-
Notifications
You must be signed in to change notification settings - Fork 5.8k
cv::cudacodec::createVideoReader Not Working as expected #3359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like an unusual error code. Are you able to run any other OpenCV cuda functions? If so can you
Which GPU and driver version are you using? |
I'm sorry to reply to your message so late.
In fact this error code is indeterminate, I got several different error codes in several attempts, such as:
and
I'm sorry I can't verify this at the moment, maybe you can provide an example to help me verify this? Since I'm building opencv on Ubuntu, I didn't find an example in the examples that looked right to run, and when I tried to run video_writer.cpp I got the following error:
Yes, I got the same error.
I also suspected that it might be a problem with my device, so I tried it on another device with a different GPU, but encountered the same problem. Device 1: Product Name: NVIDIA GeForce RTX 3080
# nvidia-smi
NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7
# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0 Device 2: Product Name: NVIDIA GeForce RTX 2060
# nvidia-smi
NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7
# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:18:20_PST_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0 And this is the cmake command I used when building opencv. Maybe there is something wrong with it? mkdir -p build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=../../opencv \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.6.0/modules \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D WITH_NVCUVID=ON \
-D WITH_CUBLAS=ON \
-D WITH_CUFFT=ON \
-D WITH_FFMPEG=ON \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
..
make -j$(nproc) && make install |
I just noticed that you are using the sample code. As far as I am aware that is broken so that could be your issue. Try replacing
with
here. The sample should display the video decoded on the cpu then the gpu, does the cpu version display correctly? |
When the program runs to |
Good point. Have you built the tests if so does opencv_test_cudaarithm work? If you haven't built the tests then you need to confirm that CUDA is working, a different error each time implies it could be returning an error from a previous CUDA call. If something simple like the below
works then CUDA is working and the next step would be to download and build the Nvidia samples and see if they work. |
I modified and ran this example
and got the correct output.
I tried to build Nvidia samples and ran ./AppDec -i big_buck_bunny.mp4 -o ouput.mp4 -resize 800x600 I got the following output:
I can't view output.mp4, but I think it's working properly |
So I should try to lower the opencv version? |
I wouldn't think that would make a difference, it looks like an error generated by the driver api but I can't recreate on my side. That said I'm using wsl with the same CUDA runtime and driver version (11.7) but I wouldn't expect that to be the issue.
The encoding hasn't worked for a few years and if you want to push rtsp streams you probably want to use a different library to OpenCV. Can you run bin/opencv_test_cudaarithm to see if you get the same errors as #3361? |
Of course. I ran all the test programs starting with opencv_test_cudaarithm
opencv_test_cudacodec
opencv_test_cudafeatures2d
opencv_test_cudaimgproc
opencv_test_cudalegacy
opencv_test_cudaobjdetect
opencv_test_cudaoptflow
opencv_test_cudastereo
opencv_test_cudawarping
|
I see in the build information that FFMPEG and GStreamer are available in Video I/O, can I use them through opencv? Are there any examples or any other references about this? Thank you for your help |
Just to confirm:
Usage questions should be placed on the OpenCV forum. Video writing in OpenCV is performed usign the |
Yes, I used Video_Codec_SDK_11.1.5 when I built opencv
output
I copied this library from Video_Codec_SDK_11.1.5
I will be there for help, thank you |
Do you have both cuda toolkit 11.3 and 11.6 on your machine? I'm wondering if OpenCV is trying to use the stub library at runtime, what is the output from
|
No, I have two machine, one with cuda toolkit 11.3 and the other with 11.6
|
What happens if you remove the stub library If not can you remove the stub library from the installation directory
to cmake to see if this fixes your issue. |
I remove the stub library libnvcuvid.so and rebuild, now
|
Can you try building and see if the error remains and if
has changed. |
Yes, I'm in the process of building it, it may take a while |
I rebuild, now
But when I run After that I tried to run video_reader.cpp without any more errors and everything seems to be fine. |
Is it the same error, or just an error related to OPENCV_TEST_DATA_PATH not being set?
Thats great, I thought it was a long shot but it seems to have paid off! |
It's the exact same error, but I'm not sure if it's caused by my incorrect operation and I think I should rebuild it once to verify it. |
The previous multiple builds generated files scattered in multiple similarly named folders, so I deleted them all and rebuilt. |
So the video_reader sample is still working for you? What is your output from
It is it similar to
If so you need to clone the extra repo and add
or similar before running the test. |
Yes, it still works.
It is similar to the one you mentioned.
I don't quite understand how this is to be done and I didn't notice where the extra repo is. Also, thanks to your help, isn't the codec already working as expected? |
Yes, I just wanted to cofirm that the errors you are seeing from |
yes, clone the extra repo and add |
Great thanks for checking that, I guess this issue can be closed then? |
Hello there, could you explain how you built your OpenCV as I have faced a same issue? 2- Making a soft link of libnvcuvid.so in /usr/lib which is linked to /usr/lib/x86_64-linux-gnu/libnvcuvid.so. And then, building opencv with this command: In the both cases, opencv_test_cudacodec is not linked to libnvcuvid. I.e, Thx again. |
If you have the Nvidia driver installed and a GPU which supports the Nvidia Video Coding SDK then I would expect |
THX for the reply. The weird thing is that, as you said, CMake should pick up /usr/lib/x86_64-linux-gnu/ as search directory and it does. inside CMakeVars.txt. There are other shared libraries picked from /usr/lib/x86_64-linux-gnu that are linked in CMakeVars.txt. Then I check |
You need to remove the stub library |
Hi I am unable to run video reader GPU Sample using cv::cudacodec::createVideoReader . My configuration is as follows
Ubuntu 20.04 CUDA 11.6. Open CV build from Source.
opencv build:
This is the code I run:
I tried rtsp and video files and got the same error:
Thanks in advance!
The text was updated successfully, but these errors were encountered: