How to concatenate two flv files?
I would personally do this with ffmpeg's
Concat demuxer
First create a file called inputs.txt
which looks like this:
file 'input1.flv'
file 'input2.flv'
Then use ffmpeg like so:
ffmpeg -f concat -i inputs.txt -c copy output.mp4
(You can use output.flv
, though MP4 is a generally more useful format). The demuxer is avaiable on versions of ffmpeg from 1.1 onwards. If you want to stick to an outdated version of ffmpeg for some reason, you can use the
Concat protocol
This is a little bit complicated. The FLV container does not support concatenation at the file level, so you'll need to remux to a container that does - like an MPEG Transport Stream. Unfortunately, with h.264 video and AAC audio, you'll need to apply a couple of bit stream filters.
Since you're on linux, you can use named pipes.
mkfifo temp0 temp1
You'll need to do the following in three separate teminal windows (or tabs if your terminal emulator supports them - ctrl+shift+t
normally opens a new tab):
ffmpeg -i input0.flv -map 0 -c copy -f mpegts -bsf h264_mp4toannexb -y temp0
ffmpeg -i input1.flv -map 0 -c copy -f mpegts -bsf h264_mp4toannexb -y temp1
ffmpeg -f mpegts -i "concat:temp0|temp1" -c copy -absf aac_adtstoasc output.mp4
You can, in fact, run all of those on one (rather complicated-looking) command line:
ffmpeg -i input0.flv -map 0 -c copy -f mpegts -bsf h264_mp4toannexb -y temp0 2> /dev/null & \
ffmpeg -i input1.flv -map 0 -c copy -f mpegts -bsf h264_mp4toannexb -y temp1 2> /dev/null & \
ffmpeg -f mpegts -i "concat:temp0|temp1" -c copy -absf aac_adtstoasc output.mp4
Make sure that output.mp4 doesn't already exist, of this won't work. If someone is reading this is on a system that doesn't support named pipes, they'd have to use:
ffmpeg -i input0.flv -map 0 -c copy -f mpegts -bsf h264_mp4toannexb temp0.ts
ffmpeg -i input1.flv -map 0 -c copy -f mpegts -bsf h264_mp4toannexb temp1.ts
ffmpeg -i "concat:temp0.ts|temp1.ts" -c copy -absf aac_adtstoasc output.mp4
This will create a pair of intermediary files called temp0.ts and temp1.ts, which can be safely destroyed when you're done.
Note that these instructions will work for the FLV files specified in the OP, and probably most modern FLVs from the internet, since they almost-universally use h264 video and aac audio. For other codecs, these instructions will have to be tweaked a little.
Do you insist on using FLV format? you can convert them to mpg or some other formats(refer this) and then join them(refer this).
or may be you can just try the joining method directly on flv files.
EDIT
Read this or this. It uses some different parameters for MEncoder.