Variable framerate lossless video from yuv422 images

0

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:

image0.yuv
image1.yuv
..
image450.yuv

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

timestamps.txt

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 :)

Robin Beilvert

Posted 2019-01-14T15:38:29.597

Reputation: 3

See https://video.stackexchange.com/a/19726

– Gyan – 2019-01-14T15:51:59.670

Answers

1

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.

slhck

Posted 2019-01-14T15:38:29.597

Reputation: 182 472