FFmpeg non-existing PPS 0 referenced問題描述

查看所有的函數引用
1)static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, const H2645NAL *nal)

    if (!h->ps.pps_list[sl->pps_id]) {
        av_log(h->avctx, AV_LOG_ERROR,
               "non-existing PPS %u referenced\n",
               sl->pps_id);
        return AVERROR_INVALIDDATA;
    }
2)static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t * const buf, int buf_size)

            if (!p->ps.pps_list[pps_id]) {
                av_log(avctx, AV_LOG_ERROR,
                       "non-existing PPS %u referenced\n", pps_id);
                goto fail;
            }


avcodec_send_packet函數返回-1094995529錯誤,根據FFmpeg的錯誤信息,得知爲AVERROR_INVALIDDATA,猜測是第一種情況
在調用h264_slice_header_parse函數的時候,出現了錯誤,無法定位PPS

函數的調用邏輯
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
    int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal)
        static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, const H2645NAL *nal)

結構體的獲取
H264Context* pH264Context = AVCodecContext->priv_data
H264SliceContext *sl = H264Context->slice_ctx + H264Context->nb_slice_ctx_queued;



網上提供了一些方案,暫時沒有理解
1)1.確保第一個解碼的幀爲I幀,確保I幀中有sps和pps信息
2)如果直接從rtsp流中一幀一幀的取,再一幀一幀的轉碼yuv,對AVpacket,AVframe沒有特殊要求,完整就好。
3) 若果現將h264實時流存在共享內存中,再從共享內存中讀取一幀的AVpacket,那麼AVframe就不要循環清理,最好做成成員變量,否則非關鍵幀無法解碼,會提示如上錯誤。
解決辦法:將AVframe做成成員變量,不能用一次清理一次

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章