[vlc-devel] Dynamic overlays

Laurent Aimar fenrir at via.ecp.fr
Tue Nov 4 20:58:00 CET 2008


On Thu, Oct 30, 2008, ogg.k.ogg.k at googlemail.com wrote:
> Hi,
> 
> what is the preferred way to display dynamic subtitles in VLC ?
> A search did yield 3 variables (spu-duration, spu-elapsed, text-rerender)
> but this seems to be confined to just one lump of text, and doesn't seem
> to be used much at all.
> 
> I'd like to be able to essentially draw anything onto the video. It could
> be that going for a video_filter would be the right option, but those
> overlays will be coming from a subtitles stream in the video (the kate
> subtitles module) so I'm not sure how that'd work.
> 
> Is there a better way ? If not, is there anything I should know about
> communication from a codec to a video filter ?
 the SSA and USF subtitle decoder do what you want. You could have a look at it.
The trick is to define the following callbacks:

    subpicture_t->pf_pre_render
    subpicture_t->pf_update_regions

Becarefull that a subpicture_t will livee longer than your decoder instance.
So you will probably also have to override
    subpicture_t->pf_destroy

I think modules/codec/libass.c can be a good example.

 pf_pre_render will be call for each subpicture_t (ordered by display order)
before any call to pf_update_regions . You can then select which picture you
will update (Probably the last one).

 pf_update_regions will then be call for each subpicture_t to (potentially)
update its content.

 For perfomance, you are advised to not create a unique region that covers the
complete video.
 libass.c has code to create a reasonable amounts of region from a lot of small
ones. If it is usefull to you, it can be extracted and made available to everyone.

-- 
fenrir




More information about the vlc-devel mailing list