[FFmpeg-devel] Internal handling of subtitles in ffmpeg
Michael Niedermayer
michaelni
Fri Dec 19 11:15:07 CET 2008
On Fri, Dec 19, 2008 at 09:47:25AM -0000, Wolfram Gloger wrote:
> > From: Michael Niedermayer <michaelni at gmx.at>
> >
> > On Thu, Dec 18, 2008 at 01:01:43PM -0000, Wolfram Gloger wrote:
> > > > 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.
> > >=20
> >
> > > Text-based subtitles _are_ already supported, please check out
> > > CODEC_ID_TEXT et.al.
> >
> > have you tried ffplay with CODEC_ID_TEXT ?
>
> No. I'm sure it doesn't actually display text -- but I didn't claim
> that. My point was that the infrastructure is already there, no real
> need for AVSubtitle changes in this respect.
if you want to convert between 2 text subtitle formats while keeping effects
then the existing system surely is not adequate.
>
> > > > 1. Extend the "format" member of the AVSubtitle struct to include a text
> > > > format and eventually specific types of graphic formats
> > >=20
> >
> > > The latter would of course be possible, but if that would be
> > > required I would suggest to use AVPicture instead as that could
> > > be AVFilter'ed more easily.
> >
> > what?!
> > AVFilter on utf8 strings?
>
> No, AVFilter on _AVPicture_! What part of "The latter" was not clear?
> Hint: I was referring to "specific types of graphic formats".
>
> IMHO it was a mistake to have a special bitmap struct in AVSubtitle
> rather than using AVPicture for the graphical subtitles. I have
using AVPictures for the graphical part is fine as long as it can
easily be extended to use non graphical as well
> already written two filters for the subtitle bitmaps which would
> surely be refused for inclusion in ffmpeg because of "use AVFilter".
>
> > > > 3. Create a general purpose function to convert text into a bitmap
> > >=20
> > > Hmm, that would require complicated font handling.
> >
> > so, users are supposed to not see the subtitles?
> > If they are supposed to see them text->bitmap IS mandatory
>
> So, what font renderer would you suggest? Surely that would have
> to be a huge external library?
> Sorry, but I will not hold my breath for this..
ive written my own simple renderer maybe 10 years ago, and no it does
not require a huge external library nor is it more than a few hours
work. Of course the result wont be doing bidirectional text or other
tricks.
Basically there are 2 things needed
1. a simple native renderer
2. a optional one that can use libfreetype or similar
the native renderer can be written in 1-2 hours by
1. Use libfreetype to generate grayscale bitmaps of all glyphs you are
interrested in (there is/was a tool in mplayer svn that does this)
for the begin a single font and fontsize is enough, of course one
can do this with more and one could compress it, after all we have
tons of excellent image encoders and decoders ...
2.
for(i=0; i<num_chars; i++){
blend_bitmap(picture, pos, font[ text[i] ].bitmap)
pos+= font[ text[i] ].width;
}
And yes i know it doesnt do many tricks like combining letters and and
and but your terminal does neither and ive never heared people even notice
let alone complain.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- 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/20081219/317568c8/attachment.pgp>
More information about the ffmpeg-devel
mailing list