ANMP icon indicating copy to clipboard operation
ANMP copied to clipboard

Fix FFMpeg API compatibility for modern FFMpeg 6.x

Open Copilot opened this issue 6 months ago • 0 comments

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:

  1. av_register_all() removed: This function was deprecated in FFMpeg 4.0 and removed in 5.0+
  2. Type mismatch: avcodec_find_decoder() now returns const AVCodec * instead of AVCodec *
  3. Channel API changes: channels field replaced with ch_layout.nb_channels in both AVCodecParameters and AVFrame
  4. Channel layout functions: av_get_default_channel_layout() deprecated in favor of av_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 *decoder to const AVCodec *decoder
  • Updated channel access: Replaced all instances of ->channels with ->ch_layout.nb_channels
  • Modernized channel layout setup:
    • Replaced channel_layout field checks with ch_layout equivalents
    • Updated from av_get_default_channel_layout() to av_channel_layout_default()
    • Changed SWR context setup from av_opt_set_int() with *_channel_layout to av_opt_set_chlayout() with *_chlayout
  • 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-dump binary 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:


💡 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.

Copilot avatar Aug 30 '25 19:08 Copilot