I've been pulling my hair lately with FFmpeg commandline. Be aware that I am not an FFmpeg expert. Here is my problem:

I have a bunch of YUV422 images as such:


Along with these I have a file containing timestamps for every image, say:


I would like to encode a lossless video (maybe with -c:v libx264 -pix_fmt yuv422p) from these with every image displayed at its correct timstamp. Here are the things I tried in vain:

  • use -f concat and provide a file containing a list like this:

    file 'image0.yuv'
    duration '0.0515'
    file 'image0.yuv'
    duration '0.0721'
    ... etc

    this solution does not work because I need to provide a frame size (which is not included in the raw yuv files)

  • something like cat *.yuv | ffmpeg -f rawvideo -s 800x600 -pix_fmt yuv422p -framerate 0.5 -i - -c:v libx264 -pix_fmt yuv422p out.mp4 which doesn't work neither because I can't provide it timestamps for each image (variable framerate) but just use the fixed -framerate argument

  • I'm aware of the -vsync vfr argument but can't manage to make it work properly

I would be eternally grateful for any piece of advice, thanks :)


It's not possible to specify common input options for the concat demuxer. Quick and dirty workaround: convert all YUV images to something that can be read without having to specify further options. For example:

for f in *.yuv; do ffmpeg -f rawvideo -s 320x240 -pix_fmt yuv422p -i "$f" "${f%%.yuv}.avi"; done

Then, construct your concat file with the AVI files instead.

Or, with GNU parallel:

parallel 'ffmpeg -f rawvideo -s 320x240 -pix_fmt yuv422p -i {} {.}.avi' ::: *.yuv

Or use the method linked to in the comments wherein you can pipe the YUV images and later modify the CFR timestamps of the generated file to become VFR.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.