[FFmpeg-devel] Internal handling of subtitles in ffmpeg

Michael Niedermayer michaelni
Thu Dec 18 20:04:24 CET 2008

On Wed, Dec 17, 2008 at 09:24:22PM +0100, Patrik wrote:
> Hey guys.
> I am looking into adding some subtitle support to ffmpeg and want to
> share an idea before going on.
> I have noticed that subtitles are sent internally in ffmpeg between
> decoders and encoders as bitmaps, which is a bit limiting if one were to
> introduce text-based subtitles.
> My idea is therefore as follows:
> 1. Extend the "format" member of the AVSubtitle struct to include a text
> format and eventually specific types of graphic formats

> 2. Add a member to the AVSubtitle struct to contain the actual subtitle
> text (utf8)

maybe that should be in AVSubtitleRect, maybe AVSubtitle, not sure ...

> 3. Create a general purpose function to convert text into a bitmap
> 4. Add an interface for subtitle codecs to publish what types of
> subtitle inputs and outputs they can (or must) have
> 5. Add some logic in ffmpeg to determine how to convert the subtitle
> types between different codecs

I like your idea, and patch(s) implementing this would be very welcome
If you decide to try to implement this, dont hesitate to send any kind
of questions to the list if you have any ...

> My idea, basically, is that if one was to transcode a text-based
> subtitle into another text-based subtitle, ffmpeg would recognize this
> and pass the text between the codecs.

> If the conversion was done from a text-based to a bitmap-based, ffmpeg
> would use its "general purpose" bitmap generator to pass bitmaps. (Maybe
> this could be enhanced to support arguments for fonts, size, color,
> placement, etc.)

This generator (let me call it renderer) is also needed for ffplay to
display the text subs.

we might one day even add OCR support to do the opposit way ...

> If new subtitle graphic formats are added, maybe ffmpeg could convert
> between those as well.

graphic formats should be the normal pixel formats and supported by

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081218/ad5d0657/attachment.pgp>

More information about the ffmpeg-devel mailing list