Декодировать h264 rtsp с помощью ffmpeg и отдельного AVCodecContext

Мне нужна помощь с декодированием rtsp потока видео. Я получаю его от камеры AXIS IP -. Я использую для этого библиотеку 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 или что-то еще, чтобы сделать это правильно?

6
задан mmmaaak 29 June 2012 в 12:11
поделиться