cat like that can cause unpredictable problems. Fortunately, there are two really useful ways to concatenate files with ffmpeg.
If all your inputs are the same type of file (same codecs etc), then you can use the concat demuxer. This is probably the more useful answer to your question, since it is compatible with -c copy (and so should be lossless, and take an almost trivially short time to complete).
First, create a file called
inputs.txt containing the following:
Then use the following command:
ffmpeg -f concat -i inputs.txt -c copy output.flv
If that doesn't work, or you want to combine videos of different types, you can use the
ffmpeg -i input1.flv -i input2.flv -i input3.flv -i input4.flv \
-filter_complex '[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] [3:0] [3:1] concat=n=4:v=1:a=1 [v] [a]' \
-map '[v]' -map '[a]' -c:v libx264 -crf 22 -preset veryfast -c:a libfdk_aac -vbr 3 -afterburner 1 output.mp4
This example uses my preferred encoding settings, obviously change up the last line to use whatever you want to.
I'll break apart the -filter_complex section, to make it easier to follow.
'[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] [3:0] [3:1]
This fragment tells ffmpeg what streams to send to the concat filter; in this case, streams 0 and 1 from input 0 (ffmpeg starts counting from 0, so that's the first and second streams from the first input file, input1.flv in this example), and streams 0 and 1 from every input up to the fourth (input 3 according to ffmpeg, which starts counting from 0).
concat=n=4:v=1:a=1 [v] [a]'
This is the concat filter itself. n=4 is telling the filter that there are four input files; v=1 is telling it that there will be one video stream; a=1 is telling it that there will be one audio stream (I know I said that ffmpeg starts counting from 0, but apparently the writer of this filter decided to do this instead).
[v] and [a] are names for the output streams, to allow the rest of the ffmpeg line to use the output of the concat filter. I think they can have arbitrary names; which one is video and which one is audio is probably determined by their relative positions, but I haven't tested that out.
Note that the single quotes ' ' around the whole filter section are required.
-map '[v]' -map '[a]'
This tells ffmpeg to use the results of the concat filter rather than the streams directly from the input files.
Note that filters are incompatible with stream copying; you can't use -c copy with this method. I also think that it can't handle soft subtitles, though I haven't tested that: there's no hint about it in the documentation, but ffmpeg documentation is often incomplete or obfuscated, so that's not a sure sign either way.
This can concatenate files encoded in different formats (I've tested with a h264/aac MP4 and a vpx/vorbis WEBM, worked perfectly), though they need to be the same video frame size and audio depth (and possibly other things).
See also here.