[FFmpeg-devel] Rendering text-based subtitles
chrisburel at gmail.com
Sat May 28 02:51:22 CEST 2011
I'm interested in getting support for rendering text based subtitles, like
ass and srt. This would be useful for encoding text-based subtitles to
xsub. I've hacked in a patch to get this to work using libass, but I had to
do some things that seem wrong to get it to work. I'm writing this to start
the process of cleaning up this patch so it can be merged in.
Here's some of the problems I faced:
Since I'm mainly concerned with playing the result of this process on the
PS3, I was mainly concerned with getting the xsub encoder to work. On my
first pass, I put the rendering code into the xsub encoder. This proved to
be problematic for a couple of reasons. #1, it seemed wrong to have the
xsub encoder know about how to render ass subtitles. #2, ass allows events'
timecodes to overlap, but the PS3 doesn't. So for example, let's say two
ass events overlap. xsub encode needs to adjust the end time of the first
event to be just before the begin time of the next one. But the encoder
doesn't have access to the next event yet, so it can't do that. To solve
these issues, I moved the rendering code into the decoder of the ass
subtitles. The first problem I encountered here is that the decoder doesn't
know the output resolution (which libass needs to know). So right now I
have a resolution hard-coded in the decoder, which is terrible. But less
terrible than not having subtitles if they're timecodes overlap.
Another problem is that I had to make an addition to a struct in the libass
library that breaks its ABI. The author of that library didn't want to
include my patch because of this. The change is relatively small, but still
requires adding some fields to a struct. I created a bug/issue report for
this on the libass google code page:
A couple questions:
Is this a feature that the maintainers of ffmpeg would like to see merged
Where does the rendering code really belong? In the ass decoder? In the
ass encoder? Somewhere else entirely?
Is linking in libass a problem?
I wasn't planning on posting the patch yet, because this is my first time
coding in ffmpeg and I don't want to embarrass myself :-). But if none of
my questions make sense without seeing some code, then I'll post it.
More information about the ffmpeg-devel