B4J Question How can I play a video(mov) with alpha channel?

bjfhs

Active Member
Licensed User
I play a video ,and then I want play another video(mov) with alpha channel on it,but i can not.

Can you give me some advise? or other tool?
 

JordiCP

Expert
Licensed User
Longtime User
What are you using to play the first video?

If you only need to overlay a second video assigning an alpha channel, and there is no audio in this second one, you can try jOpenCV, assuming that the format is compatible with what its built In ffmpeg decoder can manage.
 
Upvote 0

bjfhs

Active Member
Licensed User
What are you using to play the first video?

If you only need to overlay a second video assigning an alpha channel, and there is no audio in this second one, you can try jOpenCV, assuming that the format is compatible with what its built In ffmpeg decoder can manage.
Thank you for your reply,but I can not download the jOpenCV libary,can you send it to me?
Email:[email protected]
 
Upvote 0

bjfhs

Active Member
Licensed User
Thank JordiCP very much,I have test it,it can play the video very well, but the transparent part is replaced by black, I want the result like the next picture,can you help me?
1619399609697.png
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
I don't know if videos can have alpha layers by themselves.
I guess that what you want is to replace the black part by a transparent channel.

Post the video here or send it by mail and I'll try to help with it :)
 
Upvote 0

bjfhs

Active Member
Licensed User
Now,I'll send the video to you by mail.
The second video have a alpha channel(incorrect show black),In fact ,the black part have nothing, when I put it on the background video in AE,it transparent ,and can show the background video.
 
Last edited:
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
To my surprise, I realized that the ffmpeg specific build for OpenCV (at least in 3.4.4, perhaps it changed later) purposely outputs only 3-channels frames on VideoCapture, even if the source is 4-channels. That's not an ffmpeg limitation, but a build decision from the OpenCV guys.

I can see 2 options here:

1. If the source video images (as in the case you sent me) has no zones of black solid color, use this as an inverse mask, and overlay it on top of the other.

(Using background and foreground videos you sent me, result is)



2. For a more general use-case (i.e., the foreground video can have black solid colors), I'd use command-line ffmpeg to compose them. Perhaps @moster67 could help in this case.
 
Upvote 0

bjfhs

Active Member
Licensed User
To my surprise, I realized that the ffmpeg specific build for OpenCV (at least in 3.4.4, perhaps it changed later) purposely outputs only 3-channels frames on VideoCapture, even if the source is 4-channels. That's not an ffmpeg limitation, but a build decision from the OpenCV guys.

I can see 2 options here:

1. If the source video images (as in the case you sent me) has no zones of black solid color, use this as an inverse mask, and overlay it on top of the other.

(Using background and foreground videos you sent me, result is)



2. For a more general use-case (i.e., the foreground video can have black solid colors), I'd use command-line ffmpeg to compose them. Perhaps @moster67 could help in this case.
@JordiCP ,Thank you for your help!
@moster67,Can you give me some advise?I use it in a PC game,the second video(with alpha channel) will play when mousedown.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Upvote 0

bjfhs

Active Member
Licensed User
HI, saw this post only now.
I am not an expert and I have never tried what you are doing but you could perhaps use ffmpeg.

You can use ffmpeg using jShell. There should be forum posts showing how to do that.

By googling, I found this interesting post which might be what you are looking for:
https://stackoverflow.com/questions...ideo-on-top-of-another-using-an-alpha-channel

Good luck
Thank you for your reply,because in the game I need play the video anytime and anywhere,so jShell can not do it.
 
Upvote 0
Top