最近在练习ffmpeg开发音视频的一些内容,发现ffmpeg由于版本的冲突,有些api已经不再使用。所以抽时间整理一下
av_free_packet
这个api的使用已经替换为 av_packet_unref,两者在使用上没有任何的不同,就是API的替换
AVStream::codec 这个成员已被否决使用,与之替换的是AVStream::codecpar,此成员保留了AVStream::codec 的大多数参数,在转换的时候是这样转化
AVCodecContext *pAVCodecContext = avcodec_alloc_context3(nullptr);
avcodec_parameters_to_context(pAVCodecContext,pAVFormatContext->streams[videoIndex]->codecpar);
av_dup_packet 正如av_free_packet被否决一样,av_dup_packet同样被否决了,此时替换的为av_packet_ref
不过av_packet_ref增加源和目的参数,这点需要注意。
还有就是 avcodec_decode_audio4系列也被否决,此时根据新的api
ret = avcodec_send_frame(play->m_audio_ctx, &avframe);
if (ret < 0)
{
break;
}
got_frame = avcodec_receive_packet(play->m_audio_ctx, &pkt2);
if (!got_f