使用`select`过滤器限制视频帧率

huangapple go评论52阅读模式
英文:

Limiting video fps with `select` filter

问题

这个滤镜据说通过帧选择将视频的帧率限制在30帧每秒:
select='eq(n,0)+if(gt(t-prev_selected_t,1/30.50),1,0)

问题是,当我在一个120帧每秒的视频上使用这个滤镜并输出为HLS格式时,.m3u8文件报告的段长度低于实际长度25%,或者说,ffmpeg似乎选择了错误的帧数来表示每个段,因为它认为视频仍然是120帧每秒。如果我在Windows中检查.ts文件,元数据表明视频仍然是120帧每秒。

有没有办法在ffmpeg中重新计算正确的帧率,而不需要进行额外的视频处理?

否则,是否有另一种方法可以将帧率限制在30帧每秒,而不需要额外的ffmpeg/ffprobe命令?

英文:

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?

答案1

得分: 1

使用我在v4.4中添加的选项-fpsmax 30,而不是解决此问题。这是一个输出选项,可用于替代-r 30
如果输入的帧速率等于或更低,它将保持不变。如果更高,它将将其限制为给定的值。

英文:

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.

huangapple
  • 本文由 发表于 2023年7月3日 22:50:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605864.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定