1

How can I use the avconv tool to concatenate multiple .mp4 videos of different encoding parameters in a single container, without losing quality?

3
  • You can only do that if the output video is losslessly encoded. Is that acceptable? What's your use case here?
    – slhck
    Commented Oct 2, 2014 at 6:56
  • @slhck Yes, the output video can be losslessly encoded. The use case is that I have different scenes of a movie in separate files, encoded with different parameters. I would like to concatenate them in a single output file, in such a way that each scene retains original quality.
    – a06e
    Commented Oct 2, 2014 at 12:08
  • related: superuser.com/a/522658/91054, however that uses ffmpeg, and some options are not recognized by avconv
    – a06e
    Commented Oct 2, 2014 at 12:09

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .