首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用ffmpeg和分离的AVCodecContext解码h264 rtsp

用ffmpeg和分离的AVCodecContext解码h264 rtsp
EN

Stack Overflow用户
提问于 2012-06-29 20:11:14
回答 1查看 8.6K关注 0票数 6

我需要一些帮助来解码rtsp视频流。我是从AXIS IP-camera得到的。为此,我使用了ffmpeg库。有必要单独创建AVCodecContext,而不是从AVFormatContext->Streames...->codec;

所以我创建了AVCodec,AVCOdecContext并尝试初始化它们。

代码语言:javascript
复制
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);

然后在应用程序的主循环中,我获取帧数据并尝试解码:

代码语言:javascript
复制
_preallocatedFrame = avcodec_alloc_frame();
avcodec_decode_video2(_context, _preallocatedFrame, &got_picture, &_packet);

在这里,我在控制台中得到了很多消息:

代码语言:javascript
复制
[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或其他正确的方法?

EN

回答 1

Stack Overflow用户

发布于 2012-07-02 02:50:29

您需要执行更多的工作。如果你想解码h.264流,你需要把"sps pps“数据传给解码器。这些数据可以在RTP流本身的see上找到

或者在SDP中的rtsp协商中。在您成功地将此数据提供给解码器之后,解码应该可以工作了。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11261551

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档