ffmpeg 新老接口
宏
CODEC_TYPE_VIDEO -> AVMEDIA_TYPE_VIDEO // #define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
属性:
AVStream::codec:
- old:
pCodecCtx = pFormatCtx->streams[video_index]->codec;
pCodec = avcodec_find_decoder(pFormatCtx->streams[video_index]->codec->codec_id); - new:
pCodecCtx = avcodec_alloc_context3(NULL);
avcodec_parameters_to_context(pCodecCtx,pFormatCtx->streams[video_index]->codecpar);
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
函数:
avpicture_get_size:
old: frameYUV_size = avpicture_get_size(AV_PIX_FMT_YUV420P,
pCodecCtx_Video_in->width, pCodecCtx_Video_in->height);
new: frameYUV_size = av_image_get_buffer_size(AV_PIX_FMT_YUV420P,
pCodecCtx_Video_in->width, pCodecCtx_Video_in->height, 1);// 1按1字节对齐,实际大小。4按4字节对齐,实际大小的4
avpicture_fill:
avcodec_encode_video2:
avcodec_encode_video2(AVCodecContext*, AVPacket*,const AVFrame*,int* ) == avcodec_send_frame(AVCodecContext*, const AVFrame*) + avcodec_receive_packet(AVCodecContext*, &AVPacket*); //AVPacket avpkt;
avcodec_decode_video2:
avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, pPacket) = avcodec_send_packet(pCodecCtx, pPacket) + avcodec_receive_frame(pCodecCtx, pFrame)
av_free_packe:
av_free_packe(AVPacket*) -> av_packet_unref(AVPacket*)
avcodec_encode_audio2:
avcodec_decode_audio4:
本文来自博客园,作者:封兴旺,转载请注明原文链接:https://www.cnblogs.com/fxw1/p/17587557.html