Compilation error with FFmpeg 6.0

OpenCascade 7.7.0 builds fine for me with ffmpeg-4.4.3, but compilation aborts when trying FFmpeg 6.0:

[ 38% 2291/5992] /usr/bin/c++ -DHAVE_DRACO -DHAVE_FFMPEG -DHAVE_FREEIMAGE -DHAVE_FREETYPE -DHAVE_GLES2_EXT -DHAVE_OPENGL_EXT -DHAVE_RAPIDJSON -DHAVE_TK -DHAVE_VTK -DHAVE_XLIB -DOCC_CONVERT_SIGNALS -DTKService_EXPORTS -DVTK_OPENGL2_BACKEND -I/usr/local/include/tcl8.6 -I/usr/local/include/tk8.6 -I/usr/local/include/freetype2 -I/usr/local/include/vtk-9.2 -I/usr/local/include/draco -I/wrkdirs/usr/ports/cad/opencascade/work/.build/usr/local/include/OpenCASCADE -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -fexceptions -fPIC -Wall -Wextra -Wshorten-64-to-32 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -DNDEBUG -DNo_Exception -fPIC -std=gnu++11 -MD -MT src/TKService/CMakeFiles/TKService.dir/__/Image/Image_VideoRecorder.cxx.o -MF src/TKService/CMakeFiles/TKService.dir/__/Image/Image_VideoRecorder.cxx.o.d -o src/TKService/CMakeFiles/TKService.dir/__/Image/Image_VideoRecorder.cxx.o -c /wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx
FAILED: src/TKService/CMakeFiles/TKService.dir/__/Image/Image_VideoRecorder.cxx.o
/usr/bin/c++ -DHAVE_DRACO -DHAVE_FFMPEG -DHAVE_FREEIMAGE -DHAVE_FREETYPE -DHAVE_GLES2_EXT -DHAVE_OPENGL_EXT -DHAVE_RAPIDJSON -DHAVE_TK -DHAVE_VTK -DHAVE_XLIB -DOCC_CONVERT_SIGNALS -DTKService_EXPORTS -DVTK_OPENGL2_BACKEND -I/usr/local/include/tcl8.6 -I/usr/local/include/tk8.6 -I/usr/local/include/freetype2 -I/usr/local/include/vtk-9.2 -I/usr/local/include/draco -I/wrkdirs/usr/ports/cad/opencascade/work/.build/usr/local/include/OpenCASCADE -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -fexceptions -fPIC -Wall -Wextra -Wshorten-64-to-32 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -DNDEBUG -DNo_Exception -fPIC -std=gnu++11 -MD -MT src/TKService/CMakeFiles/TKService.dir/__/Image/Image_VideoRecorder.cxx.o -MF src/TKService/CMakeFiles/TKService.dir/__/Image/Image_VideoRecorder.cxx.o.d -o src/TKService/CMakeFiles/TKService.dir/__/Image/Image_VideoRecorder.cxx.o -c /wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:82:3: error: use of undeclared identifier 'av_register_all'
av_register_all();
^
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:140:35: error: no member named 'codec' in 'AVStream'
avcodec_close (myVideoStream->codec);
~~~~~~~~~~~~~ ^
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:245:20: error: assigning to 'AVCodec *' from 'const AVCodec *' discards qualifiers
myVideoCodec = avcodec_find_encoder_by_name (theParams.VideoCodec.ToCString());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:250:20: error: assigning to 'AVCodec *' from 'const AVCodec *' discards qualifiers
myVideoCodec = avcodec_find_encoder ((AVCodecID )theDefCodecId);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:268:46: error: no member named 'codec' in 'AVStream'
AVCodecContext* aCodecCtx = myVideoStream->codec;
~~~~~~~~~~~~~ ^
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:300:46: error: no member named 'codec' in 'AVStream'
AVCodecContext* aCodecCtx = myVideoStream->codec;
~~~~~~~~~~~~~ ^
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:440:46: error: no member named 'codec' in 'AVStream'
AVCodecContext* aCodecCtx = myVideoStream->codec;
~~~~~~~~~~~~~ ^
/wrkdirs/usr/ports/cad/opencascade/work/opencascade-7.7.0/src/Image/Image_VideoRecorder.cxx:458:14: error: use of undeclared identifier 'avcodec_encode_video2'
aResAv = avcodec_encode_video2 (aCodecCtx, &aPacket, theToFlush ? NULL : myFrame, &isGotPacket);
^
8 errors generated.

Julio Ramirez's picture

I have the same issue, however I use ffmpeg version 5.1.3.