I am currently trying to decode video using cuda. I have the cuda sample called cudaDecodeD3D9
. This sample uses a method called cuvidCreateVideoSource
which takes a file pointer to the source video. Is there any way to get Cuda to load video from memory / socket / stream?
Turns out I can't use cuvidCreateVideoSource
method at all, but instead I can feed each frame of data directly to the cuda video parser by calling cuvidParseVideoData
.
Here's an example of reading one frame from a file and feeding it to the cuda parser. The file was created by me by writing the size of each frame to the file, followed by the frame data. The file can easily be replaced with reading from a socket:
unsigned int size = 0u;
fread( &size, sizeof( unsigned char ), sizeof( unsigned int ), _file );
unsigned char *buf = new unsigned char[size];
fread( buf, sizeof( unsigned char ), size, _file );
CUVIDSOURCEDATAPACKET packet = {};
packet.payload_size = size;
packet.payload = buf;
cuvidParseVideoData( pCudaParser, &packet );
delete [] buf;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With