[libav-api] Set timestamps for muxing after seeking
lu_zero at gentoo.org
Tue Sep 1 12:33:57 CEST 2015
On 28/08/15 20:40, Espen Jürgensen wrote:
> So my application basically transcodes (demuxes, decodes, encodes, muxes)
> very much the same way as in doc/examples/transcode.c.
> During transcoding, the user may decide to seek backwards in the input
> file. I have this working fine with av_seek_frame(). My issue is that the
> timestamps passed to the muxer are those from the decoded packets (like in
> the transcode.c example), and after seeking backwards a discontinuity
> naturally arises so they are no longer monotonically increasing, which
> understandably makes the muxer very unhappy.
> I'm thinking of a solution where I calculate the length of the jump for
> each stream, and then add those to the decoder packet timestamps given to
> the muxer, again for each stream. It would be rather cumbersome, and I have
> a feeling there is a better way of doing it? I would really appreciate some
Depending on the content you can just do a quite simple approximation:
- save the current *frame* timestamp + its duration as `now`.
- consider the first *frame* timestamp as `offset`.
- the timestamps are `now` - `offset` + the *frame* timestamps.
Ehen you seek further you update now and offset accordingly.
More information about the libav-api