[FFmpeg-devel] [BUG]+[Workaround] Video concat example from faq broken (yuv4mpegpipe broken?)

Artur Bodera abodera
Thu Dec 3 09:35:32 CET 2009

Hey everyone!

Example taken directly from http://ffmpeg.org/faq.html.
The third example for "How can I join video files?" does not work. Tried
under different compilations of ffmpeg under x86_64.

For example on ffmpeg rev. 20520 using the EXACT copy+paste of the example
from FAQ, with the exact same file formats and names, on Linux, always
results in a video file with only the first segment (input1.flv) of video.
The container reports it has the length of input1+input2 but seeking to
later parts can not be performed because there is no data (eof in vlc).

I have found out it is related to yuv4mpegpipe which fails to work when
For example when disregarding pipes and performing the following

    ffmpeg -i input1.flv -an -f yuv4mpegpipe input1.yuv
    ffmpeg -i input2.flv -an -f yuv4mpegpipe input2.yuv
    cat input1.yuv input2.yuv > input_combined.yuv
    ffmpeg -f yuv4mpegpipe -i input_combined result.flv

It would also result with broken flv file, with only the first segment
(input1.yuv) - this suggests that it is not related to pipes, but rather the
yuv4mpegpipe codec.

A simple workaround: use rawvideo instead! The only caveat is that you need
to specify the exact video dimensions in the last ffmpeg invocation (because
rawvideo does not encapsulate that). Here's an example script of video
concat using rawvideo:

mkfifo temp1.a
mkfifo temp1.v
mkfifo temp2.a
mkfifo temp2.v
mkfifo all.a
mkfifo all.v
dims=`ffmpeg -i $1 2>&1 | grep -Po 'Stream.*?Video.*?(\d{3,4}x\d{3,4})' |
grep -Po '\d+x\d+'`
ffmpeg -i $1 -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a <
/dev/null &
ffmpeg -i $2 -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a <
/dev/null &
ffmpeg -i $1 -an -f rawvideo - > temp1.v < /dev/null &
ffmpeg -i $2 -an -f rawvideo - > temp2.v < /dev/null &
cat temp1.a temp2.a > all.a &
cat temp1.v temp2.v > all.v &
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
       -f rawvideo -s $dims -i all.v \
       -b 128k -y $3
rm temp[12].[av] all.[av]

Best regards,



    /.)\   +48 695 600 936
    \(./   abodera at gmail.com

More information about the ffmpeg-devel mailing list