2012-06-29 20 views
6

ビデオのdecodein rtspストリームで助けが必要です。 AXIS IPカメラから入手できます。私はそれのためのffmpegライブラリを使用します。 AVFormatContext-> streams [...] - > codecではなく、AVCodecContextを個別に作成する必要があります。デコードh264 rtspでffmpegと分離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); 

次に、アプリケーションのメインループでは、Iフレームデータを取得し、復号化するために試してみてください。

_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

もう少し作業を行う必要があります。 h.264ストリームをデコードする場合は、デコーダに "sps pps"データを渡す必要があります。 このデータは、rtpストリーム自体のsee

またはSDPのrtspネゴシエーションにあります。 このデータをデコーダに正しく供給した後、デコードが機能するはずです。

+0

ただし、違いはありません。私はAVFormatContext->ストリーム[...] - >コーデックからAVCodecContextを取得し、絶対にsimmilar操作を行うと、エラーなしでデコードします。 Btそれは私が分離codeccontextを使用する必要があります(それは、私はフォーマットのコンテキストを傾けることができない場合、ディスクから保存されたアーカイブからデータを取得した後にデコードされる可能性があります) – mmmaaak

+0

2つのコンテキストオブジェクトを比較しようとしましたか? – Horonchik

+0

はい、20種類以上の違いがあります。私はAVCOdecContext-> priv_dataと他のポインタフィールドを除いて、私のコンテキストにすべての異なるフィールドを設定しようとしました - それは動作しません。 – mmmaaak

関連する問題