Skip to content

Update FFCodec structure for ffmpeg 7.1+#283

Open
cincodenada wants to merge 3 commits into
anthwlock:masterfrom
cincodenada:fix-ffmpeg-7
Open

Update FFCodec structure for ffmpeg 7.1+#283
cincodenada wants to merge 3 commits into
anthwlock:masterfrom
cincodenada:fix-ffmpeg-7

Conversation

@cincodenada
Copy link
Copy Markdown

Short version

It looks like a field was removed above the union in FFCodec, which seems to have broken things quite a bit.

There wasn't an internal version change for this, so there are a handful of commits that this will still break against, but it should be fine against all release versions.

Specifically, the internal version was bumped to 13 in this ffmpeg commit, and and init_static_data was actually removed a few commits later.

I've also added targets for 7.x releases to the Makefile, and added --disable-libdrm to the build flags for versions > 6, because I was getting build errors from the drm bits, and it seemed unlikely that we needed that bit just based on the name (and it still works on my test videos, at least).

Background

I tried to build this untrunc against my Ubuntu shared libraries, which has ffmpeg 7.1, and it didn't work very well at all - recovered a few seconds of a video, if it worked at all. So I tried building the original version, and it worked fine.

After some investigation, I determined that the likely difference was that the original had a baked-in version of ffmpeg. And indeed, building this fork of untrunc with various ffmpeg versions worked just fine. After some bisecting of releases I determined that the problem was introduced between 7.0 and 7.1, and then further bisecting with the git repo pointed to the above commit (4524d527bf), where a field was removed from FFCodec.

I don't know enough about how all this works to know for sure what effect that had, but I know enough about how C works to suspect that having our copy of the internal headers differ from the actual internal headers is likely to cause all kinds of strange problems. So I made that field conditional on the internal AVCODEC_VERSION (as closely as I could), and now untrunc runs with 7.1 just fine - both my shared libraries, and the release version.

I don't have a clear enough understanding of everything involved to know if this is the best fix for this or not, but it does seem to fix the issue for me, it's a very simple change, and seems safe as it's quite unlikely to affect building with previous versions of ffmpeg due to the version gating involved.

A field was removed above the union, which broke things quite a bit.

There wasn't an internal version change for this, so there are a handful
of commits that this will still break against, but it should be fine
against all release versions.

Specifically, the internal version was bumped to 13 in this ffmpeg commit:
3305767560 commit 2024-04-03 - avcodec: add avcodec_get_supported_config()

And init_static_data was actually removed here:
4524d527bf avcodec/codec_internal: nuke init_static_data()
It was throwing errors, and it doesn't seem like we need it
@cincodenada
Copy link
Copy Markdown
Author

Thanks for all your work on this project, by the way - this version was much easier to build than the original, and I could have saved myself that by just reading the README closer and trying building against 3.3.9 :)

The build targets for various versions also made tracking down the problem MUCH easier, so thank you for that as well!

@cincodenada
Copy link
Copy Markdown
Author

Also, it might be worth checking with recent issue-openers to see what version of FFmpeg they were building against - in my case, when it was broken, it still recovered the first few seconds of video, but no more than that, which fits what e.g. #282 is describing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant