7

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?

kaka_ace
  • 327
  • 1
  • 5
  • 7
  • thx very much, i'm using the cmd-tools :) – kaka_ace Sep 03 '14 at 01:53
  • 1
    Such questions belong to http://video.stackexchange.com/questions/tagged/ffmpeg – Alex Cohn Dec 25 '15 at 02:42
  • 1
    use `-r` to set `fps`, `-video_track_timescale` to set `tbn`, refer to [ffmpeg concat compressed video result in wrong time span](https://stackoverflow.com/a/57019132/6521116) – LF00 Jul 15 '19 at 01:15

3 Answers3

6

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 called mpeg4 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 for mpeg4.
  • -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.

llogan
  • 87,794
  • 21
  • 166
  • 190
5

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
MarianD
  • 9,720
  • 8
  • 27
  • 44
picapica
  • 59
  • 1
  • 3
  • This 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. – Hermann Sep 21 '20 at 18:06
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.

Community
  • 1
  • 1
liuyang1
  • 1,415
  • 1
  • 15
  • 22
  • 3
    *ffmpeg -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. – TheKarateKid May 24 '19 at 16:36