Not able to read Video from Capture Card with GPU (Unsupported Format) while Reading with CPU works fine

Thanks a lot, that fixed the problem with the cv::VideoCapture(). I can now open the Camera like this:

cv::VideoCapture cam("video=Microsoft® LifeCam HD-3000", cv::CAP_FFMPEG);
// cam.set(cv::CAP_PROP_FORMAT, -1); // If activated camera Window is about 1 px high and as wide as my screen

I tested also with cv::cudacodec::VideoReader() and there I get:

OpenCV(4.6.0) C:\...\private.cuda.hpp:112: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'

I also looked up the post from @alex to this problem:

I did that, but it still gives me the error message.
Should I open up a new thread for this problem or could this be related?

Did you build OpenCV afterwards?

You also need to set -DWITH_NVCUVID=ON and check for the below in your CMake output


Thank you :slight_smile:
With both of that done, I have now NCUVID shown as above.

Now I face two more errors, seems like OpenCV is actively trying to stop me from using ths functionallity :sweat_smile: :

OpenCV(4.6.0) C:\...\OpenCV\opencv_contrib-4.6.0\modules\cudacodec\src\cuvid_video_source.cpp:66: error: (-217:Gpu API call) CUDA_ERROR_FILE_NOT_FOUND [Code = 301] in function 'cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource'

[dshow @ 000001e43cc99b00] Malformed dshow input string.

My code:

const std::string fname("Microsoft® LifeCam HD-3000");
cv::Ptr<cv::cudacodec::VideoReader> d_reader = cv::cudacodec::createVideoReader(fname);

fname is set to the exact name of my camera from the Windows Device Manager. I tried it without the “®”, but this seems not to be the problem.

Try exactly the same string you used for VideoCapture

const std::string fname("video=Microsoft® LifeCam HD-3000");

When doing that, I get another error from cuvid_video_source.cpp:66:

(-217:Gpu API call) CUDA_ERROR_FILE_NOT_FOUND [Code = 301] in function 'cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource'

That error implies that VideoCapture inside of VideoReader failed to open the stream, however I can’t think of a reason why because the below worked for you

Is there any additional error messages?
Have you tried stepping through the code to see what is happening?
Do you get any additional info if you set the following environmental variables?

I tried the Debug Log Level.
There is one, looks like the problem to me, what do you think?:

[ WARN:0@0.622] global C:\...\OpenCV\opencv_contrib-4.6.0\modules\cudacodec\src\ffmpeg_video_source.cpp (95) FourccToCodec Unknown codec FOURCC: 0x32595559 (YUY2)

That’s strange, if you reach that warning VideoCapture has opened the web cam and you should not have fallen through to try CuvidVideoSource and see the previous error.

If I were you I would step through the code and see what is throwing an exception inside