econsysqtcam / qtcam

QtCAM is a free, Open Source Linux Webcamera Software with more than 10 image control settings, extension settings and Color space switching.
http://www.e-consystems.com/opensource-linux-webcam-software-application.asp
GNU General Public License v3.0
185 stars 95 forks source link

cannot compile with FFmpeg v7 #57

Open SingingBush opened 3 weeks ago

SingingBush commented 3 weeks ago

While doing my PR for #56 I found that the project will not compile on the recently released Fedora 41 due to the newer version of FFmpeg having removed fields that were previously deprecated. This is likely to be an issue for other distros such as Arch and Opensuse.

videoencoder.cpp:908:8: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channels'
  908 |     c->channels    = channels;
      |        ^~~~~~~~
videoencoder.cpp:909:12: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channels'
  909 |     if (c->channels < 2)
      |            ^~~~~~~~
videoencoder.cpp:910:12: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channel_layout'; did you mean 'ch_layout'?
  910 |         c->channel_layout = AV_CH_LAYOUT_MONO;
      |            ^~~~~~~~~~~~~~
      |            ch_layout
videoencoder.cpp:912:12: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channel_layout'; did you mean 'ch_layout'?
  912 |         c->channel_layout = AV_CH_LAYOUT_STEREO;
      |            ^~~~~~~~~~~~~~
      |            ch_layout
videoencoder.cpp: In member function 'int VideoEncoder::open_audio(AVStream*)':
videoencoder.cpp:989:18: error: 'AVFrame' {aka 'struct AVFrame'} has no member named 'channels'
  989 |     pAudioFrame->channels       = pAudioCodecCtx->channels;
      |                  ^~~~~~~~
videoencoder.cpp:989:51: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channels'
  989 |     pAudioFrame->channels       = pAudioCodecCtx->channels;
      |                                                   ^~~~~~~~
videoencoder.cpp: In member function 'int VideoEncoder::encodeAudio(void*)':
videoencoder.cpp:1016:71: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channels'
 1016 |     int bufferSize = av_samples_get_buffer_size(NULL, pAudioCodecCtx->channels, pAudioCodecCtx->frame_size,
      |                                                                       ^~~~~~~~
videoencoder.cpp:1022:29: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channels'
 1022 |             pAudioCodecCtx->channels, pAudioCodecCtx->sample_fmt);
      |                             ^~~~~~~~
videoencoder.cpp:1027:65: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channels'
 1027 |     ret = avcodec_fill_audio_frame(pAudioFrame, pAudioCodecCtx->channels, pAudioCodecCtx->sample_fmt,
      |                                                                 ^~~~~~~~
videoencoder.cpp:1034:29: error: 'AVCodecContext' {aka 'struct AVCodecContext'} has no member named 'channels'
 1034 |             pAudioCodecCtx->channels, pAudioCodecCtx->sample_fmt);
      |                             ^~~~~~~~

I don't mind doing some work on this but my existing PR should probably get merged first.

SingingBush commented 3 weeks ago

worth noting that according to the readme Ubuntu 18.04 is the min-supported os. 18.04 shipped with libavcodec57 so where there are version checks for LIBAVCODEC_VER_AT_LEAST then it's only worth checking above version 57.

It's worth considering dropping support for v57 altogether and just use code for 58 and above (61 is the current latest in FFmpeg source)