Error in definition of macro ‘AV_CODEC_ID_FFV1’

Hi all. I have been stuck for days (yet again…) on building OpenCV. I am building it for Docker bookworm image with 7:5.1.4-0+deb12u1 version for ffmpeg. As a result, I get a lot of errors similar to Error in definition of macro ‘AV_CODEC_ID_FFV1’ :

 697.5 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:142:26: note: in definition of macro ‘AV_CODEC_ID_NONE’
#17 697.5   142 | #define AV_CODEC_ID_NONE CODEC_ID_NONE
#17 697.5       |                          ^~~~~~~~~~~~~
#17 697.5 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp: In function ‘void cv_ff_codec_tag_dump(const AVCodecTag* const*)’:
#17 697.5 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:142:26: error: ‘CODEC_ID_NONE’ was not declared in this scope; did you mean ‘AV_CODEC_ID_NONE’?
#17 697.5   142 | #define AV_CODEC_ID_NONE CODEC_ID_NONE
#17 697.5       |                          ^~~~~~~~~~~~~
#17 697.5 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:142:26: note: in definition of macro ‘AV_CODEC_ID_NONE’
#17 697.5   142 | #define AV_CODEC_ID_NONE CODEC_ID_NONE
#17 697.5       |                          ^~~~~~~~~~~~~
#17 697.6 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvVideoWriter_FFMPEG::open(const char*, int, double, int, int, const cv::VideoWriterParameters&)’:
#17 697.6 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:142:26: error: ‘CODEC_ID_NONE’ was not declared in this scope; did you mean ‘AV_CODEC_ID_NONE’?
#17 697.6   142 | #define AV_CODEC_ID_NONE CODEC_ID_NONE
#17 697.6       |                          ^~~~~~~~~~~~~
#17 697.6 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:142:26: note: in definition of macro ‘AV_CODEC_ID_NONE’
#17 697.6   142 | #define AV_CODEC_ID_NONE CODEC_ID_NONE
#17 697.6       |                          ^~~~~~~~~~~~~
#17 697.6 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2615:28: note: in expansion of macro ‘CV_CODEC’
#17 697.6  2615 |     CV_CODEC_ID codec_id = CV_CODEC(CODEC_ID_NONE);
#17 697.6       |                            ^~~~~~~~
#17 697.6 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:131:28: error: ‘CODEC_ID_JPEGLS’ was not declared in this scope; did you mean ‘AV_CODEC_ID_JPEGLS’?
#17 697.6   131 | #define AV_CODEC_ID_JPEGLS CODEC_ID_JPEGLS
#17 697.6       |                            ^~~~~~~~~~~~~~~
#17 697.6 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:131:28: note: in definition of macro ‘AV_CODEC_ID_JPEGLS’
#17 697.6   131 | #define AV_CODEC_ID_JPEGLS CODEC_ID_JPEGLS
#17 697.6       |                            ^~~~~~~~~~~~~~~
#17 697.6 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2767:10: note: in expansion of macro ‘CV_CODEC’
#17 697.6  2767 |     case CV_CODEC(CODEC_ID_JPEGLS):
#17 697.6       |          ^~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:97:29: error: ‘CODEC_ID_HUFFYUV’ was not declared in this scope; did you mean ‘AV_CODEC_ID_HUFFYUV’?
#17 697.7    97 | #define AV_CODEC_ID_HUFFYUV CODEC_ID_HUFFYUV
#17 697.7       |                             ^~~~~~~~~~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:97:29: note: in definition of macro ‘AV_CODEC_ID_HUFFYUV’
#17 697.7    97 | #define AV_CODEC_ID_HUFFYUV CODEC_ID_HUFFYUV
#17 697.7       |                             ^~~~~~~~~~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2773:10: note: in expansion of macro ‘CV_CODEC’
#17 697.7  2773 |     case CV_CODEC(CODEC_ID_HUFFYUV):
#17 697.7       |          ^~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:106:26: error: ‘CODEC_ID_FFV1’ was not declared in this scope; did you mean ‘AV_CODEC_ID_FFV1’?
#17 697.7   106 | #define AV_CODEC_ID_FFV1 CODEC_ID_FFV1
#17 697.7       |                          ^~~~~~~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:106:26: note: in definition of macro ‘AV_CODEC_ID_FFV1’
#17 697.7   106 | #define AV_CODEC_ID_FFV1 CODEC_ID_FFV1
#17 697.7       |                          ^~~~~~~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2812:10: note: in expansion of macro ‘CV_CODEC’
#17 697.7  2812 |     case CV_CODEC(CODEC_ID_FFV1):
#17 697.7       |          ^~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:95:27: error: ‘CODEC_ID_MJPEG’ was not declared in this scope; did you mean ‘AV_CODEC_ID_MJPEG’?
#17 697.7    95 | #define AV_CODEC_ID_MJPEG CODEC_ID_MJPEG
#17 697.7       |                           ^~~~~~~~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:95:27: note: in definition of macro ‘AV_CODEC_ID_MJPEG’
#17 697.7    95 | #define AV_CODEC_ID_MJPEG CODEC_ID_MJPEG
#17 697.7       |                           ^~~~~~~~~~~~~~
#17 697.7 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2841:10: note: in expansion of macro ‘CV_CODEC’
#17 697.7  2841 |     case CV_CODEC(CODEC_ID_MJPEG):
#17 697.7       |          ^~~~~~~~
#17 697.8 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:96:27: error: ‘CODEC_ID_LJPEG’ was not declared in this scope; did you mean ‘AV_CODEC_ID_LJPEG’?
#17 697.8    96 | #define AV_CODEC_ID_LJPEG CODEC_ID_LJPEG
#17 697.8       |                           ^~~~~~~~~~~~~~
#17 697.8 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:96:27: note: in definition of macro ‘AV_CODEC_ID_LJPEG’
#17 697.8    96 | #define AV_CODEC_ID_LJPEG CODEC_ID_LJPEG
#17 697.8       |                           ^~~~~~~~~~~~~~
#17 697.8 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2842:10: note: in expansion of macro ‘CV_CODEC’
#17 697.8  2842 |     case CV_CODEC(CODEC_ID_LJPEG):
#17 697.8       |          ^~~~~~~~
#17 697.8 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:100:30: error: ‘CODEC_ID_RAWVIDEO’ was not declared in this scope; did you mean ‘AV_CODEC_ID_RAWVIDEO’?
#17 697.8   100 | #define AV_CODEC_ID_RAWVIDEO CODEC_ID_RAWVIDEO
#17 697.8       |                              ^~~~~~~~~~~~~~~~~
#17 697.8 /usr/dev/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:100:30: note: in definition of macro ‘AV_CODEC_ID_RAWVIDEO’
#17 697.8   100 | #define AV_CODEC_ID_RAWVIDEO CODEC_ID_RAWVIDEO
#17 697.8       |                              ^~~~~~~~~~~~~~~~~
#17 697.8 /usr/dev/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2846:10: note: in expansion of macro ‘CV_CODEC’
#17 697.8  2846 |     case CV_CODEC(CODEC_ID_RAWVIDEO):

I have tried OpenCV 4.4.0 and, when checked that issue is apparently with incompatibility between OpenCV and ffmpeg, also with OpenCV 4.6.0. The issue is still the same. Question: which OpenCV+ffmpeg versions are compatible? Cannot see to find this information anywhere. To which OpenCV version I have to upgrade so that it also stays compatible with project that used OpenCV 4.4.0 before? Or should I use older Debian with older ffmpeg? Or build ffmpeg from source? Any solutions are highly welcome.

neither v4.4 nor v4.6 are the latest release.

bug reports cannot be accepted if you “found” an old bug that might already be fixed.

please check with latest release of OpenCV.

make sure that ffmpeg has an appropriate version. latest opencv releases try to track ffmpeg 5. I’m not sure anyone has bothered with ffmpeg 6 since that followed so quickly after ffmpeg 5.