Fix build with FFmpeg >=7 and Qt6#7
Open
Kreijstal wants to merge 2 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/AVFramechannels+channel_layout→ thech_layout(AVChannelLayout) API:av_channel_layout_default()/av_channel_layout_copy()andch_layout.nb_channels.swr_alloc_set_opts()→swr_alloc_set_opts2().#include "libavutil/channel_layout.h".FFmpeg const-correctness (>=5.0)
av_find_input_format(),avcodec_find_encoder/decoder()andav_guess_format()returnconstpointers now, so the matching members/locals are madeconst(no-fpermissiveneeded).Qt6
AreaSelectorButtons.h: add#include <QObject>— Qt6 dropped the transitive include, leavingQObjectincomplete.mainwindow.cpp:QAudioDeviceInfowas removed in Qt6. Drop it and use the existinggetAudioDevices()helper on Windows as well — it returns the DirectShow friendly names FFmpeg'sdshowinput 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).🤖 Generated with Claude Code