{"record":{"id":"4a8304ad8a292fcc","repo":"rustdesk/rustdesk","slug":"don-t-support-h264","errorCode":null,"errorMessage":"don't support h264!","messagePattern":"don't support h264!","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"libs/scrap/src/common/codec.rs","lineNumber":673,"sourceCode":"                if let Some(av1) = &mut self.av1 {\n                    Decoder::handle_av1s_video_frame(av1, av1s, rgb, chroma)\n                } else {\n                    bail!(\"av1 decoder not available\");\n                }\n            }\n            #[cfg(any(feature = \"hwcodec\", feature = \"vram\"))]\n            video_frame::Union::H264s(h264s) => {\n                *chroma = Some(Chroma::I420);\n                #[cfg(feature = \"vram\")]\n                if let Some(decoder) = &mut self.h264_vram {\n                    *_pixelbuffer = false;\n                    return Decoder::handle_vram_video_frame(decoder, h264s, _texture);\n                }\n                #[cfg(feature = \"hwcodec\")]\n                if let Some(decoder) = &mut self.h264_ram {\n                    return Decoder::handle_hwram_video_frame(decoder, h264s, rgb, &mut self.i420);\n                }\n                Err(anyhow!(\"don't support h264!\"))\n            }\n            #[cfg(any(feature = \"hwcodec\", feature = \"vram\"))]\n            video_frame::Union::H265s(h265s) => {\n                *chroma = Some(Chroma::I420);\n                #[cfg(feature = \"vram\")]\n                if let Some(decoder) = &mut self.h265_vram {\n                    *_pixelbuffer = false;\n                    return Decoder::handle_vram_video_frame(decoder, h265s, _texture);\n                }\n                #[cfg(feature = \"hwcodec\")]\n                if let Some(decoder) = &mut self.h265_ram {\n                    return Decoder::handle_hwram_video_frame(decoder, h265s, rgb, &mut self.i420);\n                }\n                Err(anyhow!(\"don't support h265!\"))\n            }\n            #[cfg(feature = \"mediacodec\")]\n            video_frame::Union::H264s(h264s) => {\n                *chroma = Some(Chroma::I420);","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/7aa98d43cf1962a7a29ec16ffef42974377ef11e/libs/scrap/src/common/codec.rs#L655-L691","documentation":"Decoder::decode_video_frame in libs/scrap/src/common/codec.rs matched an incoming video_frame::Union::H264s message, but neither the vram decoder (self.h264_vram, feature vram) nor the hwcodec RAM decoder (self.h264_ram, feature hwcodec) is present. The H264 arm only exists when one of those cargo features is compiled in, and it still errors when the decoder slots are None — i.e. the build has no usable H264 decoder for this frame.","triggerScenarios":"The remote peer encodes H264 (hwcodec negotiated) while the local Decoder was created without H264 support: hwcodec/vram features disabled at compile time, hardware H264 decode not found at startup, or the HwRamDecoder creation failed so self.h264_ram stayed None.","commonSituations":"Software-only build (no hwcodec feature) connecting to a peer that sends H264s; VMs or hosts without GPU decode; codec negotiation mismatch after one side updated and began preferring H264.","solutions":["Build with the hwcodec feature (default on desktop targets) so h264_ram can be populated.","Ensure the negotiated codec falls back to VP9/VP8 when local H264 decode capability is absent — check the capability exchange before accepting H264.","If hardware decode init failed, retry or clear the hwcodec config cache (HwCodecConfig::clear) so detection runs again, then recreate the Decoder.","As a last resort, have the remote side switch to a codec this build supports (VPX)."],"exampleFix":"// before\nlet rgb = decoder.decode_video_frame(&vf, &mut rgb, &mut chroma, false)?; // H264s -> Err\n\n// after: advertise capability before the session starts\nlet prefer_h264 = Decoder::video_codec_state(|c| c.score_h264 > 0); // only accept H264 if decodable\nif !prefer_h264 { options.lock().unwrap().insert(\"video-codec\", \"vp9\"); }","handlingStrategy":"fallback","validationCode":"// before the session, check local H264 decode capability\nlet h264_capable = cfg!(feature = \"hwcodec\") && hwcodec::Decoder::info(0, false).is_some();\nif !h264_capable { opts.insert(\"custom-recv-codec\", \"vp9\"); }","typeGuard":null,"tryCatchPattern":"match decoder.decode_video_frame(&vf, &mut rgb, &mut chroma, false) {\n    Ok(done) => done,\n    Err(e) if e.to_string().contains(\"don't support h264\") => request_codec_switch(Codec::VP9),\n    Err(e) => return Err(e),\n}","preventionTips":["Gate codec negotiation on measured local decode capability, not on defaults.","Build with the hwcodec feature on platforms where GPU decode is expected.","Clear the hwcodec config cache when decode creation fails so re-detection can occur."],"tags":["decoder","h264","hwcodec","video","feature-gate"],"backgroundTag":null,"analyzedSha":"7aa98d43cf1962a7a29ec16ffef42974377ef11e","analyzedAt":"2026-08-16T06:17:34.842Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}