Saturday, 2 April 2016

Ubuntu - merge Video files

The following applications can be used to concatenate video files.

Some ways to determine details of the media files :
ffprobe file.mp4
ffmpeg -i file.mp4

Extracting AC3 audio with FFMpeg

ffmpeg -i video.avi -acodec copy audio.ac3
or if there are multiple audio streams use the map to select the correct stream to extract

ffmpeg -i my_input_file.m4v -map 0:2 -c:a copy output_file.ac3 

MP4

sudo apt-get install gpac 
 MP4Box -add file1.mp4 -cat file2.mp4 NameofCombinedFile.mp4

Update:

And a way with ffmpeg (if all files are the same format):
ffmpeg -f concat -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy ../destination.mp4

Update2:

And to compress the mp4 afterwards for something like Youtube:
ffmpeg -i source.mp4 -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart target.mp4
Update 3: 

to add a audio channel to a video file:
MP4Box -new -add OriginalMovie.mp4 -add Track2.mp3#audio:delay=300 Output.mp4

MKV

sudo apt-get install mkvtoolnix

mkvmerge [global options] {-o out} [options1] {file1} [[options2] {file2}] [@optionsfile] 

AVI

sudo apt-get install transcode transcode-utils
avimerge -i part1.avi part2.avi -o joinedfile.avi

 




No comments:

Post a Comment