Build error when compiling against ffmpeg-5

We received a compile time failure[1] on Gentoo Linux, when trying to build opencascade with ffmpeg-5 installed. The report was for v7.6.0. While I was packaging v7.6.1, I noticed the issue also show up for this version.

The error (for v7.6.1) is:

FAILED: src/TKService/CMakeFiles/TKService.dir/__/Media/Media_FormatContext.cxx.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -DHAVE_FFMPEG -DHAVE_FREETYPE -DHAVE_OPENGL_EXT -DHAVE_TK -DHAVE_XLIB -DOCC_CONVERT_SIGNALS -DTKService_EXPORTS -I/usr/include/freetype2 -I/var/tmp/portage-ondisk/portage/sci-libs/opencascade-7.6.1/work/occt-V7_6_1_build/include/opencascade  -std=c++0x -O2 -pipe -march=znver2 -frecord-gcc-switches -fstack-protector-strong -fstack-check -fexceptions -fPIC -Wall -Wextra -fPIC -MD -MT src/TKService/CMakeFiles/TKService.dir/__/Media/Media_FormatContext.cxx.o -MF src/TKService/CMakeFiles/TKService.dir/__/Media/Media_FormatContext.cxx.o.d -o src/TKService/CMakeFiles/TKService.dir/__/Media/Media_FormatContext.cxx.o -c /var/tmp/portage-ondisk/portage/sci-libs/opencascade-7.6.1/work/occt-V7_6_1/src/Media/Media_FormatContext.cxx
/var/tmp/portage-ondisk/portage/sci-libs/opencascade-7.6.1/work/occt-V7_6_1/src/Media/Media_FormatContext.cxx: In member function ‘TCollection_AsciiString Media_FormatContext::StreamInfo(unsigned int, AVCodecContext*) const’:
/var/tmp/portage-ondisk/portage/sci-libs/opencascade-7.6.1/work/occt-V7_6_1/src/Media/Media_FormatContext.cxx:413:25: error: ‘const AVStream’ {aka ‘const struct AVStream’} has no member named ‘codec’
  413 |     aCodecCtx = aStream.codec;

followed by more error messages, which you can see in the attached build log of the original report.

[1] https://bugs.gentoo.org/834422