Open
Conversation
优化后的解决方案可在“优云智算”平台上正常部署和运行。
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
In containerized deployment (e.g., Docker on https://www.compshare.cn/), the system attempts to use NVIDIA NVENC (
h264_nvenc) for H.264 video encoding. However, due to permission restrictions,av.CodecContext.create('h264_nvenc')raises anOSError(e.g.,PermissionError: [Errno 1] Operation not permitted).The current exception handling only catches
_AVErrorand_AVCodecError, which do not includeOSErrorin newer versions of PyAV (≥10.0). As a result, the fallback to software encoder (libx264) is never triggered, causing WebRTC video transmission to fail completely.This issue manifests as:
and repeated
/webrtc/offerrequests from the client.Solution
Update the exception handling in
patched_encode_frameto catchOSError,ValueError, and genericExceptionto ensure robust fallback tolibx264when any hardware encoder fails - especially in headless or container environments without NVIDIA NVENC access.This change maintains full backward compatibility while significantly improving deployment reliability.
Changes
Modified
src/handlers/client/rtc_client/client_handler_rtc.py:Replaced narrow exception catch
(_AVError, _AVCodecError)with broader(OSError, ValueError, Exception)Ensures fallback logic is always triggered on encoder creation/encoding failure
Removed reliance on
_AVErroror_AVCodecErrorTesting
libx264