[FFmpeg-user] improving selection of image frames from videos

David Bernat david.bernat at gmail.com
Mon Jul 17 19:54:16 EEST 2023


Lots of good times over here extracting frames from videos. Hello to
YouTube. Hello all you wonderful (and other) people who subscribe to this
email list to know what I am doing. (To everybody else: whoa boy do we have
a news story for you to read in the future! Hello!)

Could you help me refine this process?

The fastest process that I have determined so far is this. It allows me to
generate frames every N seconds apart, to encode the specific timestamp of
the specific frame (exactly) into the filename of the bmp, and does not
require encoding. We are going for maximum speed so we want better than
even seek, and using skip_frame helps accelerate that extraction of
individual frames as well. The use of bmp is because these are the fastest
to write files; as transformation to png or jpg can be done offline.
ffmpeg -y -hide_banner -skip_frame nokey -i FILENAME -vf fps=1/5 -vsync 0
-frame_pts true -r 1000 out%d.bmp

There are several improvements that I cannot confirm nor figure out:
1. Can we confirm that the timestamp of the bmp file is precisely the
timestamp of the frame? Using the command without "-vf fps=1/5" will select
exactly key frames, but those are every ~one second, and I need to be able
to customize this. It is not clear to me how I can pull frames at arbitrary
timestamps without doing some slower recalculation of the frames; or, what
the algorithm is doing is selecting nearest keyframes but tagging them with
filenames with filenames like out1000.bmp which is not the precise
timestamp. What can be improved?

2. This ERROR: "Using -vsync passthrough and -r/-fpsmax can produce invalid
output files" is supposed to be fixed by using -fps_mode instead of -vsync.
But unfortunately the documentation is meager, and I have not been able to
find an exact solution online. What is -fps_mode, how is it used, and what
should I be including here?

3. This WARNING: "[hevc @ 0x13d92c210] Multiple Dolby Vision RPUs found in
one AU. Skipping previous." is a warning that presumably slows down
calculation, and can be removed by properly pre-processing the file
beforehand or by properly configuring the ffmpeg command. What can I do?
The warning also throws off subprocess calls by mistaking this as an error,
but adjusting loglevel will not work as I need its full output anyway.

Thank you so much, everybody. I have been really enjoying this community a

4. Any other improvements? I plan to "ffmpeg segment" longer files into 5
minute chunks, then parallel process the selection of image files from
those at approximately 10 second intervals.

Thank you!!!!!


David Bernat, Ph. D.
text: 917-825-7193 / LinkedIn <https://www.linkedin.com/in/david-bernat/>
All content should be considered proprietary to Starlight LLC and
Confidential or higher

More information about the ffmpeg-user mailing list