6

ビデオの rtsp ストリームのデコードについて助けが必要です。AXIS IP カメラから取得します。ffmpeg ライブラリを使用します。AVFormatContext->streams[...]->codec; からではなく、AVCodecContext を個別に作成する必要があります。

だから私は 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 を初期化する方法など、正しく行う方法を教えてもらえますか?

4

1 に答える 1

4

さらに作業を行う必要があります。h.264 ストリームをデコードする場合は、デコーダに「sps pps」データを渡す必要があります。このデータは、rtp ストリーム自体で見つけることができます

または SDP の rtsp ネゴシエーションで。このデータをデコーダーに正常にフィードすると、デコードが機能するはずです。

于 2012-07-01T18:50:28.713 に答える