[FFmpeg-devel] Implementing Fixed-Interval Input Reading/Sampling

Soft Works softworkz at hotmail.com
Wed Jan 9 15:22:30 EET 2019


Hi,

I am posting to devel as I’m assuming that this won’t go without some changes to the code base, so please bear with me even though it may sound like a user issue at first sight:

This is about extracting images from a video file – every 10s in the following example:

    ffmpeg -i input.mkv -r 0.1 -s 320x132 img_%05d.jpg

This is working of course, but it takes a pretty long time. Problem seems to be that the video is always fully decoded to every single frame. For a 30fps video that means 300  frames need to be decoded for every single image that I want.

I’m not sure whether I’m missing something, but among all available parameters and filters I couldn’t find a way to affect input reading, like:

"after one video frame (or timespan x) has been read, skip forward 10s reading the input”
(I apologize, if there’s already a way to do this – at least I couldn’t find one.)


I suppose the primary question about this might be “WHY?”.
And this is easy to explain. Looking at the above command line:

    ffmpeg -i input.mkv -r 0.1 -s 320x132 img_%05d.jpg

This will create 60 images for a 10 minute video.

Alternate method: When I run ffmpeg 60 times in a batch file like this:

ffmpeg -ss  0 -f matroska -i input.mkv -v quiet -vframes 1 -s 320x132 thumbX_0.png
ffmpeg -ss 10 -f matroska -i input.mkv -v quiet -vframes 1 -s 320x132 thumbX_1.png
ffmpeg -ss 20 -f matroska -i input.mkv -v quiet -vframes 1 -s 320x132 thumbX_2.png
ffmpeg -ss 30 -f matroska -i input.mkv -v quiet -vframes 1 -s 320x132 thumbX_3.png
ffmpeg -ss 40 -f matroska -i input.mkv -v quiet -vframes 1 -s 320x132 thumbX_4.png
ffmpeg -ss 50 -f matroska -i input.mkv -v quiet -vframes 1 -s 320x132 thumbX_5.png
ffmpeg -ss 60 -f matroska -i input.mkv -v quiet -vframes 1 -s 320x132 thumbX_6.png
…
…

Those 60 ffmpeg executions are still twice as fast as the single command above.

So, at least by theory, that whole process should be able to perform even faster with a single (optimized) execution instead of 60.

What’s your thoughts about this?
Did I make any incorrect assumptions?

Thanks you very much,

softworkz










More information about the ffmpeg-devel mailing list