Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with FFmpeg 6.0 #1106

Closed
1 of 6 tasks
cebtenzzre opened this issue Mar 17, 2023 · 6 comments
Closed
1 of 6 tasks

Build fails with FFmpeg 6.0 #1106

cebtenzzre opened this issue Mar 17, 2023 · 6 comments
Labels

Comments

@cebtenzzre
Copy link

Overview

FFmpeg 6.0 was released on February 28th. PyAV currently doesn't build against this version due to removal of several deprecated features, including the flags AV_CODEC_CAP_TRUNCATED, AV_CODEC_CAP_AUTO_THREADS, AV_CODEC_CAP_INTRA_ONLY, AV_CODEC_CAP_LOSSLESS, and AVFMT_FLAG_PRIV_OPT.

Expected behavior

I would expect to be able to successfully build against FFmpeg 6.0.

Actual behavior

The build fails with FFmpeg 6.0.

Build report (full log here):

gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -fPIC -I/usr/include/python3.10 -c src/av/container/core.c -o build/temp.linux-x86_64-cpython-310/src/av/container/core.o
src/av/container/core.c: In function ‘__pyx_pf_2av_9container_4core_9Container___cinit__’:
src/av/container/core.c:4452:18: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 4452 |       __pyx_t_11 = av_guess_format(NULL, __pyx_v_name, NULL);
      |                  ^
src/av/container/core.c:4729:5: warning: ‘io_close’ is deprecated [-Wdeprecated-declarations]
 4729 |     __pyx_v_self->ptr->io_close = __pyx_f_2av_9container_4core_pyav_io_close;
      |     ^~~~~~~~~~~~
In file included from /usr/include/libavdevice/avdevice.h:57,
                 from src/av/container/core.c:791:
/usr/include/libavformat/avformat.h:1677:12: note: declared here
 1677 |     void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
      |            ^~~~~~~~
src/av/container/core.c:4957:90: warning: passing argument 1 of ‘__pyx_f_2av_6format_build_container_format’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 4957 |     __pyx_t_3 = ((PyObject *)__pyx_f_2av_6format_build_container_format(__pyx_v_self->ptr->iformat, __pyx_v_self->ptr->oformat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
      |                                                                         ~~~~~~~~~~~~~~~~~^~~~~~~~~
src/av/container/core.c:4957:90: note: expected ‘struct AVInputFormat *’ but argument is of type ‘const struct AVInputFormat *’
src/av/container/core.c:4957:118: warning: passing argument 2 of ‘__pyx_f_2av_6format_build_container_format’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 4957 |     __pyx_t_3 = ((PyObject *)__pyx_f_2av_6format_build_container_format(__pyx_v_self->ptr->iformat, __pyx_v_self->ptr->oformat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
      |                                                                                                     ~~~~~~~~~~~~~~~~~^~~~~~~~~
src/av/container/core.c:4957:118: note: expected ‘struct AVOutputFormat *’ but argument is of type ‘const struct AVOutputFormat *’
src/av/container/core.c: In function ‘__pyx_pymod_exec_core’:
src/av/container/core.c:9043:36: error: ‘AVFMT_FLAG_PRIV_OPT’ undeclared (first use in this function); did you mean ‘AVFMT_FLAG_IGNIDX’?
 9043 |   __pyx_t_3 = __Pyx_PyInt_From_int(AVFMT_FLAG_PRIV_OPT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
      |                                    ^~~~~~~~~~~~~~~~~~~
      |                                    AVFMT_FLAG_IGNIDX
src/av/container/core.c:9043:36: note: each undeclared identifier is reported only once for each function it appears in
error: command '/usr/bin/gcc' failed with exit code 1

Investigation

I recently updated to FFmpeg 6.0, and PyAV does not build anymore. I looked into the changes made in FFmpeg 6.0 and it appears that at a minimum, some flags PyAV references have been removed.

Reproduction

  1. Install FFmpeg 6.0
  2. Attempt to build PyAV with python setup.py build

Versions

  • OS: Arch Linux
  • PyAV runtime: v10.0.0, commit 6982d81
  • PyAV build: (suggested command just prints "running config")
  • FFmpeg:
ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 12.2.1 (GCC) 20230201
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-version3 --enable-vulkan
libavutil      58.  2.100 / 58.  2.100
libavcodec     60.  3.100 / 60.  3.100
libavformat    60.  3.100 / 60.  3.100
libavdevice    60.  1.100 / 60.  1.100
libavfilter     9.  3.100 /  9.  3.100
libswscale      7.  1.100 /  7.  1.100
libswresample   4. 10.100 /  4. 10.100
libpostproc    57.  1.100 / 57.  1.100

Research

I have done the following:

@diizzyy
Copy link

diizzyy commented Mar 18, 2023

Seeing same issue on FreeBSD (amd64) using LLVM/Clang:

cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -march=tigerlake -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -march=tigerlake -fstack-protector-strong -fno-strict-aliasing -fPIC -I/usr/local/include -I/usr/local/include/python3.9 -c src/av/container/core.c -o build/temp.freebsd-13.2-BETA1-amd64-cpython-39/src/av/container/core.o
src/av/container/core.c:3017:13: warning: code will never be executed [-Wunreachable-code]
  __pyx_r = 0;
            ^
src/av/container/core.c:3108:13: warning: code will never be executed [-Wunreachable-code]
  __pyx_r = 0;
            ^
src/av/container/core.c:4481:18: warning: assigning to 'struct AVOutputFormat *' from 'const AVOutputFormat *' (aka 'const struct AVOutputFormat *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
      __pyx_t_11 = av_guess_format(NULL, __pyx_v_name, NULL);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/av/container/core.c:4758:24: warning: 'io_close' is deprecated [-Wdeprecated-declarations]
    __pyx_v_self->ptr->io_close = __pyx_f_2av_9container_4core_pyav_io_close;
                       ^
/usr/local/include/libavformat/avformat.h:1672:5: note: 'io_close' has been explicitly marked deprecated here
    attribute_deprecated
    ^
/usr/local/include/libavutil/attributes.h:100:49: note: expanded from macro 'attribute_deprecated'
#    define attribute_deprecated __attribute__((deprecated))
                                                ^
src/av/container/core.c:4986:73: warning: passing 'const struct AVInputFormat *' to parameter of type 'struct AVInputFormat *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    __pyx_t_3 = ((PyObject *)__pyx_f_2av_6format_build_container_format(__pyx_v_self->ptr->iformat, __pyx_v_self->ptr->oformat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/av/container/core.c:4986:101: warning: passing 'const struct AVOutputFormat *' to parameter of type 'struct AVOutputFormat *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    __pyx_t_3 = ((PyObject *)__pyx_f_2av_6format_build_container_format(__pyx_v_self->ptr->iformat, __pyx_v_self->ptr->oformat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
                                                                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/av/container/core.c:9072:36: error: use of undeclared identifier 'AVFMT_FLAG_PRIV_OPT'
  __pyx_t_3 = __Pyx_PyInt_From_int(AVFMT_FLAG_PRIV_OPT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
                                   ^
6 warnings and 1 error generated.

archlinux-github pushed a commit to archlinux/aur that referenced this issue Mar 18, 2023
wader added a commit to wader/PyAV that referenced this issue Mar 21, 2023
Removed and renamed constants with entry from API changes
https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/doc/APIchanges

Remove use of AVCodecContext.sub_text_format
  2021-09-20 - 176b8d785bf - lavc 59.9.100 - avcodec.h
    Deprecate AVCodecContext.sub_text_format and the corresponding
    AVOptions. It is unused since the last major bump.

AV_CODEC_CAP_TRUNCATED removed:
  2021-09-20 - dd846bc4a91 - lavc 59.8.100 - avcodec.h codec.h
    Deprecate AV_CODEC_FLAG_TRUNCATED and AV_CODEC_CAP_TRUNCATED,
    as they are redundant with parsers.

AV_CODEC_CAP_AUTO_THREADS renamed to AV_CODEC_CAP_AUTO_THREADS
  2021-03-16 - 7d09579190 - lavc 58.132.100 - codec.h
    Add AV_CODEC_CAP_OTHER_THREADS as a new name for
    AV_CODEC_CAP_AUTO_THREADS. AV_CODEC_CAP_AUTO_THREADS
    is now deprecated.

AV_CODEC_CAP_INTRA_ONLY removed (use AV_CODEC_PROP_INTRA_ONLY instead):
AV_CODEC_CAP_LOSSLESS removed (use AV_CODEC_PROP_LOESSNES instead):
  2020-05-21 - 13b1bbff0b - lavc 58.86.101 - avcodec.h
    Deprecated AV_CODEC_CAP_INTRA_ONLY and AV_CODEC_CAP_LOSSLESS.

AV_CODEC_FLAG_TRUNCATED removed:
AV_CODEC_CAP_TRUNCATED removed:
  2021-09-20 - dd846bc4a91 - lavc 59.8.100 - avcodec.h codec.h
    Deprecate AV_CODEC_FLAG_TRUNCATED and AV_CODEC_CAP_TRUNCATED,
    as they are redundant with parsers.

AV_CODEC_FLAG2_DROP_FRAME_TIMECODE removed:
  Not API changelog but was removed in f843460eb790d37e444e5946628f228421916537:
  avcodec/avcodec: Remove AV_CODEC_FLAG2_DROP_FRAME_TIMECODE

  It has been deprecated in 94d68a4
  and can't be set via AVOptions. The only codecs that use it
  (the MPEG-1/2 encoders) have private options for this.
  So remove it.

AVFMT_FLAG_PRIV_OPT removed:
  2021-03-03 - 2ff40b98ec - lavf 58.70.100 - avformat.h
    Deprecate AVFMT_FLAG_PRIV_OPT. It will do nothing
    as soon as av_demuxer_open() is removed.

Related to PyAV-Org#1106
@abhinavsingh
Copy link

jFYI, we hit this error today for our Docker builds.

Pinning to python:3.11-alpine3.17 helps get past the build error,
as alpine v3.18 fetches FFmpeg 6.0 by default.

Looking forward to compatibility with FFmpeg 6.0
so we can remove pin on alpine 3.17

@araczkowski
Copy link

I'm waiting for the update to ffmpeg 6.0 ...

@leidix
Copy link

leidix commented Jul 21, 2023

I have the same issue, hope this will be fixed soon

@badger200
Copy link

badger200 commented Aug 4, 2023

Also breaks MacOS 10.9 MacPorts with ffmpeg 6.0 installed, I also tried installing from pip and that fails due to missing Metal Framework, so I’m trying to build from source and that fails due to this issue.

update: this waiting PR works on ffmpeg 6.0!
wader@8871e13

@WyattBlue
Copy link
Member

We've merged the necessary PRs to build ffmpeg 6.0 in the main branch. A release will happen soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants