ffmpegframe-rate

Limiting video fps with `select` filter


So this filter supposedly limits a video's FPS to 30 by doing frame selection: select='eq(n,0)+if(gt(t-prev_selected_t,1/30.50),1,0)

The problem is, when I use this on a 120fps video and output as HLS, the .m3u8 file under-reports the segment lengths by 25%, or rather, ffmpeg seems to be selecting the wrong # of frames per segment because it thinks the video is still 120fps. If I inspect the .ts files in Windows, the metadata suggests the video is still 120fps.

Any ideas how to recalculate the correct fps in ffmpeg without doing additional video processing?

Otherwise, is there another way to limit the FPS to 30 without a separate ffmpeg/ffprobe command?


Solution

  • Instead of troubleshooting this, use the option -fpsmax 30 which I added in v4.4. It's an output option, to be used in place of -r 30. If the input fps is equal or lower, it will preserve that. If higher, it will clamp it to the given value.