Skip to content

Conversation

@ssh4net
Copy link
Contributor

@ssh4net ssh4net commented Jul 23, 2025

avcodec_close (AVCodecContext *avctx) removing in ffmpeg 7.2 and was deprecated for couple years

Description

Global avcodec_close (AVCodecContext *avctx)
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.

In ffmpeg master, it has already been removed. But still work in v7.1

Tests

Checklist:

  • [x ] I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (Check if there is no
    need to update the documentation, for example if this is a bug fix that
    doesn't change the API.)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

avcodec_close (AVCodecContext *avctx) removing in ffmpeg 7.2 and was deprecated for couple years

Signed-off-by: Vlad (Kuzmin) Erium <[email protected]>
@lgritz
Copy link
Collaborator

lgritz commented Jul 23, 2025

How far back is avcodec_free_context available? Does it go all the way back to ffmpeg 4.0, the earliest version we claim to support? (If not, then we either have to make our advertised minimum ffmpeg new enough that this is supported, or else use an #if based on the version.)

@ssh4net
Copy link
Contributor Author

ssh4net commented Jul 23, 2025

Not sure about version, but there is a changelog

2014-05-18 - 68c0518 / fd05602 - lavc 55.63.100 / 55.52.0 - avcodec.h
  Add avcodec_free_context(). From now on it should be used for freeing
  AVCodecContext.

@lgritz
Copy link
Collaborator

lgritz commented Jul 23, 2025

Our oldest is ffmpeg 4.0, which corresponds to 58.18.100, so I think we are safe.

@lgritz lgritz changed the title Replace deprecated and soon removed avcodec_close with avcodec_free_context in ffmpeg plugin. ffmpeg: Replace deprecated and soon removed avcodec_close with avcodec_free_context in ffmpeg plugin. Jul 23, 2025
@lgritz lgritz added file formats Image file formats, ImageInput, ImageOutput build / testing / port / CI Affecting the build system, tests, platform support, porting, or continuous integration. labels Jul 23, 2025
@lgritz lgritz merged commit 49efbd6 into AcademySoftwareFoundation:main Jul 23, 2025
30 checks passed
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Jul 24, 2025
…c_free_context (AcademySoftwareFoundation#4837)

avcodec_close (AVCodecContext *avctx) removing in ffmpeg 7.2 and was
deprecated for couple years

Global avcodec_close (AVCodecContext *avctx)
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.

In ffmpeg master, it has already been removed. But still work in v7.1

We checked the ffmpeg changelog, and avcodec_free_context was added 7 years ago and should be present in ffmpeg 4.0, the oldest version we support.

Signed-off-by: Vlad (Kuzmin) Erium <[email protected]>
zachlewis pushed a commit to zachlewis/OpenImageIO that referenced this pull request Aug 1, 2025
…c_free_context (AcademySoftwareFoundation#4837)

avcodec_close (AVCodecContext *avctx) removing in ffmpeg 7.2 and was
deprecated for couple years

Global avcodec_close (AVCodecContext *avctx)
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.

In ffmpeg master, it has already been removed. But still work in v7.1

We checked the ffmpeg changelog, and avcodec_free_context was added 7 years ago and should be present in ffmpeg 4.0, the oldest version we support.

Signed-off-by: Vlad (Kuzmin) Erium <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Sep 14, 2025
…c_free_context (AcademySoftwareFoundation#4837)

avcodec_close (AVCodecContext *avctx) removing in ffmpeg 7.2 and was
deprecated for couple years

Global avcodec_close (AVCodecContext *avctx)
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.

In ffmpeg master, it has already been removed. But still work in v7.1

We checked the ffmpeg changelog, and avcodec_free_context was added 7 years ago and should be present in ffmpeg 4.0, the oldest version we support.

Signed-off-by: Vlad (Kuzmin) Erium <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Sep 15, 2025
…c_free_context (AcademySoftwareFoundation#4837)

avcodec_close (AVCodecContext *avctx) removing in ffmpeg 7.2 and was
deprecated for couple years

Global avcodec_close (AVCodecContext *avctx)
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.

In ffmpeg master, it has already been removed. But still work in v7.1

We checked the ffmpeg changelog, and avcodec_free_context was added 7 years ago and should be present in ffmpeg 4.0, the oldest version we support.

Signed-off-by: Vlad (Kuzmin) Erium <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build / testing / port / CI Affecting the build system, tests, platform support, porting, or continuous integration. file formats Image file formats, ImageInput, ImageOutput

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants