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

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.

Leave a Comment