[FFmpeg-devel] Supporting container formats with PTS gaps (Ogg)

Måns Rullgård mans
Mon Feb 2 14:48:57 CET 2009


Peter Ross <pross at xvid.org> writes:

> Hi,
>
> The design of Ogg container format challenges the way FFmpeg (and most other
> media tools) do business. Namely:
>
> 1. A PTS value is typically associated with a group of video or audio packets.
> 2. The PTS value applies to the last packet in the group.
> 3. Encoding of the PTS value is defined on a per-codec basis.
>
> I am struggling with how to support #1 properly, and am looking for 'ideas'.
> At present the Ogg demuxer reports the PTS value for the packets that
> actually have a PTS, and and AV_NOPTS_VALUE for other packets.

The MPEG demuxers do the same.

> This is adequate for simple playback, but when copying an Ogg file
> to another format, things break. For example, the ffmpeg program
> tries to calculate the DTS value from the previous PTS (see
> output_packet() ffmpeg.c ~1396). There is some other functional
> cruft in libavformat that attempts to calculate PTS from DTS
> (compute_pkt_fields2() in libavformat/utils.c ~2548).

I consider this mess a flaw in the FFmpeg design.  Some formats
provide only occasional timestamps, and there is no generic way to
find the missing timestamps without (more or less) decoding the
elementary streams.  The current approach seems to be vigorous denial
of this, and a half-baked attempt at inventing the missing
timestamps.  More often than not this fails, resulting in the infamous
"non-monotone timestamps" error when stream-copying.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list