clangen / musikcube

a cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++
https://musikcube.com
BSD 3-Clause "New" or "Revised" License
4.08k stars 295 forks source link

ffmpeg 7.x incompatibility #685

Open meanjollies opened 2 weeks ago

meanjollies commented 2 weeks ago

It appears there have been a number of API changes with the release of ffmpeg 7.0, some of which are not backward compatible. As a result, musikcube fails to build:

[ 55%] Building CXX object src/plugins/ffmpegdecoder/CMakeFiles/ffmpegdecoder.dir/plugin.cpp.o
[ 56%] Building CXX object src/plugins/ffmpegdecoder/CMakeFiles/ffmpegdecoder.dir/FfmpegDecoder.cpp.o
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp: In member function ‘bool FfmpegDecoder::InitializeResampler()’:
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:270:29: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channel_layout’; did you mean ‘ch_layout’?
  270 |         this->codecContext->channel_layout,
      |                             ^~~~~~~~~~~~~~
      |                             ch_layout
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:273:29: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channel_layout’; did you mean ‘ch_layout’?
  273 |         this->codecContext->channel_layout,
      |                             ^~~~~~~~~~~~~~
      |                             ch_layout
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:268:23: error: ‘swr_alloc_set_opts’ was not declared in this scope; did you mean ‘swr_alloc_set_opts2’?
  268 |     this->resampler = swr_alloc_set_opts(
      |                       ^~~~~~~~~~~~~~~~~~
      |                       swr_alloc_set_opts2
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp: In member function ‘virtual bool FfmpegDecoder::Open(musik::core::sdk::IDataStream*)’:
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:303:13: error: invalid conversion from ‘int (*)(void*, uint8_t*, int)’ {aka ‘int (*)(void*, unsigned char*, int)’} to ‘int (*)(void*, const uint8_t*, int)’ {aka ‘int (*)(void*, const unsigned char*, int)’} [-fpermissive]
  303 |             writeCallback,
      |             ^~~~~~~~~~~~~
      |             |
      |             int (*)(void*, uint8_t*, int) {aka int (*)(void*, unsigned char*, int)}
In file included from /home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.h:43,
                 from /home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:35:
/usr/include/libavformat/avio.h:404:25: note:   initializing argument 6 of ‘AVIOContext* avio_alloc_context(unsigned char*, int, int, void*, int (*)(void*, uint8_t*, int), int (*)(void*, const uint8_t*, int), int64_t (*)(void*, int64_t, int))’
  404 |                   int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size),
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:367:53: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channel_layout’; did you mean ‘ch_layout’?
  367 |                             if (this->codecContext->channel_layout == 0) {
      |                                                     ^~~~~~~~~~~~~~
      |                                                     ch_layout
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:368:53: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channel_layout’; did you mean ‘ch_layout’?
  368 |                                 this->codecContext->channel_layout =
      |                                                     ^~~~~~~~~~~~~~
      |                                                     ch_layout
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:369:87: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channels’
  369 |                                     av_get_default_channel_layout(this->codecContext->channels);
      |                                                                                       ^~~~~~~~
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:369:37: error: ‘av_get_default_channel_layout’ was not declared in this scope
  369 |                                     av_get_default_channel_layout(this->codecContext->channels);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:383:60: error: ‘AVCodecParameters’ {aka ‘struct AVCodecParameters’} has no member named ‘channels’
  383 |                         this->channels = stream->codecpar->channels;
      |                                                            ^~~~~~~~
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp: In member function ‘AVFrame* FfmpegDecoder::AllocFrame(AVFrame*, AVSampleFormat, int, int)’:
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:594:55: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channel_layout’; did you mean ‘ch_layout’?
  594 |         const int channelLayout = this->codecContext->channel_layout == 0
      |                                                       ^~~~~~~~~~~~~~
      |                                                       ch_layout
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:595:65: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channels’
  595 |             ? av_get_default_channel_layout(this->codecContext->channels)
      |                                                                 ^~~~~~~~
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:595:15: error: ‘av_get_default_channel_layout’ was not declared in this scope
  595 |             ? av_get_default_channel_layout(this->codecContext->channels)
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:596:35: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘channel_layout’; did you mean ‘ch_layout’?
  596 |             : this->codecContext->channel_layout;
      |                                   ^~~~~~~~~~~~~~
      |                                   ch_layout
/home/a/musikcube/musikcube-3.0.2/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:598:19: error: ‘AVFrame’ {aka ‘struct AVFrame’} has no member named ‘channel_layout’; did you mean ‘ch_layout’?
  598 |         original->channel_layout = channelLayout;
      |                   ^~~~~~~~~~~~~~
      |                   ch_layout
make[2]: *** [src/plugins/ffmpegdecoder/CMakeFiles/ffmpegdecoder.dir/build.make:90: src/plugins/ffmpegdecoder/CMakeFiles/ffmpegdecoder.dir/FfmpegDecoder.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:867: src/plugins/ffmpegdecoder/CMakeFiles/ffmpegdecoder.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
sudoAlphaX commented 1 week ago

Confirmed. Fails to build using musikcube AUR package with ffmpeg version 7.0.1

maxilla-0 commented 2 days ago

has something happened since then?

sudoAlphaX commented 2 days ago

Nope. No commits since then. I've been trying to fix it myself, but the task is difficult since i haven't done much C development.

Regards

--
sudoAlpha

Sent from my Android device using K-9 Mail

-------- Original Message -------- From: Maxilla @.> Sent: July 4, 2024 1:57:54 PM UTC To: clangen/musikcube @.> Cc: Alpha @.>, Comment @.> Subject: Re: [clangen/musikcube] ffmpeg 7.x incompatibility (Issue #685)

has something happened since then?

-- Reply to this email directly or view it on GitHub: https://github.com/clangen/musikcube/issues/685#issuecomment-2209063628 You are receiving this because you commented.

Message ID: @.***>

clangen commented 2 days ago

Apologies, musikcube development has stalled the past 6 months or so -- real life sometimes takes priority.

This is a particularly bad breakage, so I spent the day working on a fix; I pushed a couple commits to the main branch and it seems to be working across the platforms I've been able to test thus far. My Intel mac machine is extremely old, slow and out of date, but once I can verify it's working in that environment I'll get a new release out.

For now: if you can compile from source pull the latest changes and give it a go.

sudoAlphaX commented 2 days ago

With latest commit 40a26d7, Im able to successfully build musikcube from source, but when running musikcube, it crashes: I forgot to uninstall the version installed from AUR (musikcube-git)

./musikcube: error while loading shared libraries: libmusikcore.so: cannot open shared object file: No such file or directory

Host details: Arch Linux x86_64 6.9.7-zen1-1-zen ffmpeg v7.0.1

sudoAlphaX commented 2 days ago

Musicube works perfectly when built from source. Thank you very much. Commit: 40a26d7

meanjollies commented 1 day ago

I can also confirm musikcube builds and works fine again. @clangen thank you for your work on this, and I hope you've been taking care of yourself.