I try to develop streaming program,I have 4k videos that 5 fps and 20 seconds, I encode frames with cuda encoder successfully, i send encoded data over rtp successfully but when i try to decode that data, i got 0 frame from cuvidParseVideoData
. Should i do something before the cuvidParseVideoData
for example use ffmpeg demuxer ?
RecvDec.cpp
Server* server = new Server(8890 + thread_no);
server->recv_packets();
totBuf* totBuf = server->getTotalBuf();
if (totBuf->perBuf == nullptr) {
std::cout << prompt << "perBuf null!" << std::endl;
nVideoBytes = 1;
continue;
}
pVideo = new uint8_t[totBuf->totSize];
memcpy(pVideo, totBuf->perBuf->perBuf, totBuf->totSize);
nVideoBytes = totBuf->perBuf->size;
int nFrameReturned = 0;
nFrameReturned = dec.Decode(pVideo, nVideoBytes);
NvDecoder.cpp
int NvDecoder::Decode(const uint8_t *pData, int nSize, int nFlags, int64_t nTimestamp)
{
m_nDecodedFrame = 0;
m_nDecodedFrameReturned = 0;
CUVIDSOURCEDATAPACKET packet = { 0 };
packet.payload = pData;
packet.payload_size = nSize;
packet.flags = nFlags | CUVID_PKT_TIMESTAMP;
packet.timestamp = nTimestamp;
if (!pData || nSize == 0) {
packet.flags |= CUVID_PKT_ENDOFSTREAM;
}
CUresult cuStatus = cuvidParseVideoData(m_hParser, &packet);
if (cuStatus != CUDA_SUCCESS) {
std::cout<<"Cuda Status : "<<cuStatus<<std::endl;
}
m_cuvidStream = 0;
return m_nDecodedFrame;
}
My data always starts with 0x00 0x00 0x00 0x01. This is start frame tag. cuvidParseVideoData always returns 0 and m_nDecodedFrame is 0.