Char
Char

Reputation: 115

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

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:

Thank you!

Upvotes: 1

Views: 915

Answers (1)

Gyan
Gyan

Reputation: 93008

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)'"

Upvotes: 2

Related Questions