Ubuntu – How to concatenate several FLV files into one

flvvideo

I have a handful of FLV files that are in fact a single sequence. I'd like to combine them into a single file, e.g. part1.flv, part2.flv, part3.flv become final.flv.

What is the easiest way that I can do this without losing video quality?

Best Answer

I'd suggest mencoder. This is a part of mplyaer and can be used at command line:

mencoder -oac copy -ovc copy -o final.avi part1.flv part2.flv part3.flv

Normally -oac and -ovc are for special audio and video codecs. In this case the commands says it just should (stream)copy them. The option -o gives the name of the output file.

The output could be forced to FLV, but this is currently buggy, and you will get the following message if you try adding -of lavf:

REMEMBER: MEncoder's libavformat muxing is presently broken and can generate INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer will play these INCORRECT files as if nothing were wrong!

According to your comment you got the error:

Audio format 0x4134504d is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it.

According to a blog entry this is caused by attempting to convert AAC audio. In this case you can try -oac mp3lame instead.

Otherwise, add the option -fafmttag plus a code for your audio codec. Usually mplayer has a file etc/codecs.conf. There you'll find which code maps to which codec. This file does not always exist.

If this doesn't work for you, you can also recode the audio. However this is too complex to describe in this answer. You'll need to look at the manpage or ask another question here.