I have been trying to find documentation for about an hour and gave up, deciding to recompile 4.5.1 to try to recover my setup…
The so called “improvement” of videoio was a cataclysmic change with poor documentation. ChangeLog · opencv/opencv Wiki · GitHub
I am running opencv and using the ffmpeg backend with cuda acceleration using the python API. I have compiled every version of opencv if contrib this far without any issues.
My question is this: What is the 4.5.2 new equivalent to setting up a video stream as I used to do with this:
Edit: confirmed after re-compiling 4.5.1 release that it is back to working normally. This feature on 4.5.2 is breaking things and/or poorly documented.
Thanks, I was thinking about doing this but first wanted to make sure I didn’t miss anything by posting here first. I read all the docs I could find and tried them all. @cudawarped: I am on linux running python. The syntax you have above is for the C API. Yes I tried this on python and it doesn’t work. These are not the codecs I want to use either as I am trying to use the cuda hevc and h264 codecs. It doesn’t even error out. It seem to establish the connection ok but decodes nothing and doesn’t return any video stream, occasionally posting a scrambled image which I suspect is because it is not using hardware decoding or it is using the wrong codec for the h264 streams. It never returns anything for hevc streams.
should work in 4.5.2, assuming VideoCapture initialized without new property ‘CAP_PROP_HW_ACCELERATION’ introduced in OpenCV 4.5.2.
It works in my quick check with input from local file.
Here is corresponding code handling this property.
Can you please check on local file, not RTSP server URL?
Starting OpenCV 4.5.2, for acceleration types listed in enum VideoAccelerationType you can request specific HW acceleration (ex, VIDEO_ACCELERATION_D3D11 on Windows) or any HW acceleration (VIDEO_ACCELERATION_ANY) via property CAP_PROP_HW_ACCELERATION.
should work if open VideoCapture with property { CAP_PROP_HW_ACCELERATION, cv::VIDEO_ACCELERATION_ANY} and assuming FFMPEG was build with corresponding codecs (CUDA in this example).
Note that CUDA codecs are different to CUVID, for some reason CUVID not exposed in FFMPEG as acceleration type (enum AVHWDeviceType).
Thanks for the quick response but unfortunately I tried most of this as I explained in my first post.
This is equivalent to my default setting from 4.5.1 and no it doesn’t work with an rtsp url. I don’t have any local file to test this on. I will try to create one but I suspect that it won’t work. It does establish connection to the rtsp url fine. It just doesn’t decode properly sending either a black image or a scrambled image.
This is the C API obviously and I posted above the Python equivalent. Again as I said, I tried that too and it doesn’t work
You posted exactly what I said I tried in my original post and it doesn’t work. The result is the same. Connection is established but decoding fails for h264. For HEVC it doesn’t even return anything.