Hi, everyone, I’m using cv2.cudacodec.createVideoReader(r’video.mp4’) function, I have Unicode characters in my video path, like Chinese characters, and it’ll encounter this error
video_gpu = cv2.cudacodec.createVideoReader(video_path, params=params)
cv2.error: OpenCV(4.7.0) D:\opencv_build\opencv_contrib-4.7.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'
cv2.VideoCapture works fine with Unicode path, but I need to accelerate video encoding and decoding. I just found some solutions to deal with reading and writing images with Unicode characters in the path, but didn’t find anything about this function, are there any solutions for this problem?
sure, video_path is r’D:\test\2231221\CU测试汉字_K988+11\K0+000.mp4’, I know there’s ‘+’ there, but I tested, it’s Chinese characters which really caused the problem. and thank you very much!
known issue with OpenCV in general. it can’t handle unicode in file names at runtime. this usually shows up with non-CUDA imread() uses but apparently it also affects everything else in OpenCV.
I don’t know when they’ll figure out a way to fix this, or if they have already.
You could try the v5 branch of OpenCV. it’s not released yet. maybe it contains a fix.
I am not familiar with using unicode however in python I can open a file with the path you supplied with both cv::VideoCapture and cudacodec::VideoReader in OpenCV 4.8.0. e.g.
cap = cv2.VideoCapture(‘d:/media/CU测试汉字_K988+11/K0+000.265’)
and
reader = cv2.cudacodec.createVideoReader(‘d:/media/CU测试汉字_K988+11/K0+000.265’)
As cudacodec::VideoReader uses cv::VideoCapture to open video files I am suprised that for you one worked and the other did not.
Maybe there is an error somewhere else, can you supply the exact code you are using and I will try it on my setup?
issue may potentially be modulated by windows system settings relating to unicode. I think they’re introducing more and more inherent unicode support into windows that wasn’t there before. this may also affect old APIs, which OpenCV is likely to use.
Did you try a later version of OpenCV? Can you share the output you are getting in the console, info/warnings/errors etc.
I am not sure what to suggest as I am not familiar with unicode support on Windows, maybe @berak, @laurent.berger or @crackwitz can offer some assistance?
sorry I didn’t try later verison of opencv, I tried build opencv 4.8 with cuda, but encounter error LNK2001 unresolved external symbol error, and didn’t find a solution yet
If you give me more details on the error I might be able to help. Did you update both repos to 4.8.0? If you are building again I would checkout the 4.9.0. tag from both repos.