Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ffmpeg 在C/C+中使用nvdec(h264_cuvid)解码原始h.264帧数据+;_Ffmpeg_Decoding - Fatal编程技术网

Ffmpeg 在C/C+中使用nvdec(h264_cuvid)解码原始h.264帧数据+;

Ffmpeg 在C/C+中使用nvdec(h264_cuvid)解码原始h.264帧数据+;,ffmpeg,decoding,Ffmpeg,Decoding,每个人 我正在尝试为h.264原始流编写解码器类…但效果不好 流只是由数据大小和编码的原始数据组成。。。 (资源量=1280 x 720) 以下是我写的代码…(例外情况除外…) 第1部分:初始化 AVCodec *m_pDecoder = avcodec_find_decoder_by_name("h264_cuvid"); AVCodecContext *m_pDecoderContext = avcodec_alloc_context3(m_pDecoder); AV

每个人

我正在尝试为h.264原始流编写解码器类…但效果不好

流只是由数据大小和编码的原始数据组成。。。 (资源量=1280 x 720)

以下是我写的代码…(例外情况除外…)


第1部分:初始化

AVCodec *m_pDecoder = avcodec_find_decoder_by_name("h264_cuvid");
AVCodecContext *m_pDecoderContext = avcodec_alloc_context3(m_pDecoder);

AVBufferRef *m_HWContext;
av_hwdevice_ctx_create(&m_HWContext, AV_HWDEVICE_TYPE_CUDA, NULL, NULL, 0);

AVPacket m_pkt_decode;
av_init_packet(&m_pkt_decode);

m_pDecoderContext->pix_fmt = AV_PIX_FMT_CUDA;
m_pDecoderContext->width = 1280;
m_pDecoderContext->height = 720;
avcodec_open2(m_pDecoderContext, m_pDecoder, NULL);

第2部分:填充流数据

m_pkt_decode.data = (uint8_t *)pStreamData;
m_pkt_decode.size = nDataSize;
AVFrame *frame = nullptr;
frame = av_frame_alloc();

avcodec_send_packet(m_pDecoderContext, &m_pkt_decode);
avcodec_receive_frame(m_pDecoderContext, frame);

第3部分:解码流数据

m_pkt_decode.data = (uint8_t *)pStreamData;
m_pkt_decode.size = nDataSize;
AVFrame *frame = nullptr;
frame = av_frame_alloc();

avcodec_send_packet(m_pDecoderContext, &m_pkt_decode);
avcodec_receive_frame(m_pDecoderContext, frame);
然后

avcodec\u receive\u frame
函数始终返回错误…

我的代码中是否缺少任何步骤?

首先,检查错误代码。它会给你一个想法。