ijkplayer錄像改造功能的問題集

FFmpeg中 avcodec_copy_context和codec deprecated方案如下:

將之前http://www.itdecent.cn/p/e35566f0965a網(wǎng)上的ios錄像功能函數(shù)在開始錄像函數(shù)的里面要修改,由于上面提到int ffp_start_recording_l(FFPlayer*ffp,constchar*file_name)函數(shù)沖突問題,修改如下:

for(inti =0; i < is->ic->nb_streams; i++) {

.........

?AVCodec*codec =avcodec_find_decoder(in_stream->codecpar->codec_id);

? ? ? ? AVStream *out_stream = avformat_new_stream(ffp->m_ofmt_ctx, codec);//avformat_new_stream(ffp->m_ofmt_ctx, in_stream->codec->codec);

...........

AVCodecContext *pCodecCtx = avcodec_alloc_context3(codec);

? ? ? ? intret =avcodec_parameters_to_context(pCodecCtx, in_stream->codecpar);

? ? ? ? //if (avcodec_copy_context(out_stream->codec, in_stream->codec) < 0)

? ? ? ? if(ret <0)

? ? ? ? {

? ? ? ? ? ? av_log(ffp, AV_LOG_ERROR, "Failed to copy context from input to output stream codec context\n");

? ? ? ? ? ? goto?end;

? ? ? ? }

?? ? ? ?pCodecCtx->codec_tag=0;

? ? ? ??if(ffp->m_ofmt_ctx->oformat->flags&AVFMT_GLOBALHEADER) {

? ? ? ? ? ? pCodecCtx->flags|=CODEC_FLAG_GLOBAL_HEADER;

? ? ? ? }

? ? ? ? ret =avcodec_parameters_from_context(out_stream->codecpar, pCodecCtx); ? ? ? ? ? ? ?

? ? ? ? if(ret <0) {

? ? ? ? ? ? printf("Failed to copy context input to output stream codec context\n");

? ? ? ? ? ??goto?end;

? ? ? ? }

? ? ? ? //out_stream->codec->codec_tag = 0;

//? ? ? ? if (ffp->m_ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) {

//? ? ? ? ? ? out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;

//? ? ? ? }

}

對應修改看上面注釋都是和新修改是一一對應的。

參考資料:

?http://www.itdecent.cn/p/e35566f0965a

https://www.2cto.com/kf/201704/634731.html

https://blog.csdn.net/leixiaohua1020/article/details/25422685

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容