Fix FFMpeg API compatibility for modern FFMpeg 6.x
This PR resolves issue #78 by updating FFMpegWrapper.cpp to use the modern FFMpeg API, fixing compilation errors with FFMpeg 6.x.
Issues Fixed
The original code used deprecated FFMpeg APIs that were removed in recent versions:
-
av_register_all()removed: This function was deprecated in FFMpeg 4.0 and removed in 5.0+ -
Type mismatch:
avcodec_find_decoder()now returnsconst AVCodec *instead ofAVCodec * -
Channel API changes:
channelsfield replaced withch_layout.nb_channelsin bothAVCodecParametersandAVFrame -
Channel layout functions:
av_get_default_channel_layout()deprecated in favor ofav_channel_layout_default()
Changes Made
-
Removed deprecated registration: Replaced
av_register_all()call with explanatory comment (auto-registration since FFMpeg 4.0) -
Fixed decoder type: Changed
AVCodec *decodertoconst AVCodec *decoder -
Updated channel access: Replaced all instances of
->channelswith->ch_layout.nb_channels -
Modernized channel layout setup:
- Replaced
channel_layoutfield checks withch_layoutequivalents - Updated from
av_get_default_channel_layout()toav_channel_layout_default() - Changed SWR context setup from
av_opt_set_int()with*_channel_layouttoav_opt_set_chlayout()with*_chlayout
- Replaced
-
Added required header: Included
<libavutil/channel_layout.h>for new channel layout API
Testing
- Successfully compiles with FFMpeg 6.1.1 (libavcodec 60.31.102)
- All changes maintain existing functionality while using the modern API
- Built and tested
anmp-dumpbinary executes correctly
Backward Compatibility
These changes target FFMpeg 4.0+ API. The new channel layout API was introduced in FFMpeg 5.1, but the other changes (removing av_register_all(), const correctness) are compatible with FFMpeg 4.0+.
Closes #78
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.