Opencv hardware acceleration not working


i had the following config in a python file which is run in a docker container
os.environ[ “OPENCV_FFMPEG_CAPTURE_OPTIONS”] = “hwaccel;qsv|vsync;0”
os.environ[ “OPENCV_FFMPEG_CAPTURE_OPTIONS”] = “video_codec”

cap = cv2.VideoCapture(“testvideo.mp4”, cv2.CAP_FFMPEG,(cv2.CAP_PROP_HW_ACCELERATION, cv2.VIDEO_ACCELERATION_ANY))

and have rebuilt my opencv to 4.5.4 with cuda being turn on and validate with opencv check if gpu available However when it run the code, the nvdec is consistently showing 0. any advise ? thanks

However, my issue that when i checked the

Hi, I would read the following post to see if it helps

If you don’t have time and you are on windows, then opening your stream with


should enable Nvidia hardware decoding.

The environmental variables you were setting look wrong to me, but I don’t have time to test them to be 100% sure.

Would enable quicksync if it worked which is not what you want.

This as far as I know wouldn’t do anything as you haven’t specified the video codec.