Page 1 of 1

Transparent video and libvlc

Posted: 05 Jan 2019 18:00
by toverna
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

Re: Transparent video and libvlc

Posted: 05 Jan 2019 21:42
by Rémi Denis-Courmont
This is not explicitly supported so far. Patch welcome.

Re: Transparent video and libvlc

Posted: 08 Jan 2019 15:03
by toverna
I see.

Could you point me where to start?

Re: Transparent video and libvlc

Posted: 08 Jan 2019 17:19
by Rémi Denis-Courmont
No, I have not investigated the problem.

Re: Transparent video and libvlc

Posted: 10 Jan 2019 11:10
by MikOfClassX
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.

Re: Transparent video and libvlc

Posted: 10 Jan 2019 12:40
by MikOfClassX
Further notice toverna: use libvlc_video_set_format(vlcMediaPlayer, "BGRA", videoWidth, videoHeight, videoWidth * 4); (at least on windows)

Re: Transparent video and libvlc

Posted: 10 Jan 2019 17:42
by unidan
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.

Re: Transparent video and libvlc

Posted: 13 Jan 2019 15:04
by toverna
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.

Re: Transparent video and libvlc

Posted: 20 Jan 2019 22:32
by Jean-Baptiste Kempf
File a bug. I would use the OpenGL callbacks though.