Drop avcodec_close for FFmpeg 8 compatibility#360
Open
baldvin-kovacs wants to merge 1 commit intokasmtech:masterfrom
Open
Drop avcodec_close for FFmpeg 8 compatibility#360baldvin-kovacs wants to merge 1 commit intokasmtech:masterfrom
baldvin-kovacs wants to merge 1 commit intokasmtech:masterfrom
Conversation
avcodec_close() was deprecated in FFmpeg 3.x and removed in FFmpeg 8.0. Its absence makes FFmpeg::FFmpeg()'s D_LOOKUP_SYM throw, which causes the constructor to set available=false and disables the entire hardware video encoding path. KasmVNC then logs: ffmpeg: Failed to load symbol avcodec_close VNCServerST: Hardware video encoding acceleration capability: unavailable avcodec_close was only referenced from one site (common/rfb/benchmark/FfmpegFrameFeeder.cpp's destructor), and that call was redundant: codec_ctx_guard is a unique_ptr whose deleter calls avcodec_free_context, which already releases the codec internally. Remove the dlsym, the typedef, the struct member, and the wrapper, and default the benchmark destructor (the guard handles cleanup). No runtime behavior change on FFmpeg <= 7; restores hardware encode on FFmpeg >= 8.
e182247 to
08343a4
Compare
|
LGTM |
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.
Problem
On systems with FFmpeg 8.0+ (Arch as of late 2025/early 2026, recent
Fedora, etc.), KasmVNC cannot initialize hardware video encoding. The
log shows:
ffmpeg: Failed to load symbol avcodec_close
VNCServerST: Hardware video encoding acceleration capability: unavailable
KasmVNC then silently falls back to its software WebP/JPEG encoders,
which is a major regression for users who configured
videoCodec: h264_vaapi(or similar) and are now paying significant CPU forsomething the hardware was meant to handle.
Root cause
avcodec_close()was deprecated in FFmpeg 3.x (its replacement,avcodec_free_context(), has existed since 2015) and was finallyremoved in FFmpeg 8.0.
FFmpeg::FFmpeg()resolves every libavcodec symbol via theD_LOOKUP_SYMmacro, which throws on any missing symbol. Theconstructor catches the throw and sets
available = false—disabling the entire hardware-encode path. So the missing
avcodec_closesymbol kills hardware encoding wholesale, even thoughthe encode path itself never calls
avcodec_close.Why removing the symbol is safe
grep -rn 'avcodec_close'over the tree shows only one productioncaller: the destructor of
FfmpegFrameFeeder(a benchmarking helperfor
Xvnc_replay_benchmark):