0

I am using ffprobe to extract frame rate as follows:

ffprobe -show_streams rgbok.mp4

which on 99% of my videos gives:

Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1440, 37471 kb/s, 30 fps, 30 tbr, 19200 tbn (default)

However, on one or two videos I don't get fps for example one gives:

Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1280x720, SAR 1:1 DAR 16:9, 14.25 tbr, 1k tbn (default)

My suspicion - based on https://askubuntu.com/a/110269/634607 - is that I am not getting a frame rate because the frame rate is variable.

As such, how can I reliably get an average frame rate on a variable frame rate video?

Note I've also tried:

ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=avg_frame_rate rgb.mp4

which gives 311400/10381 (29.997) on a working video but gives 0/0 on one of the videos which does not work.

Finally, I've also tried:

ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=r_frame_rate rgb.mp4

which gives 30/1 (30) on a working video and gives 57/4 (14.25) on one of the videos which does not work but 14.25 seems like an odd frame rate and I am not convinced I can rely on this as an average frame rate.

So how can I reliably get FPS for a video with a variable frame rate?

halfer
  • 19,824
  • 17
  • 99
  • 186
danday74
  • 52,471
  • 49
  • 232
  • 283
  • You may use FFprobe to [count the number of frames](https://stackoverflow.com/a/28376817/4926757), get [duration in seconds](https://superuser.com/questions/650291/how-to-get-video-duration-in-seconds) and divide. In case it's not working you may use `ffprobe -select_streams v -show_entries packet=duration_time ...` and sum the durations using a script. – Rotem Jul 18 '22 at 16:32

0 Answers0