How to fill 'extradata' field of AVCodecContext with SPS and PPS data?

前端 未结 2 1886
北海茫月
北海茫月 2021-01-03 07:54

Here is the problem: When decoding H264 stream with ffmpeg, I can obtain raw data of SPS and PPS but I have no idea how to fill them into the extradata

2条回答
  •  囚心锁ツ
    2021-01-03 08:32

    c_v->extradata = (uint8_t*)av_malloc(flvBufSize + FF_INPUT_BUFFER_PADDING_SIZE);
    if(!c_v->extradata){
        loge("Could not av_malloc extradata");
    }
    logv("extradata_size =%d", c_v->extradata_size);
    c_v->extradata_size = flvBufSize;
    memcpy(c_v->extradata, avpkt.data, avpkt.size);
    
    if (avcodec_open2(c_v, codec_v, NULL) < 0) {
        loge("could not open video codec");                             
    }
    

提交回复
热议问题