Choose FFmpec decoder

Is there a way to choose what codec use when creating VideoCapture(…, cv::CAP_FFMPEG)?
I want to use libvpx-vp9 and be sure my video load correctly.

so you have a video file. the video file has a specific container format and video encoding.

ffmpeg will decide what codec to use for decoding that video.

usually, there is exactly one codec that can decode the video.

why do you want to control this?

So there is some problem either with opencv or ffmpeg.
I created a .webm video with alpha channel, but it load without alpha channel.
OpenCV gives always 3 channel instead of 4 (bgr+a).
But I’m reading online OpenCV doesn’t manage alpha channel at all


OpenCV doesn’t understand the special meaning of alpha channels (in calculations) but it can read and write them… at least as images. I haven’t personally done any specific color space stuff with VideoCapture/VideoWriter.

Already tried it without any success.

capture.set(cv::CAP_PROP_CONVERT_RGB, false);

Indeed I don’t have any problem loading a .png file with transparency, thought it was so easy for video too. How do other tools show properly my test video? (Obs, some HTML5 webapp, etc)

As stated in your other post

the OpenCV FFMpeg backend does not support an alpha channel

Additonaly CAP_PROP_CONVERT_RGB doesn’t have any effect in FFMpeg and if it did I assume it would be to convert from BGR to RGB but I may be wrong.

Out of interest why do you need an alpha channel?

1 Like

Since I want to display some video with transparency on my project as an overlay (they are YUVA format). Since this videos are made with an alpha channel on it (YUVA format) I want to display them without doing any preprocess like masking pixel etc.
But I can’t. So basically I’ve 3 solutions:

  1. Create a chroma key feature with opencv and doing so I need to resync video+audio;
  2. Build custom opencv with forcing AV_FMT with alpha channel in videoio;
  3. Use FFmpeg directly on my project and get rid of opencv.