[FFmpeg-devel] Internal handling of subtitles in ffmpeg

Reimar Döffinger Reimar.Doeffinger
Fri Dec 19 13:51:22 CET 2008

On Fri, Dec 19, 2008 at 01:20:02PM +0100, Michael Niedermayer wrote:
> On Fri, Dec 19, 2008 at 12:57:19PM +0100, Reimar D?ffinger wrote:
> > On Fri, Dec 19, 2008 at 12:20:46PM +0100, Michael Niedermayer wrote:
> > > the subtitle decoders are supposed to output what is stored in the
> > > bitstream
> > > in a decompressed and generic repressentation.
> > 
> > I am arguing that this generic representation is bitmap format also
> > for
> > text.
> find my reply in the attached file.bmp

Try right-aligning the text in your email in a way that works for
everyone who reads your mails...

> what is it that can be complex by copying the relevant part of
> ASS into a char* of AVSubtitleRect ?
> Please explain/elaborate on this

Nothing unless you want more than one AVSubtitleRect with text (is order
relevant or not?) or you actually want to keep x, y, w and h meaningful.
If you just want to do
text = strdup(..);
x = y = w = h = 0;
there is of course no problem, though I do not see a point then either
(or slightly more useful make them only guesses for non-ASS capabel
renderers, that would still make them non-correct).

> what i suggest is to split the ASS string into parts (in reallity that
> being 1 part 99% of the time) extract time and position into the AVSubtitleRect
> put the ASS string with its encoded effects into a char* of the struct
> and return that. The renderer (which you above implicitly assume to posses)
> then can convert this to a bitmap. Or a encoder could encode it again.

Hm, okay. Except that I think that extracting the position (at least in
absolute pixel coordintes) for ASS would basically mean you have to render
it, at least you would need to know the size of the font and the size of
the display screen and it would not be correct when displaying at a
different size (think of e.g. right-aligned text with fixed-size font,
or subtitles that should be located in the non-coded black border of the
video if there is any).
This is why I think that AVSubtitleRect (as-is or with only simple
extensions) can not allow for a equivalent transformation between text
subtitle formats and why I think there is no point in involving it in
the conversion.
Which would leave the only use of it for display, in exactly the way it
was decoded and for that extending AVSubtitleRect just seems like
overkill, and it would mean running almost the same rendering code twice,
once to get x/y/w/h of the AVSubtitleRect and once to actually render it.
I will note that the same issues in principle apply to bitmap subtitles,
but at least users there expect them to look like crap at the wrong

Reimar D?ffinger

More information about the ffmpeg-devel mailing list