Skip to content
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

[CUDA] opencv cannot decode rtsp video stream #1037

Open
hexianbin1994 opened this issue Oct 11, 2024 · 1 comment
Open

[CUDA] opencv cannot decode rtsp video stream #1037

hexianbin1994 opened this issue Oct 11, 2024 · 1 comment

Comments

@hexianbin1994
Copy link

Expected behaviour

opencv-cuda decode rstp video stream success

Actual behaviour

opencv-cuda can decode mp4 video file, but cannot decode rtsp video stream, with the fault is 【Segmentation fault (core dumped)】

Steps to reproduce

I create docker container and compile opencv-cuda:

docker run -it --network host --gpus all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video  nvidia/cuda:12.0.0-cudnn8-devel-ubuntu20.04 bash
## compile ffmpeg
## compile opencv-python
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.8.0
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout 4.8.0

compile result is :
image

NVIDIA CUDA is YES and contain NVCUVID

main code

1 - decode mp4 video file
import cv2

s = "test2.mp4"
cap = cv2.cudacodec.createVideoReader(s)
frame_id = 0
while 1:
    _, img_gpu = cap.nextFrame()
    if frame_id == 100:
        img_cpu = img_gpu.download()
        print(img_cpu.shape)
        break

    frame_id += 1

the result is
image

2 - decode rtsp video stream
import cv2

s = "rtsp://128.8.84.224:8554/rtsp/test"
cap = cv2.cudacodec.VideoReader(s)
frame_id = 0
while 1:
    _, img_gpu = cap.nextFrame()
    if frame_id == 100:
        img_cpu = img_gpu.download()
        print(img_cpu.shape)
        break

    frame_id += 1

the result is
image
error is in 【_, img_gpu = cap.nextFrame()

@hexianbin1994
Copy link
Author

cv2.getBuildInformation() is
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant