bino-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bino-list] SubTitles?


From: Martin Lambers
Subject: Re: [Bino-list] SubTitles?
Date: Sun, 10 Apr 2011 13:47:25 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8

Hi Joe!

On 10/04/11 00:04, Joe wrote:
> On Saturday 09 April 2011 15:46:05 Martin Lambers wrote:
>> Does the current version work for you, or do you need changes?
> 
> CODEC_ID_TEXT subtitles does not have any decoder in ffmpeg. Raw UTF-8 text 
> is 
> directly in packet. Please see attached patch adding support. This type of 
> subtitles are for example in Matroska mkv container. Subtitle duration is 
> taken from "packet.convergence_duration" field. This field is little bit 
> abused 
> by matroska decoder to store the duration of subtitle. I know the 
> implementation is a bit hacky and maybe the right way is to add encoder into 
> ffmpeg, but as a workaround attached patch should work.

Thanks, I applied this patch plus a little additional workaround for
seeking and subtitle stream switching: since there is no decoder, any
attempt to flush decoder buffers resulted in a crash, so now we simply
don't flush CODEC_ID_TEXT streams.

> It would also by great to be able to put subtitles inside "black stripe" 
> below 
> movie when the movie is too wide. It is much better for my eyes to watch 
> subtitles in black stripe than inside movie, especially when I use parallax 
> for subtitles. In black stripe, subtitles can be far away and one does not 
> have to refocus eyes when switching focus from movie to subtitles and back. 
> Is 
> this possible? I have not tried to implement this yet so no patch now.

It is possible, but a little more complex than it might look on first sight.

Here's an outline:

We currently keep track of two viewports in video_output: one for the
left view, and one for the right view (if the stereo output method uses
two different viewports instead of only one). This viewport is only the
video area, i.e. it does not contain black bars.

We need to extent this information with the total viewport (including
black bars), so that we keep track of two viewport pairs: total_viewport
and video_viewport.

The update_subtitle_tex() function must, when rendering to display size
instead of video size, use the total_viewport area and it must also
compute the offsets to the video_viewport. This information must be
passed to the subtitle renderer. There, we set the offsets (called
margins) with ass_set_margins(), and tell LibASS to use these margins
for rendering with ass_set_use_margins(). This should probably not be
the default since ASS subtitles can be positioned to exact positions
relative to the video size, so we need to add another parameter for this
and make it configurable.

Then, in display_current_frame() step 3, we currently render to
video_viewport only. We must change this and render to total_viewport.
However, that means that our texture coordinates for the video textures
are wrong, since they assume video_viewport aspect ratio. We must
correct them using the offsets between total_viewport and video_viewport.

(It looks easier to first render the video to video_viewport and then
render the subtitle to total_viewport, but this might not work too well
with the anaglyph output modes (because of the mangled colors), and in
any case it would add an additional render pass which is probably
expensive.)

Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]