[MPlayer-dev-eng] [PATCH] libass: fix parsing of tracks extracted from containers

Uoti Urpala uoti.urpala at pp1.inet.fi
Sun Sep 14 20:03:45 CEST 2008


On Sun, 2008-09-14 at 14:49 +0300, Ivan Kalvachev wrote:
> So could somebody give nice explanation with _examples_ of both
> methods and the differences associated in them.

Currently Matroska is the only container that supports ASS subtitles.
The bitstream contents of each subtitle packet are <ReadOrder, ASS
subtitle contents>. ReadOrder is the line number where this subtitle was
stored in a .ass file; this allows reconstructing a file similar to the
original from the muxed version and has also been useful in MPlayer to
identify which subtitles have already been seen and which are repeated
after a seek back. Information about subtitle start and stop times is
stored at the container level.

The subtitle format contains two timed changes to subtitle content in
each packet: the time when the subtitle appears, and the time when it
disappears. This causes a problem for containers that only support a
single timestamp per packet. To mux the subtitles into such a container
you need to either split each packet in two or use a hack moving part of
the timing information inside the bitstream of the packet. Aurelien
wanted to pick such a format. He insisted on using an existing format
instead of designing a new one; however as no one is yet using ASS with
containers that would need such a format a suitable one did not exist.
So instead he made up a packet format based on the spec for lines in
a .ass file. This was not a format meant for muxing and is not suitable
for it.

Aurelien's format has <absolute start time, absolute stop time, ASS
subtitle contents>. This duplicates the start time which practically all
containers CAN store. Using absolute timestamps inside the bitstream is
a bad choice as it means all timing changes require modifying the
bitstream. If you need to move part of the timing information there then
the best choice is to store the duration from start to end instead. This
allows changing the timing without bitstream modification as long as
duration does not change. Aurelien's format also lacks support for
ReadOrder so you cannot mux SSA/ASS from Matroska into his format
without losing information.

I think the best format for containers that only support a single time
value would be <duration, ReadOrder, ASS subtitle contents>. This avoids
absolute timestamps and can be easily converted to/from the Matroska
format (which is used by all existing content) by removing/adding the
"duration, " prefix.

Another question is what format to use internally in lavf and in MPlayer
(assuming you want to convert all ASS packets to a standard format).
Aurelien wants to use his format because in theory it could be muxed
into more containers unmodified. I think the Matroska format is a better
choice. Moving the timing information inside the bitstream is a
workaround for container limitations, and even if such limitations are
common that doesn't mean you should limit your program in the same way.
Also his justification relies on the unproven assumption that multiple
containers would define ASS storage to work the way he prefers; at the
moment no container does that.

The code changes Aurelien wanted in MPlayer also had the additional
breakage that they moved all timing information inside the codec
bitstream, completely ignoring what was stored at the demuxer level.




More information about the MPlayer-dev-eng mailing list