Transparent video and libvlc

This forum is about all development around libVLC.
toverna
New Cone
New Cone
Posts: 3
Joined: 05 Jan 2019 16:08

Transparent video and libvlc

Postby toverna » 05 Jan 2019 18:00

Hello!

I am trying to play transparent video using libvlc and libvlcpp.
Video is encoded from transparent PNG files using ffmpeg. Video format is VP9.
Encoding options are: ffmpeg -framerate 30 -f image2 -i %04d.png -c:v libvpx-vp9 -pix_fmt yuva420p transparent.webm
I checked with Chromium-based browser that the video contains an alpha channel.

Here is some code of playback:

Code: Select all

... media_ = VLC::Media(instance_, "transparent.webm", VLC::Media::FromPath); mp_.setMedia(media_); mp_.setVideoFormat("RGBA", 512, 512, 512 * 4); //setting video format to RGBA. Video size is 512×512; pitch is 4 bytes per pixel mp_.setVideoCallbacks([this](void** pBuffer) -> void* { //std::cout << "Lock callback" << std::endl; *pBuffer = buffer_na_; return NULL; }, [](void*, void*const*) { //std::cout << "Unlock callback" << std::endl; }, [this](void*) { //std::cout << "Display callback" << std::endl; std::ofstream buffer_file; //Let's save buffer to file and see what is inside buffer_file.open("buffer.raw", std::ios::binary | std::ios::out | std::ios::trunc); buffer_file.write(reinterpret_cast<const char*>(buffer_na_), BUF_SIZE); buffer_file.close(); }); mp_.play(); ...
Saved buffer looks like this:

Code: Select all

... 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF ... AF 7A 33 FF AF 7A 33 FF B0 75 33 FF AC 70 2E FF ...
It is looks like RGBA but with Alpha channel set to FF for every pixel.
I can even open this file as raw in image editor and it looks correct but with black background instead of transparent.

The question is how can I get data from libvlc with proper Alpha channel.

application output for --verbose=2: https://pastebin.com/RfJEeXYs

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Transparent video and libvlc

Postby Rémi Denis-Courmont » 05 Jan 2019 21:42

This is not explicitly supported so far. Patch welcome.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

toverna
New Cone
New Cone
Posts: 3
Joined: 05 Jan 2019 16:08

Re: Transparent video and libvlc

Postby toverna » 08 Jan 2019 15:03

I see.

Could you point me where to start?

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Transparent video and libvlc

Postby Rémi Denis-Courmont » 08 Jan 2019 17:19

No, I have not investigated the problem.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

MikOfClassX
Blank Cone
Blank Cone
Posts: 48
Joined: 29 Dec 2018 10:23

Re: Transparent video and libvlc

Postby MikOfClassX » 10 Jan 2019 11:10

Hi, I noticed the same problem with prores4444 MOV files. Good video, No alpha. While libAVCodec renders it correctly.

Additionally, VLC is unable to play the above sample video (gui flasing, auto-resizing during the playout), while it can be played with libVLC (set to RGBA videomode).
Sample video available on request.

MikOfClassX
Blank Cone
Blank Cone
Posts: 48
Joined: 29 Dec 2018 10:23

Re: Transparent video and libvlc

Postby MikOfClassX » 10 Jan 2019 12:40

Further notice toverna: use libvlc_video_set_format(vlcMediaPlayer, "BGRA", videoWidth, videoHeight, videoWidth * 4); (at least on windows)

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: Transparent video and libvlc

Postby unidan » 10 Jan 2019 17:42

Hi, VLC with the GUI flashing and autoresizing is probably a sign that the chroma is unsupported for the given video output, or at least that there is an error in this video output.
You might need to wait the 4.0 release to do something like this.

toverna
New Cone
New Cone
Posts: 3
Joined: 05 Jan 2019 16:08

Re: Transparent video and libvlc

Postby toverna » 13 Jan 2019 15:04

Further notice toverna: use libvlc_video_set_format(vlcMediaPlayer, "BGRA", videoWidth, videoHeight, videoWidth * 4); (at least on windows)
No luck. Output is 00 00 00 FF so alpha channel is still forced to FF.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Transparent video and libvlc

Postby Jean-Baptiste Kempf » 20 Jan 2019 22:32

File a bug. I would use the OpenGL callbacks though.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: Bing [Bot] and 6 guests