FORUMS: list search recent posts

HANDY TIP: Concatenating ffmpeg encodes

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Michael Rampe
HANDY TIP: Concatenating ffmpeg encodes
on Jun 12, 2010 at 4:50:15 am


You can easily concatenate (chain together) several FFmpeg commands to produce multiple sequential encodes in one command line. You can also join video files in this way.

Example parallel use:
ffmpeg -i -y out1.mp4 && ffmpeg -i -y out2.avi && ffmpeg -i -y out3.flv && ffmpeg -i -y

The same input file is being encoded to several different formats.
Useful for:
  • Trying different variations of an encode command in one go.
  • Encoding to multiple sizes and/or bitrates in one go.

Example chained use:
ffmpeg -i -y out1.mp4 && ffmpeg -i out1.mp4 -y out2.avi && ffmpeg -i out2.avi -y out3.flv && ffmpeg -i out3.flv -y

The output of the first command is being used as the input for the second command and so on.

Useful for:
  • Encoding once and rewrapping the codecs into a different container without re-encoding.
  • Creating intermediates to join movies using the cat command and compress to the desired output.

ffmpeg -i -sameq -y tmp1.mpg && ffmpeg -i -sameq -y tmp2.mpg && cat tmp1.mpg tmp2.mpg > tmp3.mpg && ffmpeg -i tmp3.mpg -vcodec libx264 -vpre hq -b 1500k -y joined.mp4

By using the -sameq command as well as the mpg format, you are ensuring an absolute minimum loss of quality. mpg has to be used as it's raw codec streams can easily be joined into a valid movie file by *nix with the cat command. This high quality intermediate is then encoded to a format or size of your choice, 1.5 m/bit x264 in this case.
(The two movies are the same size and frame rate in this example. There is no audio in this example.)

Experiment with different combinations and settings to make life easier. I can post some examples with audio if desired.

Take it easy.


"half-way to world domination A.K.A. the belligerent blue bike shed"

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved