[英]Decode h264 rtsp with ffmpeg and separated AVCodecContext
我需要一些有关decodein rtsp视频流的帮助。 我从AXIS IP-camera那里得到它。 我使用ffmpeg库。 有必要单独创建AVCodecContext,而不是AVFormatContext-> streams [...] - > codec;
所以我创建AVCodec,AVCOdecContext并尝试初始化它们。
AVCodec *codec=avcodec_find_decoder(codec_id);
if(!codec)
{
qDebug()<<"FFMPEG failed to create codec"<<codec_id;
return false; //-->
}
AVCodecContext *context=avcodec_alloc_context3(codec);
if(!context)
{
qDebug()<<"FFMPEG failed to allocate codec context";
return false; //-->
}
avcodec_open2(context, codec, NULL);
然后在应用程序的主循环中,我获取帧数据并尝试解码:
_preallocatedFrame = avcodec_alloc_frame();
avcodec_decode_video2(_context, _preallocatedFrame, &got_picture, &_packet);
在这里,我在控制台中收到了很多消息:
[h264 @ 1f177720] decode_slice_header error
[h264 @ 1f177720] no frame!
[h264 @ 1f177720] non-existing PPS 0 referenced
[h264 @ 1f177720] decode_slice_header error
[h264 @ 1f177720] no frame!
[h264 @ 1f177720] non-existing PPS 0 referenced
[h264 @ 1f177720] decode_slice_header error
[h264 @ 1f177720] no frame!
[h264 @ 1f177720] non-existing PPS 0 referenced
[h264 @ 1f177720] decode_slice_header error
[h264 @ 1f177720] no frame!
[h264 @ 1f177720] non-existing PPS 0 referenced
[h264 @ 1f177720] decode_slice_header error
[h264 @ 1f177720] no frame!
[h264 @ 1f177720] non-existing PPS 0 referenced
[h264 @ 1f177720] decode_slice_header error
[h264 @ 1f177720] no frame!
你能告诉我一些事情,如何初始化AVCodecContext或其他什么来正确吗?
你需要做更多的工作。 如果你想解码h.264流你需要传递解码器“sps pps”数据。 这些数据可以在RTP流本身中找到看
或者在SDP的谈判中。 在您使用此数据成功提供解码器后,解码应该可行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.