Concat two mp4 files with ffmpeg without losing quality
Solution 1:
Consider using the concat
demuxer. This way you can avoid creating temporary, lossy intermediate files and skip an extra step of re-encoding.
Note: All inputs must have the same stream types (same formats, same time base, etc.).
-
Create a text file and include the paths and names of each file to concatenate (or "join"). Example file,
input.txt
:file '/home/jenia/input1.mp4' file '/home/jenia/input2.mp4' file '/home/jenia/input3.mp4'
-
Now you can use the
concat
demuxer:ffmpeg -f concat -i input.txt -codec copy output.mp4
If you do not have this feature, then either your ffmpeg is too old, or you're using a "fake" ffmpeg from the libav fork.
Easy to use static builds are available for Linux, OS X, and Windows via the FFmpeg download page, or you can follow a step-by-step guide to compile ffmpeg.
Also see:
- How to concatenate (join, merge) media files
- Who can tell me the difference and relation between ffmpeg, libav, and avconv?
Solution 2:
The quickest 1-liner would be:
ls Movie\ Part\ * | while read line; do echo file \'$line\'; done | ffmpeg -f concat -i - -c copy output.mp4