fix -Wcast-user-defined warning#3103
Conversation
|
Specifically I get warnings/errors that ch_layouts is deprecated, in dlib/media/ffmpeg_muxer.h |
|
You'll need to submit an issue with a reproducible example for me to diagnose that. To be honest i think we should drop support for the older FFMpeg libs now. |
|
I get a lot of deprecation warnings on Arch Linux with FFmpeg 7.1.1, the $ cd examples
$ cmake -G Ninja -B build
...
-- Searching for FFMPEG/LIBAV
-- Checking for modules 'libavdevice;libavfilter;libavformat;libavcodec;libswresample;libswscale;libavutil'
-- Found libavdevice, version 61.3.100
-- Found libavfilter, version 10.4.100
-- Found libavformat, version 61.7.100
-- Found libavcodec, version 61.19.101
-- Found libswresample, version 5.3.100
-- Found libswscale, version 8.3.100
-- Found libavutil, version 59.39.100
-- Found FFMPEG/LIBAV via pkg-config in `/usr/lib`
...
$ ninja -C build ffmpeg_webcam_face_pose_ex
...
dlib/media/ffmpeg_muxer.h:814:80: warning: ‘AVCodec::ch_layouts’ is deprecated [-Wdeprecated-declarations]
814 | av_channel_layout_copy(&pCodecCtx->ch_layout, &pCodec->ch_layouts[0]);
| ^~~~~~~~~~
... |
|
Maybe the easiest thing to do is drop support for older versions. I'll have a look later though |
|
I'm willing to bet it's because the following isn't working as expected with all versions of ffmpeg |
|
Oh i see the problem. Yeah, I fixed this in my own repo ages ago. Sorry. I can submit a PR at some point. FFmpeg is quite annoying at constantly changing APIs. In my own private repos i only ever support the latest version since i always build from source direct from cmake (using ExternalProject_Add) |
|
Thanks for the PR, it's a reasonable way to avoid that warning :) |
|
I've started #3105 for ffmpeg 7 warnings |
Co-authored-by: ribbon-otter <ribbon-otter@github.invalid>
The tests compile and run mostly. I get deprecated warnings for something in ffmpeg which can an error on one of the final tests. I am not enough of an expert at cmake to understand why only some of the files are compiled with -Werror.
Please look carefully at this pull request as I turned something that was
constinto non-const. I am not convinced it is correct. Though the c-style cast was likely modifying aconstvariable through a non-constreference anyway.static_castdid not work.I am planning on adding a flag to the
CMakelist.txttest file that lets me turn off-Werrorso I can at least fully test changes before submitting them. Particularly while I am patching away warnings like this.