Skip to content

Conversation

@spullara
Copy link

Summary

This PR fixes compilation errors when building decord with FFmpeg 6+. The changes address deprecated API usage and update to the new FFmpeg 6 APIs while maintaining backward compatibility with older FFmpeg versions.

Changes Made

Audio Reader (src/audio/audio_reader.cc)

  • Replace deprecated ->channels with ->ch_layout.nb_channels
  • Replace deprecated ->channel_layout with new AVChannelLayout API
  • Remove deprecated avcodec_close() calls (only avcodec_free_context() is needed)
  • Update InitSWR() to use av_opt_set_chlayout() instead of av_opt_set_channel_layout()

Video Reader (src/video/video_reader.cc)

  • Change AVCodec * to const AVCodec * for av_find_best_stream() compatibility
  • Replace deprecated av_stream_get_side_data() with av_packet_side_data_get()

FFmpeg Common (src/video/ffmpeg/ffmpeg_common.h)

  • Add #include <libavutil/channel_layout.h> for new channel layout API support

Compatibility

All changes are wrapped in version checks (#if LIBAVCODEC_VERSION_MAJOR >= 59) to maintain backward compatibility with FFmpeg 5 and earlier versions.

Testing

Successfully builds with FFmpeg 6+ on macOS with Homebrew-installed FFmpeg.

Related Issues

Fixes compilation errors:

  • no member named 'channels' in 'AVCodecParameters'
  • no member named 'channel_layout' in 'AVCodecContext'
  • use of undeclared identifier 'avcodec_close'
  • no matching function for call to 'av_find_best_stream'
  • use of undeclared identifier 'av_stream_get_side_data'

Pull Request opened by Augment Code with guidance from the PR author

- Replace deprecated ->channels with ->ch_layout.nb_channels
- Replace deprecated ->channel_layout with new AVChannelLayout API
- Remove deprecated avcodec_close() calls (avcodec_free_context() is sufficient)
- Update channel layout functions to use av_opt_set_chlayout()
- Fix av_find_best_stream() to use const AVCodec** for FFmpeg 6+
- Replace deprecated av_stream_get_side_data() with av_packet_side_data_get()
- Add libavutil/channel_layout.h header for new API support
- All changes wrapped in version checks for backward compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant