CNA-BUG-186: CNA_ENABLE_VIDEO=AUTO accepts any pkg-config FFmpeg, but VideoDecoder.cpp needs the FFmpeg 5.1 channel-layout API
Evidence basis: source-verified at the pinned commit; inferred from the source (the behaviour was not run); tests exist (not executed for this page). Claims on this page were checked by reading the CNA source at commit 009d40f5; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.
The FFmpeg probe states no minimum version while VideoDecoder.cpp uses AVCodecContext::ch_layout and swr_alloc_set_opts2, so a host with older FFmpeg development packages enables video at configure time and then fails to compile.
- Identifier
CNA-BUG-186- Category
- Bug
- Subsystem
- Build & CI
- Status
- Open
- Verified against
- CNA
009d40f5(009d40f5dd085c4e674d3479675fac84b12b3e0a) - Severity
- Low (a triage suggestion, not a project priority)
- Evidence basis
- Inferred (strong): follows from the code, but the behaviour was not run
- Tests touching this area
- Yes: see Current tests
- Affected contract
- CMake option CNA_ENABLE_VIDEO (AUTO, the default, and ON) and the cna_video_ffmpeg target
Expected behaviour
modules/CMakeLists.txt documents AUTO as “use FFmpeg only when all required pkg-config modules are present” and ON as reporting an unsupported configuration immediately. Both rely on the probe telling a usable FFmpeg from an unusable one, so an FFmpeg too old for the sources should make AUTO fall back and ON fail at configure time with a clear message.
Actual behaviour at TARGET
modules/CMakeLists.txt calls pkg_check_modules for the four libraries without a version constraint. VideoDecoder.cpp reads AVCodecContext::ch_layout and builds its resampler with swr_alloc_set_opts2, both part of the channel-layout API introduced with FFmpeg 5.1, with no LIBAVCODEC_VERSION_INT fallback. On a host whose pkg-config finds FFmpeg 4.x development packages (still the packaged version on older LTS distributions), AUTO sets CNA_FFMPEG_AVAILABLE and the build then fails compiling cna_video_ffmpeg instead of falling back to the no-video backend. No CNA document names a minimum FFmpeg version, and every CI lane that installs FFmpeg uses a recent one (ubuntu-24.04 runners, Homebrew on macOS).
Source locations
modules/CMakeLists.txt— the CNA_ENABLE_VIDEO probe: pkg_check_modules without versionsmodules/video-ffmpeg/src/VideoDecoder.cpp— VideoDecoder::Open and OpenAudioStreamByIndex (ch_layout); the resampler setup (swr_alloc_set_opts2)modules/video-ffmpeg/CMakeLists.txt— cna_video_ffmpeg links the PkgConfig imported targets.github/workflows/general-tests-ci.yml— ubuntu-24.04 runner with the distribution's FFmpeg packages
Evidence
Checked by reading at 009d40f5; not tried against an old FFmpeg. The API ages are FFmpeg's (the AVChannelLayout fields and swr_alloc_set_opts2 arrived in 5.1); a compile failure with FFmpeg 4.x follows from the missing declarations but was not observed.
Focused reproduction
Not run. On a host with FFmpeg 4.x development packages: cmake -S . -B build reports “video enabled (AUTO; FFmpeg backend cna_video_ffmpeg)”, and cmake --build build fails in VideoDecoder.cpp on ch_layout and swr_alloc_set_opts2.
Current tests
No configure test covers the FFmpeg probe's version handling; the video tests run only where a recent FFmpeg is installed.
Regression test
Add version floors to the probe (for example libswresample>=4.5 and the matching libavcodec release) or a check_symbol_exists(swr_alloc_set_opts2 ...), and a script-mode CMake test that feeds a fake old .pc file and expects AUTO to fall back and ON to fail.
Blast radius
Default (AUTO) builds on hosts with FFmpeg older than 5.1 installed; they fail instead of building without video. Hosts without FFmpeg, and Windows, Emscripten, Android and iOS (where the probe is skipped), are unaffected.
Workaround
Configure with -DCNA_ENABLE_VIDEO=OFF, or install FFmpeg 5.1 or newer.
Related pages
The same subject is explained at several altitudes. These are the neighbouring pages at each one.
- User guide
- Video playback: FFmpeg setup · Building: CMake options
- Known issues
- Bug index