Page 1 of 1
Compile error with new ffmpeg
Posted: Sun Apr 27, 2025 2:36 pm
by stevenfalco
I just downloaded a new copy of the ffmpeg snapshot (2025-04-27).
ffmpeg built properly, but when I tried building makemkv-oss-1.18.1 I got a few errors. I attached the build log, but here are the highlights:
Code: Select all
libffabi/src/ffabi.c:214:9: error: implicit declaration of function ‘avcodec_close’; did you mean ‘avcodec_license’? [-Wimplicit-function-declaration]
214 | avcodec_close(ctx->avctx);
| ^~~~~~~~~~~~~
Code: Select all
libffabi/src/ffabi.c:377:25: error: ‘FF_PROFILE_UNKNOWN’ undeclared (first use in this function); did you mean ‘FFM_PROFILE_UNKNOWN’?
377 | info->profile : FF_PROFILE_UNKNOWN;
| ^~~~~~~~~~~~~~~~~~
I then went back to an older copy of ffmpeg from 2024-10-04 and I was able to build makemkv-oss-1.18.1 without any problems.
Apparently, ffmpeg has changed its API recently, and makemkv-oss-1.18.1 cannot build using the new API.
Re: Compile error with new ffmpeg
Posted: Sun Apr 27, 2025 2:50 pm
by stevenfalco
I looked at the ffmpeg git repo, and found that avcodec_close() was deprecated, and now has been removed. Please see commit 0d48da2db in the ffmpeg source git:
Code: Select all
avcodec: remove deprecated FF_API_AVCODEC_CLOSE
Deprecated since 2024-02-09.
Signed-off-by: James Almer <jamrial@gmail.com>
There is also this note describing the API change to avcodec_close():
Code: Select all
* @deprecated Do not use this function. Use avcodec_free_context() to destroy a
* codec context (either open or closed). Opening and closing a codec context
* multiple times is not supported anymore -- use multiple codec contexts
* instead.
Regarding FF_PROFILE_UNKNOWN, I found commit 822432769 which removes it:
Code: Select all
avcodec: remove deprecated FF_API_FF_PROFILE_LEVEL
Deprecated since 2023-09-06.
Signed-off-by: James Almer <jamrial@gmail.com>
And there is this note:
Code: Select all
/** @deprecated The following define is deprecated; use AV_LEVEL_UNKOWN
* in defs.h instead. */
Re: Compile error with new ffmpeg
Posted: Sun May 11, 2025 8:57 am
by elfurbe
These were good hints. The following patch should make ffabi.c from makemkv-oss-1.18.1 compile against libavcodec.so.62, if anyone else is trying to work that out. Fair warning, no idea if this breaks compat with earlier versions of libavcodec. Also worth saying I do not generate patches with any frequency, so if this doesn't apply properly the changes are easy to make by hand.
Code: Select all
--- ffabi.c 2025-04-05 10:13:02.000000000 -0700
+++ ffabi.c 2025-05-11 01:32:20.691298362 -0700
@@ -211,8 +211,7 @@
av_packet_free(&ctx->pck);
if (ctx->avctx) {
- avcodec_close(ctx->avctx);
- av_free(ctx->avctx);
+ avcodec_free_context(ctx->avctx);
}
av_free(ctx);
@@ -374,7 +373,7 @@
#endif
ctx->avctx->profile = (info->profile != FFM_PROFILE_UNKNOWN) ?
- info->profile : FF_PROFILE_UNKNOWN;
+ info->profile : AV_PROFILE_UNKNOWN;
if ((CodecFlags&FFM_CODEC_FLAG_GLOBAL_HEADER)!=0)
ctx->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
@@ -420,8 +419,7 @@
av_freep(&ctx->frame_extended_data);
if (ctx->avctx) {
- avcodec_close(ctx->avctx);
- av_free(ctx->avctx);
+ avcodec_free_context(ctx->avctx);
}
av_free(ctx);
@@ -604,7 +602,7 @@
info->capabilities = codec->capabilities;
if (codec->profiles) {
for (i=0;i<32;i++) {
- if (codec->profiles[i].profile==FF_PROFILE_UNKNOWN)
+ if (codec->profiles[i].profile==AV_PROFILE_UNKNOWN)
break;
info->profiles_names[i]=codec->profiles[i].name;
info->profiles_values[i]=codec->profiles[i].profile;
@@ -695,8 +693,7 @@
}
if (avctx) {
- avcodec_close(avctx);
- av_free(avctx);
+ avcodec_free_context(avctx);
}
return err;
}
Re: Compile error with new ffmpeg
Posted: Sun Jun 08, 2025 7:22 pm
by innerlib
I was experiencing libc/pthread segfaults originating in ffm_mlp_read_syncframe which is part of the patch. It compiles cleanly, but looking harder at avcodec_free_context, it takes a pointer to a pointer. Amending the patch to...
Code: Select all
--- ffabi.c 2025-04-05 10:13:02.000000000 -0700
+++ ffabi.c 2025-05-11 01:32:20.691298362 -0700
@@ -211,8 +211,7 @@
av_packet_free(&ctx->pck);
if (ctx->avctx) {
- avcodec_close(ctx->avctx);
- av_free(ctx->avctx);
+ avcodec_free_context(&(ctx->avctx));
}
av_free(ctx);
@@ -374,7 +373,7 @@
#endif
ctx->avctx->profile = (info->profile != FFM_PROFILE_UNKNOWN) ?
- info->profile : FF_PROFILE_UNKNOWN;
+ info->profile : AV_PROFILE_UNKNOWN;
if ((CodecFlags&FFM_CODEC_FLAG_GLOBAL_HEADER)!=0)
ctx->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
@@ -420,8 +419,7 @@
av_freep(&ctx->frame_extended_data);
if (ctx->avctx) {
- avcodec_close(ctx->avctx);
- av_free(ctx->avctx);
+ avcodec_free_context(&(ctx->avctx));
}
av_free(ctx);
@@ -604,7 +602,7 @@
info->capabilities = codec->capabilities;
if (codec->profiles) {
for (i=0;i<32;i++) {
- if (codec->profiles[i].profile==FF_PROFILE_UNKNOWN)
+ if (codec->profiles[i].profile==AV_PROFILE_UNKNOWN)
break;
info->profiles_names[i]=codec->profiles[i].name;
info->profiles_values[i]=codec->profiles[i].profile;
@@ -695,8 +693,7 @@
}
if (avctx) {
- avcodec_close(avctx);
- av_free(avctx);
+ avcodec_free_context(&avctx);
}
return err;
}
Hasn't segfault'd yet.