Discussion:
[vlc] Movie alphamask with another movie
Alex Suter
2008-01-13 23:38:17 UTC
Permalink
Greetings all,

I thought I'd try one more time before going off to write my own.

Has anyone tried creating a filter that uses one movie as an alphamask
for another? It seems related to the logo code that's in there, or perhaps
the code to display multiple streams together.

Any advice on how to code it would be most welcome.

Thanks,
Alex
Antoine Cellerier
2008-01-18 19:50:39 UTC
Permalink
Hello,
Post by Alex Suter
I thought I'd try one more time before going off to write my own.
Has anyone tried creating a filter that uses one movie as an alphamask
for another? It seems related to the logo code that's in there, or perhaps
the code to display multiple streams together.
Any advice on how to code it would be most welcome.
That sounds exactly like the mosaic plugin. (see
http://wiki.videolan.org/Mosaic )

Mosaic input items can use specific filters including one called
"alphamask". It only supports png images as input for the time being but
it wouldn't be too hard to change that to using another movie stream.

Could you please be a bit more precise with what you want to acheive so
I can be a bit more specific? (Documentation on all that mosaic stuff is
kind of sparse ... it's mainly in the svn commit messages)

Regards,
--
Antoine Cellerier
dionoea
Alex Suter
2008-01-18 21:14:55 UTC
Permalink
Post by Antoine Cellerier
That sounds exactly like the mosaic plugin. (see
http://wiki.videolan.org/Mosaic )
Mosaic input items can use specific filters including one called
"alphamask". It only supports png images as input for the time being but
it wouldn't be too hard to change that to using another movie stream.
Could you please be a bit more precise with what you want to acheive so
I can be a bit more specific? (Documentation on all that mosaic stuff is
kind of sparse ... it's mainly in the svn commit messages)
Hi Antoine,

Thanks for the response! I was looking at the mosaic code, and was
going to use it as an example, but haven't yet traced out all of the
code paths to figure out exactly how to do it.

What I'm trying to do is mask a movie stream (say, coming from a
DVD) with another movie stream (coming from a mp4 or something
similar on disk). The on-disk mp4 would be a very simple black and
white silhouette. Anything black on the mp4 would be black in the
final image. Anything white on the mp4 would show the DVD stream
in the final image.

I got the alphamask plugin working great, but as you say, it currently
only takes a static png file. I'd love to be able to use a dynamic movie
based mask in its place.

Thanks again for any pointers. It's fun code to pore over.

-- Alex
Antoine Cellerier
2008-01-19 12:31:11 UTC
Permalink
Alex,
Post by Alex Suter
What I'm trying to do is mask a movie stream (say, coming from a
DVD) with another movie stream (coming from a mp4 or something
similar on disk). The on-disk mp4 would be a very simple black and
white silhouette. Anything black on the mp4 would be black in the
final image. Anything white on the mp4 would show the DVD stream
in the final image.
I got the alphamask plugin working great, but as you say, it currently
only takes a static png file. I'd love to be able to use a dynamic movie
based mask in its place.
Thanks again for any pointers. It's fun code to pore over.
What you need to do is use a picture from a mosaic-bridge output instead
of p_sys->p_mask in modules/video_filter/alphamask.c . The question
is: how do I get this picture? Well it's pretty simple. The mosaic
framework uses a bridge object to forward pictures from one of the
decoder items to the mosaic filter itself. That bridge structure is
defined in modules/video_filter/mosaic.h . To get the bridge, you just
need to call GetBridge( some vlc object ). Once you have the bridge, you
have access to the list of all the available mosaic elementary streams.
Each of those has a string id (psz_id in the bridged_es_t structure).
This id makes it possible to identify the source (at runtime, you define
the id in the mosaic-bridge stream output module using the id=something
option). Looping through the pp_es element of the bridge_t object, you
can thus find the appropriate elementary stream to use as a mask. The
last step is getting the appropriate picture from that bridge elementary
stream structure. The p_picture item is in fact a chained list of
pictures. You'll need to add code like in the while loop line 540 in
modules/video_filter/mosaic.c to handle that list properly and get the
appropriate picture_t pointer. Then you're done I guess. To integrate
that properly with the current alphamask filter you could either: 1/ add
another option to enable using input from the mosaic bridge or 2/ use
the mosaic bridge when the mask is set to something like "mosaic:<id>".

I hope that this big text block will help you with the code. Feel free
to ask if you have any other questions ... and please post the patch
once you're done (and a demo video)!

Regards (and happy hacking),
--
Antoine Cellerier
dionoea
Loading...