FFMPEG 4.1 API 变化 java

FFMPEG 网上下载了一些视频截图的demo,不过版本比较老,一些函数已然过期,针对这些修改一下。整理一下接触到的,作为笔记吧。

1.av_register_all(); 在新版本这个可以直接删除掉。

2.

AVStream stream=pFormatCtx.streams(i);
AVCodecContext codec=stream.codec();

//修改为:
AVStream stream=pFormatCtx.streams(videoStream);
AVCodecParameters param = stream.codecpar();
AVCodec codec = avcodec_find_decoder(param.codec_id()); 
AVCodecContext pCodecCtx = avcodec_alloc_context3(codec);
avcodec_parameters_to_context(pCodecCtx,param);     

3.avpicture_get_size(); 改为 av_image_get_buffer_size(fmt, width, height,1); 最后一个变量改为1就行

4.avpicture_fill(); 改为av_image_fill_arrays(pFrameRGB.data(),pFrameRGB.linesize(),buffer, fmt, width, height,1);

5:avcodec_decode_video2(pCodecCtx, pFrame, frameFinished, packet);该函数已经可以移除,改为:

if(avcodec_send_packet(pCodecCtx,packet)!=0) {
						return null;
}
while(avcodec_receive_frame(pCodecCtx,pFrame) == 0) {
						
sws_scale(sws_ctx, pFrame.data(), pFrame.linesize(), 0, height, pFrameRGB.data(),pFrameRGB.linesize());
						
//return 要执行的处理方法
}

6:av_free_packet()改为av_packet_unref()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值