Page 1 of 1

Does Love 2D support video with an alpha channel for video overlay?

Posted: Thu Sep 12, 2019 3:00 am
by DwayneDev
I made a video with alpha transparency to overlay it on another video. I wanted to do this to make layers animated backgrounds through video.

Code: Select all

--I've tried it and the transparency of video 2 isn't there
love.graphics.draw(video,425,0)
love.graphics.draw(video2,425,0)

I know this might be weird and ineficcient, I'm already thinking of easier solutions I'm just curious at this point if it's possible in love 2D.

here's what I'm trying to overlay.
transparent.gif
transparent.gif (2.36 MiB) Viewed 5396 times

Re: Does Love 2D support video with an alpha channel for video overlay?

Posted: Thu Sep 12, 2019 10:39 am
by Sasha264
Hello! :awesome:
I made a video with alpha transparency...
Wow!! How did you do that?
There are surprisingly few video file formats that can contain alpha channel.
Love2d supports only OGV video format https://love2d.org/wiki/love.graphics.newVideo
Just googled it for a bit and couldn't find something about alpha channel inside Ogg Theora.
Are you sure your file contains alpha channel? Can you share it here (not a .gif but .ogv)? Can you see this transparence in some player software?

A few month ago I was looking for some way to store animation with alpha-transparency and found only apng format for me. A good question about supporting it in Love2d :nyu:

And if the is no such options, then I suggest 2 separate videos: one with color + one with alpha along with simple shader will be simplest solution for your task.

Re: Does Love 2D support video with an alpha channel for video overlay?

Posted: Thu Sep 12, 2019 2:03 pm
by zorg
Alternatively, if you can sacrifice some shades of black, for instance, you could just use that one video (encoded as an ogv without an alpha channel i mean) and use a simple shader where you discard / draw 100% transparent where the video pixels are below a combined rgb threshold (i'd say 0.0,0.0,0.0 but depending on video quality, that may be too steep of a threshold, experiment)

Re: Does Love 2D support video with an alpha channel for video overlay?

Posted: Thu Sep 12, 2019 4:15 pm
by DwayneDev
OKAY. So I was using blender to export video with an alpha channel. after some testing it turns out .ogv doesn't have an alpha despite blender suggesting otherwise. Iused the following settings to export the ogv and the alpha did not work.
mistake.JPG
mistake.JPG (17.55 KiB) Viewed 5342 times
OOF2.JPG
OOF2.JPG (30.93 KiB) Viewed 5342 times
.MPG4 does support aplha channel but does not work with Love 2D of course.
thisWorkedActually.JPG
thisWorkedActually.JPG (17.85 KiB) Viewed 5342 times

Re: Does Love 2D support video with an alpha channel for video overlay?

Posted: Thu Sep 12, 2019 4:15 pm
by DwayneDev
oof.JPG
oof.JPG (31.37 KiB) Viewed 5342 times

Re: Does Love 2D support video with an alpha channel for video overlay?

Posted: Thu Sep 12, 2019 4:28 pm
by DwayneDev
Thanks for the suggestions, I'll experiment with those concepts.

Re: Does Love 2D support video with an alpha channel for video overlay?

Posted: Sun Sep 15, 2019 10:00 am
by Sasha264
Thanks for sharing blender settings!
Transparent videos is a truly mysterious mysteries in our world :3