FFmpeg 被聲明為已否決 deprecated(2018 精)


不用再取消SDL檢查,不用再添加#pragma warning(disable :4996),下面才是正確的解決方法!!
以下是一些常見的deprecated問題,遇到下述沒有列出的問題,可以打開相應的頭文件,在里面搜索ctrl+F,會有英文說明的,如下:
 

 

 

 
PIX_FMT_YUV420P -> AV_PIX_FMT_YUV420P


'AVStream::codec': 被聲明為已否決:
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){
=>
if(pFormatCtx->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_VIDEO){


'AVStream::codec': 被聲明為已否決:
pCodecCtx = pFormatCtx->streams[videoindex]->codec;
=>
pCodecCtx = avcodec_alloc_context3(NULL);
avcodec_parameters_to_context(pCodecCtx, pFormatCtx->streams[videoindex]->codecpar);


'avpicture_get_size': 被聲明為已否決:
avpicture_get_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height)
=>
#include "libavutil/imgutils.h"
av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1)


'avpicture_fill': 被聲明為已否決:
avpicture_fill((AVPicture *)pFrameYUV, out_buffer, AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height);
=>
av_image_fill_arrays(pFrameYUV->data, pFrameYUV->linesize, out_buffer, AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1);


'avcodec_decode_video2': 被聲明為已否決:
ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet); //got_picture_ptr Zero if no frame could be decompressed
=>
ret = avcodec_send_packet(pCodecCtx, packet);
got_picture = avcodec_receive_frame(pCodecCtx, pFrame); //got_picture = 0 success, a frame was returned
//注意:got_picture含義相反
或者:
int ret = avcodec_send_packet(aCodecCtx, &pkt);
if (ret != 0)
{
prinitf("%s/n","error");
return;
}
while( avcodec_receive_frame(aCodecCtx, &frame) == 0){
//讀取到一幀音頻或者視頻
//處理解碼后音視頻 frame
}

'av_free_packet': 被聲明為已否決:
av_free_packet(packet);
=>
av_packet_unref(packet);
 
 
avcodec_decode_audio4:被聲明為已否決:
int ret = avcodec_send_packet(aCodecCtx, &pkt);
if (ret != 0){prinitf("%s/n","error");}
while( avcodec_receive_frame(aCodecCtx, &frame) == 0){
//讀取到一幀音頻或者視頻
//處理解碼后音視頻 frame
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM