4

I want to ask this question again because old solutions no longer work with ffmpeg 6.0, owing to a change made in January 2023 that prevents the use of the -r and -vsync/-fps_mode parameters simultaneously.

The goal is to use filenames or superposed text with images of frames, to identify their exact (presentation) timestamps in the original video, without any kinds of offsets, sanitisations, and to a user-desired precision (by default, milliseconds). Additionally, it should be possible to tell that every frame has been dumped, and sorted in timestamp order, from a specified segment of the video. The motive is to use the video to time the durations of events recorded in it.

The command I had previously thought solved this problem was:

ffmpeg
-ss 1:23:45
-t 5
-i input.mkv
-copyts
-fps_mode passthrough
-r 1000
-frame_pts 1
%08d.jpg

But it's apparently no longer possible to use -fps_mode with -r 1000. It seems that the image2 muxer implicitly used here defaults to a timebase of 1, and -r 1000 was previously being used to scale the timebase to 0.001. I am unsure if -enc_time_base 0.001 will do the same thing, and if I may need to also use -video_track_timescale or similar. I want to ideally extract the timestamps verbatim from the source, optionally truncated (e.g. to milliseconds) and not have to make assumptions about CFR/VFR etc. So I'd like a pro to check I'm doing this correctly. I'd also like to know how to get these same timestamps superposed on the images themselves, but haven't researched it pending getting the filenames method to work. Thanks.

Here's an answer by Gyan suggesting the now-impossible mixture of -vsync and -r.

1 Answer 1

1

Yes, a change was subsequently made to enforce CFR when -r is set.
-enc_time_base 1/FPS should be used instead.

-video_track_timescale is specific to MP4/MOV output.

1
  • Here's the full command that worked for me to extract scene frames from a video and include the timestamp in the filename: ffmpeg -i "<videoPath>" -vf "select='gt(scene,0.4)'" -frame_pts true -enc_time_base 1 -vsync vfr scene-%2d.jpg
    – UnionP
    Commented Apr 25, 2023 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .