ffmpeg CLI set -r 30 if input => 30 fps, else -r to take input fps if < 30 fps

扶醉桌前 提交于 2019-12-20 07:35:32

问题


I posted my original question here. Tried suggested solution. But it does not solve my question.

Here's what I did. Download this video from Youtube as a test. Using ffprobe gives:

Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 1k tbn, 119.88 tbc (default)

The ffmpeg command I used:

ffmpeg -i Iron_Man_1080p_60fps.mp4 -vf "select='eq(n,0)+if(gt(t-prev_selected_t,1/30.01),1,0)'" -vsync 0 -c:v libx265 -crf 28 -c:a aac -b:a 64k Iron_Man_1080p_60fps_CONVERTED.mp4

ffprobe my output file Iron_Man_1080p_60fps_CONVERTED.mp4:

Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 454 kb/s, 20.49 fps, 59.94 tbr, 19001 tbn, 59.94 tbc (default)

As you can see, the fps dropped from 59.94 fps to 20.49 fps.

I'm not sure why the suggested solution does not work.

ffmpeg -i 120.mp4 -vf "select='eq(n,0)+if(gt(t-prev_selected_t,1/30.01),1,0)'" -vsync 0 out.mp4

Perhaps -vf does not set a fixed framerate?

Could someone provide an alternative solution using the -r flag please?

Here's re-stating question:

  • Set -r 30 if input fps => 30 fps
  • Set -r input_fps if input fps < 30 fps

Thank you!


回答1:


The time_base for the sample video is coarse, so the video is actually VFR. Change the interval to 1/30.5 to keep frames which are just beyond the threshold for 1/30.01

-vf "select='eq(n,0)+if(gt(t-prev_selected_t,1/30.50),1,0)'"


来源:https://stackoverflow.com/questions/59297824/ffmpeg-cli-set-r-30-if-input-30-fps-else-r-to-take-input-fps-if-30-fps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!