Issue to decode Raw video YUY2 / YUYV 422 using CUDA , the "NvDecoder : cuvidCreateVideoParser" fail with "CUDA_ERROR_INVALID_SOURCE"

Hello there,

I am playing for some time with HW accelerated decoding of the video stream and I just can’t make CUDA to decode the videofile in YUYV 422 format (in may case file is a raw stream saved using my SONY Eye camera with a bit higher FPS: 187fps, 320x240).

I did try this on various CUDA versions(nvcuvid / nvdecode api) , nVidia GeForce drivers , VideocodecSDKs over a few Linux distributions (Ubuntu, Sparky), but always ended up with the same error: “CUDA_ERROR_INVALID_SOURCE”

I did try to compile the samples attached to the Video codec SDKs, or examples attached to the OpenCV, and they were working fine; unless I used the raw video format YUYV422. With this whether it is the cv::cuda::VideoReader(string file) or NVDEC_API_CALL(cuvidCreateVideoParser(&m_hParser, &videoParserParameters)) they failing as stated above, and can be traced back to API returning the “CUDA_ERROR_INVALID_SOURCE” error.

To reproduce the issue any video file shall be converted to YUYV using ffmpeg:

ffmpeg -i “input_file” -c:v rawvideo -pix_fmt yuyv422 -s:v 320x240 -r 187 “output_file.avi”

for example

[i]ffmpeg -i ~/Videos/test_3.mkv -c:v rawvideo -pix_fmt yuyv422 -s:v 320x240 -r 187 ~/Videos/output.avi
ffmpeg version N-94986-g8f13a557ca Copyright © 2000-2019 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --enable-pic --enable-shared
libavutil 56. 35.100 / 56. 35.100
libavcodec 58. 58.101 / 58. 58.101
libavformat 58. 32.104 / 58. 32.104
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 58.102 / 7. 58.102
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
Input #0, matroska,webm, from ‘/home/matus/Videos/test_3.mkv’:
title : test_original
creation_time : 2019-08-30T14:49:17.000000Z
ENCODER : Lavf58.20.100
Duration: 00:00:50.01, start: 0.000000, bitrate: 116 kb/s
Stream #0:0: Video: h264 (Main), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 320x240 [SAR 1:1 DAR 4:3], 187 fps, 187 tbr, 1k tbn, 374 tbc (default)
DURATION : 00:00:50,005000000
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, avi, to ‘/home/matus/Videos/output.avi’:
INAM : test_original
ISFT : Lavf58.32.104
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 229785 kb/s, 187 fps, 187 tbn, 187 tbc (default)
DURATION : 00:00:50,005000000
encoder : Lavc58.58.101 rawvideo


then the produced “output_file.avi” video file can be used as a source in the OpenCV::cuda::VideoReader example, or VideoCodecSDK AppDec sample:

/AppDec -i ~/Videos/output.avi
GPU in use: GeForce GTX 670
Decode with demuxing.
[INFO ][21:33:12] Media format: AVI (Audio Video Interleaved) (avi)
[WARN ][21:33:12] ChromaFormat not recognized. Assuming 420
NvDecoder : cuvidCreateVideoParser(&m_hParser, &videoParserParameters) returned error 300 at …/…/NvCodec/NvDecoder/NvDecoder.cpp:600

This can be traced back to the above mentioned failing NVDEC_API_CALL(cuvidCreateVideoParser(&m_hParser, &videoParserParameters)) with the “CUDA_ERROR_INVALID_SOURCE” error.

In case of the OpenCV VideoReader example the error would be: OpenCV Error: Unsupported format or combination of formats (Unsupported video source).
But again if you would debug the code you will find out the real reason is the callback error reply: “CUDA_ERROR_INVALID_SOURCE”.

I would like to ask if anybody was/is successful with decoding this raw YUYV 422 video fort using the CUDA under Linux.
I have feeling this is probably a bug in the nvidia graphic drivers and/or cuda libs…

Thanks for any feedback or help here.

I think the issue I am facing is related to the fact which I just found out :

According the note on this page:

** 4:2:2 is not natively supported on HW

Can anybody pls confirm ? I was decoding the video on the GeForce GTX 670 GPU.


Hi matus.kabac,
You are correct, 4:2:2 is not supported on NVIDIA video codec hardware.