ffmpegthumbnailer icon indicating copy to clipboard operation
ffmpegthumbnailer copied to clipboard

ffmpegthumbnailer 2.2.2 no longer builds with ffmpeg 5.0

Open frankspace opened this issue 4 years ago • 4 comments

Attempting to compile with ffmpeg 5.0 fails with the following:

[ 44%] Building CXX object CMakeFiles/libffmpegthumbnailerobj.dir/libffmpegthumbnailer/videothumbnailer.cpp.o
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp: In member function ‘void ffmpegthumbnailer::MovieDecoder::initialize(const string&, bool)’:
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:73:5: error: ‘av_register_all’ was not declared in this scope
   73 |     av_register_all();
      |     ^~~~~~~~~~~~~~~
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:74:5: error: ‘avcodec_register_all’ was not declared in this scope
   74 |     avcodec_register_all();
      |     ^~~~~~~~~~~~~~~~~~~~
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp: In member function ‘int32_t ffmpegthumbnailer::MovieDecoder::findPreferedVideoStream(bool)’:
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:155:50: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
  155 |         auto ctx = m_pFormatContext->streams[i]->codec;
      |                                                  ^~~~~
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp: In member function ‘void ffmpegthumbnailer::MovieDecoder::initializeVideo(bool)’:
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:206:44: error: ‘struct AVStream’ has no member named ‘codec’
  206 |     m_pVideoCodecContext = m_pVideoStream->codec;
      |                                            ^~~~~
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:207:41: error: invalid conversion from ‘const AVCodec*’ to ‘AVCodec*’ [-fpermissive]
  207 |     m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
      |                     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                         |
      |                                         const AVCodec*
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp: In member function ‘void ffmpegthumbnailer::MovieDecoder::initializeFilterGraph(const AVRational&, const string&, bool)’:
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:392:99: warning: ‘AVBufferSinkParams* av_buffersink_params_alloc()’ is deprecated [-Wdeprecated-declarations]
  392 |     std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
      |                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:32:
/usr/include/libavfilter/buffersink.h:112:21: note: declared here
  112 | AVBufferSinkParams *av_buffersink_params_alloc(void);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:394:5: error: ‘avfilter_register_all’ was not declared in this scope
  394 |     avfilter_register_all();
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp: In member function ‘void ffmpegthumbnailer::MovieDecoder::seek(int)’:
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:503:69: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
  503 |     avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
      |                                                                     ^~~~~
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp: In member function ‘bool ffmpegthumbnailer::MovieDecoder::decodeVideoPacket()’:
/home/frank/tmp/src/ffmpegthumbnailer-2.2.2/libffmpegthumbnailer/moviedecoder.cpp:559:24: error: ‘avcodec_decode_video2’ was not declared in this scope; did you mean ‘avcodec_decode_subtitle2’?
  559 |     int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
      |                        ^~~~~~~~~~~~~~~~~~~~~
      |                        avcodec_decode_subtitle2
make[2]: *** [CMakeFiles/libffmpegthumbnailerobj.dir/build.make:76: CMakeFiles/libffmpegthumbnailerobj.dir/libffmpegthumbnailer/moviedecoder.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:107: CMakeFiles/libffmpegthumbnailerobj.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

It appears that av_register_all, avcodec_register_all, and avfilter_register_all have been deprecated since 2018, and I infer that avcodec_decode_video2 has also been deprecated for some time. Presumably, those have now been removed entirely.

Edit: found the blog post discussing removal of deprecated APIs.

frankspace avatar Jan 25 '22 15:01 frankspace

In an effort to help, insofar as my very limited powers allow, I also eventually found this, from which I deduce the following:

It appears that av_register_all and avcodec_register_all simply aren't used anymore. They're unnecessary and can just be deleted. I can't find any good information about avfilter_register_all, but I presume it's the same. So I would further presume that avfilter_register_all();, av_register_all();, and avcodec_register_all(); can simply be blindly deleted from moviedecoder.cpp. (Removing them and attempting to compile again doesn't result in any particular error messages that weren't present previously, but it doesn't solve the other issues.)

The next apparent issue is, "AVStream.codec removed; stream information is now exported through AVStream.codecpar; for decoding/encoding the users should allocate a separate codec context." I don't have the vaguest idea what this means, and I don't seem to be alone in this, but perhaps this discussion is enlightening. It isn't to me, but I'm not a programmer.

Similarly, "old audio/video decoding APIs avcodec_decode_video2 and avcodec_decode_audio4 were removed; they are replaced by avcodec_send_packet/avcodec_receive_frame, which decouple input and output and can return any number of output frames for a single input packet." I can't help there, but presumably the error message's suggestion of "avcodec_decode_subtitle2" is wrong.

I also found this and this, which hopefully are of some help. Thank you!

frankspace avatar Jan 26 '22 13:01 frankspace

...okay, I'm an idiot, it turns out it's the latest release version that doesn't compile with ffmpeg 5.0; the current git version does. May I therefore respectfully request a version bump?

frankspace avatar Jan 26 '22 17:01 frankspace