版权声明:本文为博主原创文章,未经博主允许不得转载,如需转载请先得到博主的同意,如需帮助,联系[email protected],谢谢。 https://blog.csdn.net/HW140701/article/details/84673063
原因:FFmepg新版本已经将该API丢弃,需要新的API接口代替
解决方案1:将SDL检查设置为否(不推荐)
解决方案2:修改为新的API接口函数
- 旧API函数写法示例
int AnimationMp4VideoGeneration::WriteVideoFrame(AVFormatContext * oc, OutputStream * ost)
{
int ret;
AVCodecContext *c;
AVFrame *frame;
int got_packet = 0;
AVPacket pkt = { 0 };
c = ost->enc;
frame = GetVideoFrame(ost);
av_init_packet(&pkt);
/* encode the image */
ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
if (ret < 0) {
LOG("Error encoding video frame: %s\n");
exit(1);
}
if (!got_packet) {
ret = WriteFrame(oc, &c->time_base, ost->st, &pkt);
}
else {
ret = 0;
}
if (ret < 0)
{
LOG("Error while writing video frame: %s\n");
exit(1);
}
return (frame || got_packet) ? 0 : 1;
}
- 新API函数写法修改示例
int AnimationMp4VideoGeneration::WriteVideoFrame(AVFormatContext * oc, OutputStream * ost)
{
int ret;
AVCodecContext *c;
AVFrame *frame;
int got_packet = 0;
AVPacket pkt = { 0 };
c = ost->enc;
frame = GetVideoFrame(ost);
av_init_packet(&pkt);
/* encode the image */
ret = avcodec_send_frame(c, frame);
if (ret < 0) {
LOG("Error encoding video frame: %s\n");
exit(1);
}
got_packet = avcodec_receive_packet(c, &pkt);
if (!got_packet) {
ret = WriteFrame(oc, &c->time_base, ost->st, &pkt);
}
else {
ret = 0;
}
if (ret < 0)
{
LOG("Error while writing video frame: %s\n");
exit(1);
}
return (frame || got_packet) ? 0 : 1;
}