0

I have a video that plays at 30fps. I changed the frame rate to 20fps by using the command ffmpeg -i lamp02_20210212_060804-compressed.mp4 -filter:v fps=20 xx.mp4. But I want to get the frame numbers of the dropped frames. I saw here Which frame does ffmpeg get when reducing the frame rate that you can get the frame but I require only the frame number. Is it possible to do this and if yes, how? Any pointers in the right direction will be helpful!

user42
  • 871
  • 1
  • 10
  • 28

1 Answers1

1

You can dump the debug logs and examine those.

ffmpeg -i input -vf fps=20 -an -f null - -v debug 2>&1 | grep Parsed_fps

The output will have lines of the form,

[Parsed_fps_0 @ 000002619a56bd40] Read frame with in pts 11264, out pts 15
[Parsed_fps_0 @ 000002619a56bd40] Writing frame with pts 14 to pts 14
[Parsed_fps_0 @ 000002619a56bd40] Read frame with in pts 11776, out pts 15
[Parsed_fps_0 @ 000002619a56bd40] Dropping frame with pts 15
[Parsed_fps_0 @ 000002619a56bd40] Read frame with in pts 12288, out pts 16
[Parsed_fps_0 @ 000002619a56bd40] Writing frame with pts 15 to pts 15

All the pts are denominated in terms of a timebase. The timebase of in pts is the reciprocal of the input stream's tbn value. The timebase of out pts is the reciprocal of the filter's output fps.

Trace the in pts for the frames which show Dropping frame with pts .. and get their timestamp values.

Gyan
  • 85,394
  • 9
  • 169
  • 201