[FFmpeg-devel] How do we deal with muxing 3GPP Timed Text subtitles?

Nicolas George nicolas.george at normalesup.org
Sun Jul 8 16:32:10 CEST 2012

Le decadi 20 messidor, an CCXX, Philip Langdale a écrit :
> 1) As mp4 doesn't store duration, the end of a subtitle is
> represented by an empty subtitle, unless it is intended to
> remain visible until the next real subtitle appears.

After a real sample is written, note its end time somewhere in the private
context. Before any packet, check that field to see if any subtitle has just
expired. If so, output the empty subtitle packet.

It looks like it was the easy case: we have the full information (pts and
duration) and will only use some of it later, it is easy to store it.

The symmetric case would have been much harder: remux from a format with
start+end packets to a format with durations, because part of the
information we need immediately will only come after possibly megabytes
worth of unrelated data.

> 2) After a real sample is written, write another empty sample to
> mark the duration. To try and avoid non-monotonically increasing
> pts, the pts of the empty sample is (pts + duration - 10). This
> is shitty, and doesn't always work due to rounding.

As Clément pointed out, you can write the empty subtitle packet always. If
there are drawbacks to that, you can write in the first call to write_packet
with non-zero PTS.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120708/863d8b58/attachment.asc>

More information about the ffmpeg-devel mailing list