Issue 1:
System Information

Debian GNU/Linux

OpenCV version: 4.6.0

Detailed description

4.6 builds for these modules

core,highgui,imgcodecs,imgproc

or with all modules, but fails if videoio is added:

core,highgui,imgcodecs,imgproc,videoio

Steps to reproduce

git clone --depth 1 --branch 4.6.0 https://github.com/opencv/opencv.git opencv-4.6.0
mv opencv-4.6.0 opencv
mkdir -p build && cd build
cmake -DBUILD_LIST=core,highgui,imgcodecs,imgproc,videoio ../opencv
make -j4

opencv/modules/videoio/src/ffmpeg_codecs.hpp:81:26: error: ‘CODEC_ID_H264’ was not declared in this scope; did you mean ‘AV_CODEC_ID_H264’?
81 | #define AV_CODEC_ID_H264 CODEC_ID_H264
| ^~~~~~~~~~~~~

Issue submission checklist

I report the issue, it's not a question

I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution

I updated to the latest OpenCV version and the issue is still there

There is reproducer code and related data files (videos, images, onnx, etc)

Issue 2:
System information (version)

OpenCV => 4.6

Operating System / Platform => macOS Monterey, Arch Linux

Compiler => XCode toolchain (Mac), GCC toolchain (Arch Linux)

Detailed description

OpenCV compilation fails when FFmpeg 5.1 is installed on the system (no issue with 5.0.x and earlier versions). Here is the associated error message on Mac (the error message is somewhat similar on Arch Linux):

In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:80:6: warning: 'LIBAVCODEC_VERSION_INT' is not defined, evaluates to 0 [-Wundef]
#if (LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(54, 51, 100))
^
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:146:7: error: use of undeclared identifier 'CODEC_ID_H264'; did you mean 'AV_CODEC_ID_H264'?
{ AV_CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H264
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:81:26: note: expanded from macro 'AV_CODEC_ID_H264'
#define AV_CODEC_ID_H264 CODEC_ID_H264
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:77:5: note: 'AV_CODEC_ID_H264' declared here
AV_CODEC_ID_H264,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:147:7: error: use of undeclared identifier 'CODEC_ID_H264'; did you mean 'AV_CODEC_ID_H264'?
{ AV_CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H264
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:81:26: note: expanded from macro 'AV_CODEC_ID_H264'
#define AV_CODEC_ID_H264 CODEC_ID_H264
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:77:5: note: 'AV_CODEC_ID_H264' declared here
AV_CODEC_ID_H264,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:148:7: error: use of undeclared identifier 'CODEC_ID_H264'; did you mean 'AV_CODEC_ID_H264'?
{ AV_CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H264
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:81:26: note: expanded from macro 'AV_CODEC_ID_H264'
#define AV_CODEC_ID_H264 CODEC_ID_H264
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:77:5: note: 'AV_CODEC_ID_H264' declared here
AV_CODEC_ID_H264,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:149:7: error: use of undeclared identifier 'CODEC_ID_H264'; did you mean 'AV_CODEC_ID_H264'?
{ AV_CODEC_ID_H264, MKTAG('x', '2', '6', '4') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H264
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:81:26: note: expanded from macro 'AV_CODEC_ID_H264'
#define AV_CODEC_ID_H264 CODEC_ID_H264
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:77:5: note: 'AV_CODEC_ID_H264' declared here
AV_CODEC_ID_H264,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:150:7: error: use of undeclared identifier 'CODEC_ID_H264'; did you mean 'AV_CODEC_ID_H264'?
{ AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H264
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:81:26: note: expanded from macro 'AV_CODEC_ID_H264'
#define AV_CODEC_ID_H264 CODEC_ID_H264
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:77:5: note: 'AV_CODEC_ID_H264' declared here
AV_CODEC_ID_H264,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:151:7: error: use of undeclared identifier 'CODEC_ID_H264'; did you mean 'AV_CODEC_ID_H264'?
{ AV_CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H264
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:81:26: note: expanded from macro 'AV_CODEC_ID_H264'
#define AV_CODEC_ID_H264 CODEC_ID_H264
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:77:5: note: 'AV_CODEC_ID_H264' declared here
AV_CODEC_ID_H264,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:153:7: error: use of undeclared identifier 'CODEC_ID_H263'; did you mean 'AV_CODEC_ID_H263'?
{ AV_CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H263
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:82:26: note: expanded from macro 'AV_CODEC_ID_H263'
#define AV_CODEC_ID_H263 CODEC_ID_H263
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:54:5: note: 'AV_CODEC_ID_H263' declared here
AV_CODEC_ID_H263,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:154:7: error: use of undeclared identifier 'CODEC_ID_H263P'; did you mean 'AV_CODEC_ID_H263P'?
{ AV_CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_H263P
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:83:27: note: expanded from macro 'AV_CODEC_ID_H263P'
#define AV_CODEC_ID_H263P CODEC_ID_H263P
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:69:5: note: 'AV_CODEC_ID_H263P' declared here
AV_CODEC_ID_H263P,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:155:7: error: use of undeclared identifier 'CODEC_ID_H263I'; did you mean 'AV_CODEC_ID_H263I'?
{ AV_CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_H263I
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:84:27: note: expanded from macro 'AV_CODEC_ID_H263I'
#define AV_CODEC_ID_H263I CODEC_ID_H263I
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:70:5: note: 'AV_CODEC_ID_H263I' declared here
AV_CODEC_ID_H263I,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:156:7: error: use of undeclared identifier 'CODEC_ID_H261'; did you mean 'AV_CODEC_ID_H261'?
{ AV_CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
^~~~~~~~~~~~~~~~
AV_CODEC_ID_H261
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:85:26: note: expanded from macro 'AV_CODEC_ID_H261'
#define AV_CODEC_ID_H261 CODEC_ID_H261
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:53:5: note: 'AV_CODEC_ID_H261' declared here
AV_CODEC_ID_H261,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:159:7: error: use of undeclared identifier 'CODEC_ID_H263P'; did you mean 'AV_CODEC_ID_H263P'?
{ AV_CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_H263P
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:83:27: note: expanded from macro 'AV_CODEC_ID_H263P'
#define AV_CODEC_ID_H263P CODEC_ID_H263P
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:69:5: note: 'AV_CODEC_ID_H263P' declared here
AV_CODEC_ID_H263P,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:160:7: error: use of undeclared identifier 'CODEC_ID_H263P'; did you mean 'AV_CODEC_ID_H263P'?
{ AV_CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_H263P
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:83:27: note: expanded from macro 'AV_CODEC_ID_H263P'
#define AV_CODEC_ID_H263P CODEC_ID_H263P
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:69:5: note: 'AV_CODEC_ID_H263P' declared here
AV_CODEC_ID_H263P,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:162:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:163:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:164:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:165:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:166:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:167:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:168:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/var/folders/ty/hlxp4fjd4dlcm9y08gnxgtyw0000gn/T/Rtmpmy3YCG/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2

Steps to reproduce

Issue submission checklist

I report the issue, it's not a question

I checked the problem with documentation, FAQ, open issues,

forum.opencv.org, Stack Overflow, etc and have not found any solution

I updated to the latest OpenCV version and the issue is still there

There is reproducer code and related data files: videos, images, onnx, etc