ffmpeg how to control fps tbr tbn tbc parameters
20,158
Solution 1
You can re-encode with a specified frame rate:
ffmpeg -i B.avi -codec:v mpeg4 -r 30 -qscale:v 2 -codec:a copy C.avi
What these options mean:
-
-codec:v mpeg4
- Use the encoder calledmpeg4
for MPEG-4 Part 2 video. -
-r 30
- Set output frame rate as 30. -
-qscale:v 2
- Set video output quality using a constant quantization parameter. Recommended range is 2-5 formpeg4
. -
-codec:a copy
- Copy the audio from input to output to avoid re-encoding.
Note that ffmpeg
will simply duplicate frames to achieve your desired output frame rate. If instead you were reducing your frame rate ffmpeg
would drop frames.
Solution 2
You can change timebase or tbn
tbc
by -video_track_timescale
, e. g. to change the tbn
and tbc
to 30:
ffmpeg -i 1.avi -c:v copy -video_track_timescale 30 1.avi
Solution 3
if you want more presice control, not only control fps. but also tbr, tbn, tbc. assume you understand what mean of it. tbc,tbn,tbr
check
ffmpeg -x264opts timebase=???
or
ffmpeg -time_base
or use format factory, default it give you same tbr, tbn, tbc.
![kaka_ace](https://i.stack.imgur.com/S5O6d.jpg?s=256&g=1)
Comments
-
kaka_ace almost 2 years
RT, i have two avi file,
A.avi: fps 30 tbr 30 tbn 30 tbc 30. B.avi: fps 2 tbr 2 tbn 2 tbc 2.
the problem is how to set the same value 30 on B.avi?
-
TheKarateKid about 5 yearsffmpeg -i input.mp4 -time_base 1/30 -c:a copy -c:v copy output.mp4 Is what I used. The time_base parameter successfully changed the 'tbn' to match on both videos without re-encoding. You may need to apply additional parameters if other settings need to be uniform before joining the videos.
-
Hermann almost 4 yearsThis was helpful for me. I have a video I want to prepend with some seconds of black. The concatenated video was played much slower, the effective frame-rate only a quarter of the desired frame-rate. I was able to use
ffmpeg -f lavfi -i color=size=1920x1080:rate=60:color=black -t 10 -video_track_timescale 60k black.mp4
to generate a video with a tbn matching the actual video. The tbc does not seem to be important in this context.