How can I use the avconv tool to concatenate multiple .mp4 videos of different encoding parameters in a single container, without losing quality?
Asked
Active
Viewed 1,713 times
1 Answers
1
The commands given here will not work when videos have different encoding parameters. In fact, you can only concatenate them by bringing them to the same parameters first, working in the decoded (pixel) domain, and then losslessly storing them.
For example, harmonizing the framerate and video dimensions, audio sampling rate and audio channels:
avconv -i input_1.mp4 -s 1920x1080 -r 25 -c:v ffv1 -c:a pcm_s16le -ac 2 -ar 44100 out_1.avi
avconv -i input_2.mp4 -s 1920x1080 -r 25 -c:v ffv1 -c:a pcm_s16le -ac 2 -ar 44100 out_2.avi
avconv -i "concat:out_1.mp4|out_1.mp4" -c copy output.avi
This uses ffv1 as lossless codec, but any other lossless codec would work fine (e.g., huffyuv in an AVI or libx264 with -crf 0 in an MP4).
If you want a "small" output file again, you have no other choice than compressing output.avi with some lossy encoder.