[Libav-user] AVStream->time_base not functional

Hendrik Leppkes h.leppkes at gmail.com
Mon Nov 21 12:41:09 EET 2016

On Mon, Nov 21, 2016 at 11:35 AM, Sampsa Riikonen
<sampsa.riikonen at iki.fi> wrote:
> Hi,
> At the current development branch, setting
> AVStream->time_base
> does not have any effect on the final stream time base anymore..!
> (in earlier versions there where the codec time base and the stream time
> base, and one had to do "av_packet_rescale_ts" when giving the AVPackets to
> the muxer).
> Whatever I put in the stream time base, the matroska muxer always writes
> into the file header (you can check this with "mkvinfo -g filename.mkv")
> like this:
> Track => default duration => 1000 ms ("1000 frames/fields per second for a
> video track")
> Timestamps for individual frames are ok, but media players, live vlc, fail
> miserably when seeking such a file.
> .. in order for them to do decent seeking, they need the timebase to reflect
> the actual frame rate of the video stream (i.e. for 20 fps "track => default
> duration => 40 ms").
> Unfortunately, in "avformat.h":
> -------
> ...
> *   etc.) as known. The @ref AVStream.time_base "stream timebase" should
> *   be set to the timebase that the caller desires to use for this stream
> (note
> *   that the timebase actually used by the muxer can be different, as will
> be
> *   described later).
> ...
> * information on the packets sent to the muxer must be in the corresponding
> * AVStream's timebase. That timebase is set by the muxer (in the
> * avformat_write_header() step) and may be different from the timebase
> * requested by the caller.
> -------
> Why was this implemented?  Is there any way to force the timebase to a
> certain value?

You can set the default duration by setting AVStream.avg_frame_rate,
if thats not set then it'll use the time_base for that.

I don't see anything that would overwrite the time_base in matroska, though.

- Hendrik

More information about the Libav-user mailing list