Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is video timescale, timebase, or timestamp in ffmpeg?

There does not seem to be any explanation online as to what these are. People talk about them a lot. I just want to know what they are and why they are significant. Using -video_track_timescale, how would I determine a number for it? Is it random? Should it be 0?

like image 795
Please Help Avatar asked Apr 10 '17 21:04

Please Help


People also ask

What is timebase Ffmpeg?

AVCodecContext::time_base This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented. For fixed-fps content, timebase should be 1/framerate and timestamp increments should be identically 1.

What is Presentation timestamp in ffmpeg?

This value is a timestamp that corresponds to a measurement of time in that stream's time_base unit. For example, if a stream has 24 frames per second, a PTS of 42 is going to indicate that the frame should go where the 42nd frame would be if there we had a frame every 1/24 of a second (certainly not necessarily true).

What is pts in video?

The presentation timestamp (PTS) is a timestamp metadata field in an MPEG transport stream or MPEG program stream that is used to achieve synchronization of programs' separate elementary streams (for example Video, Audio, Subtitles) when presented to the viewer.


1 Answers

Modern containers govern the time component of presentation of video (and audio) frames using timestamps, rather than framerate. So, instead of recording a video as 25 fps, and thus implying that each frame should be drawn 0.04 seconds apart, they store a timestamp for each frame e.g.

 Frame      pts_time    0          0.00    1          0.04    2          0.08    3          0.12    ... 

For the sake of precise resolution of these time values, a timebase is used i.e. a unit of time which represents one tick of a clock, as it were. So, a timebase of 1/75 represents 1/75th of a second. The Presentation TimeStamps are then denominated in terms of this timebase. Timescale is simply the reciprocal of the timebase. FFmpeg shows the timescale as the tbn value in the readout of a stream.

Timebase = 1/75; Timescale = 75  Frame        pts           pts_time    0          0          0 x 1/75 = 0.00    1          3          3 x 1/75 = 0.04     2          6          6 x 1/75 = 0.08    3          9          9 x 1/75 = 0.12    ... 

This method of regulating time allows variable frame-rate video.

like image 140
Gyan Avatar answered Oct 19 '22 17:10

Gyan