Skip to content

Fix build with FFmpeg >=7 and Qt6#7

Open
Kreijstal wants to merge 2 commits into
cheina97:mainfrom
Kreijstal:fix/qt6-ffmpeg7-build
Open

Fix build with FFmpeg >=7 and Qt6#7
Kreijstal wants to merge 2 commits into
cheina97:mainfrom
Kreijstal:fix/qt6-ffmpeg7-build

Conversation

@Kreijstal

Copy link
Copy Markdown

What

The project no longer compiles against current FFmpeg (the channel-layout API was deprecated in 5.1 and removed in 7.0) or Qt6. This ports the affected code with no behavioural change.

FFmpeg channel-layout API (removed in 7.0)

  • AVCodecContext/AVFrame channels + channel_layout → the ch_layout (AVChannelLayout) API: av_channel_layout_default() / av_channel_layout_copy() and ch_layout.nb_channels.
  • swr_alloc_set_opts()swr_alloc_set_opts2().
  • Add the now-required #include "libavutil/channel_layout.h".

FFmpeg const-correctness (>=5.0)

av_find_input_format(), avcodec_find_encoder/decoder() and av_guess_format() return const pointers now, so the matching members/locals are made const (no -fpermissive needed).

Qt6

  • AreaSelectorButtons.h: add #include <QObject> — Qt6 dropped the transitive include, leaving QObject incomplete.
  • mainwindow.cpp: QAudioDeviceInfo was removed in Qt6. Drop it and use the existing getAudioDevices() helper on Windows as well — it returns the DirectShow friendly names FFmpeg's dshow input expects, so this also unifies the Windows/Linux device-enumeration paths.

Testing

Built and run on Windows (MSYS2 UCRT64, gcc 16, Qt 6.11, FFmpeg 8.1). The GUI launches and a fullscreen capture produces a valid H.264 MP4 (ffprobe: h264, 1280x720).

Note: these are source-only changes. On Windows the bundled import libs under lib/ are still FFmpeg 4.x — building against FFmpeg ≥7 requires pointing at a matching 7.x/8.x SDK (e.g. system FFmpeg on MSYS2). Toolchains using their system FFmpeg pick this up directly.

🤖 Generated with Claude Code

elektrischrainbow-crypto and others added 2 commits June 25, 2026 12:13
The project no longer compiled against current FFmpeg (>=5.1, hard break
in 7.0) or Qt6. This ports the affected code without changing behaviour:

FFmpeg channel-layout API (removed in 7.0):
- AVCodecContext/AVFrame `channels` + `channel_layout` -> `ch_layout`
  (AVChannelLayout) via av_channel_layout_default / _copy and
  `ch_layout.nb_channels`.
- swr_alloc_set_opts() -> swr_alloc_set_opts2().
- Explicitly include libavutil/channel_layout.h.

FFmpeg const-correctness (>=5.0): av_find_input_format(),
avcodec_find_encoder/decoder() and av_guess_format() now return const
pointers, so the matching variables/members are const.

Qt6:
- AreaSelectorButtons.h: include <QObject> (Qt6 dropped the transitive
  include, leaving QObject incomplete).
- mainwindow.cpp: QAudioDeviceInfo was removed in Qt6. Drop it and use
  the existing getAudioDevices() helper on Windows too (it returns the
  DirectShow friendly names FFmpeg's dshow input expects), unifying the
  Windows/Linux device-enumeration paths.

Built and verified on Windows (MSYS2 UCRT64, gcc, Qt 6.11, FFmpeg 8.1):
the GUI launches and a fullscreen capture produces a valid H.264 MP4.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FvcKkm5iURHmwqtyjDTC5Z
Upstream always captured the primary screen: Fullscreen used
primaryScreen(), the AreaSelector overlay sized itself to the primary
screen, and screen_number was hardcoded to 0 — so on a multi-monitor
setup there was no way to record a secondary display.

Add a "Select monitor" combobox (populated from QGuiApplication::
screens()) on the Basic tab. The chosen QScreen drives:
- Fullscreen capture size + offset (screen->geometry()).
- The AreaSelector overlay, via a new setScreen(): the overlay now opens
  on the selected monitor instead of always the primary one.
- Capture offsets in alignValues(): area coordinates are local to the
  overlay's screen, so the screen origin is added, making gdigrab/x11grab
  "desktop" offsets land on the chosen monitor.

Built and run on Windows (MSYS2 UCRT64, Qt 6.11, FFmpeg 8.1): the picker
appears and fullscreen capture still produces a valid H.264 MP4. Multi-
monitor routing follows from screen->geometry() but was exercised on a
single-display test host.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FvcKkm5iURHmwqtyjDTC5Z
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.

2 participants