Quick tip: Concatenating video files (with no quality loss)

Concatenation of video files can be done quickly from the command-line, video files must “match” (e.g. a movie formerly split into parts) i.e. they must use the same codec and parameters, this methods won’t work as expected with random files.

  • AVI files: Use mencoder with multiple inputs
    $ mencoder -oac copy -ovc copy -o output.avi input1.avi input2.avi [...]
  • MPEG files: They can either be concatenated directly:
    $ cat input1.mpg input2.mpg > output.mpg
    Or the mencoder method, which I prefer, can be used (note the output format must now be set):
    $ mencoder -oac copy -ovc copy -of mpeg -o output.mpg input1.mpg input2.mpg [...]
  • Quirks and other formats:
    • The mencoder method won’t work for multi-audio files
    • mencoder has worse support for other formats, they might require an intermediate transmuxing to avi.

I’ll update this post if I find better ways or alternatives to do this.


References:

This entry was posted in Command Line, English, Linux, Recipes and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.Required fields are marked *

Your message will require approval before publishing, this will delay it's appearance on the site.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>