[Libav-user] AVStream->time_base not functional

Sampsa Riikonen sampsa.riikonen at iki.fi
Mon Nov 21 14:25:37 EET 2016



On 21.11.2016 12:41, Hendrik Leppkes wrote:
> 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.

Thanks Hendrik - it worked.

As a side note, I discovered that older vlc(s) (like version 2.2.2 that 
comes with stock ubuntu 16) require the 20 fps timebase in mkv muxer, 
but the latest git pull (vlc 3+) doesn't mind
the timebase being the default 1 sec.

Regards,

Sampsa


>
> I don't see anything that would overwrite the time_base in matroska, though.
>
> - Hendrik
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user



More information about the Libav-user mailing list