1 原因
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;
}
如果您觉得这篇博文有用,请访问我的个人站:http://www.stubbornhuang.com/,更多博文干货等着您。