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

Fails to build with ffmpeg 5.0 #1111

Open
berolinux opened this issue Jan 16, 2022 · 8 comments
Open

Fails to build with ffmpeg 5.0 #1111

berolinux opened this issue Jan 16, 2022 · 8 comments

Comments

@berolinux
Copy link

OpenSceneGraph doesn't build with the recently released ffmpeg 5.0 - main problems are the use of the removed AVPicture API, attempts to access the "codec" member of an AVStream, and the use of avcodec_decode_video2.

@psi29a
Copy link

psi29a commented Aug 4, 2022

CMakeFiles/osgdb_ffmpeg.dir/FFmpegDecoderAudio.cpp.o -c /<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
In file included from /<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.hpp:10,
                 from /<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:1:
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegPacket.hpp: In member function ‘void osgFFmpeg::FFmpegPacket::clear()’:
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegPacket.hpp:45:17: error: ‘av_free_packet’ was not declared in this scope; did you mean ‘av_new_packet’?
   45 |                 av_free_packet(&packet);
      |                 ^~~~~~~~~~~~~~
      |                 av_new_packet
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp: In function ‘int osgFFmpeg::decode_audio(AVCodecContext*, int16_t*, int*, const uint8_t*, int, SwrContext*, int, int, AVSampleFormat)’:
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:48:11: error: ‘avcodec_decode_audio4’ was not declared in this scope; did you mean ‘avcodec_decode_subtitle2’?
   48 |     ret = avcodec_decode_audio4(avctx, frame, &got_frame, &avpkt);
      |           ^~~~~~~~~~~~~~~~~~~~~
      |           avcodec_decode_subtitle2
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:53:34: error: ‘av_frame_get_channels’ was not declared in this scope; did you mean ‘av_frame_get_buffer’?
   53 |     if (ret >= 0 && got_frame && av_frame_get_channels(frame)>0) {
      |                                  ^~~~~~~~~~~~~~~~~~~~~
      |                                  av_frame_get_buffer
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp: In member function ‘void osgFFmpeg::FFmpegDecoderAudio::open(AVStream*, osgFFmpeg::FFmpegParameters*)’:
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:154:29: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
  154 |         m_context = stream->codec;
      |                             ^~~~~
/<<PKGBUILDDIR>>/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:217:55: error: invalid conversion from ‘const AVCodec*’ to ‘AVCodec*’ [-fpermissive]
  217 |         AVCodec * const p_codec = avcodec_find_decoder(m_context->codec_id);
      |                                   ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                                                       |
      |                                                       const AVCodec*
make[3]: *** [src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/build.make:93: src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/FFmpegDecoderAudio.cpp.o] Error 1
make[3]: Leaving directory '/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu'
make[2]: *** [CMakeFiles/Makefile2:7868: src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....

Already a problem for the upcoming Ubuntu Kinetic

@mapreri
Copy link

mapreri commented Aug 29, 2022

this is also a problem for the upcoming Debian 12 (bookworm), where it has already been removed.

@aluaces
Copy link
Contributor

aluaces commented Sep 21, 2022

There is some progress, at least from the audio part in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004634#41 in case someone is able to continue from there.

@h-vetinari
Copy link

This issue is starting to become really painful for our maintenance in conda-forge. Almost all other packages have moved on to ffmpeg 5 or even 6, and now several packages are stuck on this.

@spillner
Copy link

I was able to get OpenSceneGraph 3.6.5 to build against ffmpeg-5.1.4 using the attached, in addition to Paul Liu's audio patch from the Debian bug thread linked in #1111 (comment). I haven't stress-tested it, but at least it's a start.

OpenSceneGraph-use-ffmpeg-5.0-patch.txt

@h-vetinari
Copy link

h-vetinari commented Nov 26, 2023

Awesome @spillner! Tried the patch in conda-forge/openscenegraph-feedstock#34, linux compiles fine (haven't tested it with downstream dependencies of course, though we could arrange that). However, it fails compilation on osx:

[ 57%] Linking CXX shared module ../../../lib/osgPlugins-3.6.5/osgdb_ffmpeg.so
ld: warning: -pie being ignored. It is only used when linking a main executable
Undefined symbols for architecture x86_64:
  "av_image_fill_arrays(unsigned char**, int*, unsigned char const*, AVPixelFormat, int, int, int)", referenced from:
      osgFFmpeg::FFmpegDecoderVideo::open(AVStream*) in FFmpegDecoderVideo.cpp.o
      osgFFmpeg::FFmpegDecoderVideo::publishFrame(double, bool) in FFmpegDecoderVideo.cpp.o
  "av_image_get_buffer_size(AVPixelFormat, int, int, int)", referenced from:
      osgFFmpeg::FFmpegDecoderVideo::open(AVStream*) in FFmpegDecoderVideo.cpp.o
ld: symbol(s) not found for architecture x86_64

and similarly on windows:

[ 81%] Linking CXX shared module osgdb_ffmpeg.dll
LINK: command "C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\link.exe /nologo @CMakeFiles\osgdb_ffmpeg.dir\objects1.rsp /out:osgdb_ffmpeg.dll /implib:osgdb_ffmpeg.lib /pdb:%SRC_DIR%\build\src\osgPlugins\ffmpeg\osgdb_ffmpeg.pdb /dll /version:0.0 /OPT:NOREF /machine:x64 /INCREMENTAL:NO ..\..\osgDB\osgDB.lib ..\..\osgUtil\osgUtil.lib %PREFIX%\Library\lib\avformat.lib %PREFIX%\Library\lib\avdevice.lib %PREFIX%\Library\lib\avcodec.lib %PREFIX%\Library\lib\avutil.lib %PREFIX%\Library\lib\swscale.lib %PREFIX%\Library\lib\swresample.lib opengl32.lib ..\..\osg\osg.lib ..\..\OpenThreads\win32\OpenThreads.lib %PREFIX%\Library\lib\z.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
FFmpegDecoderVideo.cpp.obj : error LNK2019: unresolved external symbol "int __cdecl av_image_fill_arrays(unsigned char * * const,int * const,unsigned char const *,enum AVPixelFormat,int,int,int)" (?av_image_fill_arrays@@YAHQEAPEAEQEAHPEBEW4AVPixelFormat@@HHH@Z) referenced in function "public: void __cdecl osgFFmpeg::FFmpegDecoderVideo::open(struct AVStream *)" (?open@FFmpegDecoderVideo@osgFFmpeg@@QEAAXPEAUAVStream@@@Z)
FFmpegDecoderVideo.cpp.obj : error LNK2019: unresolved external symbol "int __cdecl av_image_get_buffer_size(enum AVPixelFormat,int,int,int)" (?av_image_get_buffer_size@@YAHW4AVPixelFormat@@HHH@Z) referenced in function "public: void __cdecl osgFFmpeg::FFmpegDecoderVideo::open(struct AVStream *)" (?open@FFmpegDecoderVideo@osgFFmpeg@@QEAAXPEAUAVStream@@@Z)
osgdb_ffmpeg.dll : fatal error LNK1120: 2 unresolved externals

@spillner
Copy link

Strange that they're linker failures, not compilation failures, as you might expect if the argument types don't quite match up. Can you tell me which compiler and version of ffmpeg you're using on OS X and Windows, and can you confirm that other programs using ffmpeg link correctly in the same environment?

@h-vetinari
Copy link

Can you tell me which compiler and version of ffmpeg you're using on OS X and Windows

All builds were using ffmpeg 5.1.2, which is the last one we've built from the 5.1.x series (if necessary, we can build 5.1.4 of course).

can you confirm that other programs using ffmpeg link correctly in the same environment?

We've had no problems with those builds while ~all of conda-forge was being built against 5.1.x (though in the meantime we've moved on to ffmpeg 6.1; osg is one of the very few exceptions that hasn't been able to follow suit).

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

No branches or pull requests

6 participants