我从 IP 摄像机获取 H.264 图像,并希望保存编码图像(不解码)。为此,我正在使用ffmpeg (libavformat/output-example.c)中的 output-example.c。为了保存原始 H.264 图像,我执行以下操作:
AVPacket pkt;
av_init_packet(&pkt);
if (c->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
if(c->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index= st->index;
pkt.data= (uint8_t *)ulAddr;//video_outbuf;
pkt.size= out_size;
save_image(pkt.data, out_size);
其中ulAddr是指向图像的地址指针,out_size 是图像大小。我不想将图像保存到媒体视频文件,而是保存单个图像。save_image 函数仅使用基本的fopen和fwrite函数来保存图像。如果我解码帧然后保存,一切正常。但我在保存编码帧时遇到问题。编码的帧以非常小的尺寸保存,然后无法解码。有什么问题吗?我将非常感谢这方面的任何帮助。