{"record":{"id":"2facb087ec1ebd49","repo":"chenhg5/cc-connect","slug":"ffmpeg-not-found-in-path-install-ffmpeg-to-enable-2facb0","errorCode":null,"errorMessage":"ffmpeg not found in PATH: install ffmpeg to enable audio conversion","messagePattern":"ffmpeg not found in PATH: install ffmpeg to enable audio conversion","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/speech.go","lineNumber":347,"sourceCode":"\t}\n\n\tcmd.Stdin = bytes.NewReader(audio)\n\tvar stdout, stderr bytes.Buffer\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\n\tif err := cmd.Run(); err != nil {\n\t\treturn nil, fmt.Errorf(\"ffmpeg conversion failed: %w (stderr: %s)\", err, stderr.String())\n\t}\n\treturn stdout.Bytes(), nil\n}\n\n// ConvertAudioToOpus uses ffmpeg to convert audio to opus format (ogg container).\n// Returns the opus bytes. If ffmpeg is not installed, returns an error.\nfunc ConvertAudioToOpus(ctx context.Context, audio []byte, srcFormat string) ([]byte, error) {\n\tffmpegPath, err := exec.LookPath(\"ffmpeg\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ffmpeg not found in PATH: install ffmpeg to enable audio conversion\")\n\t}\n\n\targs := []string{\"-i\", \"pipe:0\", \"-c:a\", \"libopus\", \"-f\", \"opus\", \"-y\", \"pipe:1\"}\n\tif srcFormat == \"amr\" || srcFormat == \"silk\" {\n\t\targs = append([]string{\"-f\", srcFormat}, args...)\n\t}\n\tcmd := exec.CommandContext(ctx, ffmpegPath, args...)\n\tcmd.Stdin = bytes.NewReader(audio)\n\tvar stdout, stderr bytes.Buffer\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\n\tif err := cmd.Run(); err != nil {\n\t\treturn nil, fmt.Errorf(\"ffmpeg opus conversion failed: %w (stderr: %s)\", err, stderr.String())\n\t}\n\treturn stdout.Bytes(), nil\n}\n","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/speech.go#L329-L365","documentation":"ConvertAudioToOpus converts audio to Opus-in-OGG (used for voice notes on platforms like Telegram) by invoking ffmpeg. Like the other Convert* helpers, it first probes for ffmpeg with exec.LookPath and returns this error when the binary cannot be found in PATH. Opus encoding also requires an ffmpeg build that includes libopus; the presence check here only covers the binary itself.","triggerScenarios":"Calling ConvertAudioToOpus (directly or via SendAudio) on a host where `exec.LookPath(\"ffmpeg\")` fails: ffmpeg not installed, not in the daemon's PATH, or the service runs in a container image that omits it.","commonSituations":"Alpine/slim Docker images without the ffmpeg package; systemd services with a minimal default PATH; self-hosted bots on fresh VPS instances; ffmpeg installed via snap/nix in a directory the service user does not have on PATH.","solutions":["Install ffmpeg (`apt-get install ffmpeg`, `apk add ffmpeg`, `brew install ffmpeg`).","Ensure the install includes libopus support (`ffmpeg -encoders | grep opus` shows libopus).","Add ffmpeg's location to the PATH of the cc-connect process (systemd Environment=PATH=..., Docker ENV).","Verify with `which ffmpeg` run as the same user the daemon runs as."],"exampleFix":"// docker-compose before\nservices:\n  cc-connect:\n    image: alpine:3.20\n// after\nservices:\n  cc-connect:\n    image: alpine:3.20\n    # in Dockerfile: RUN apk add --no-cache ffmpeg","handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"ffmpeg\"); err != nil {\n    return fmt.Errorf(\"audio conversion unavailable: %w\", err)\n}\n","typeGuard":"func hasFFmpeg() bool { _, err := exec.LookPath(\"ffmpeg\"); return err == nil }","tryCatchPattern":"opus, err := core.ConvertAudioToOpus(ctx, audio, format)\nif err != nil && strings.Contains(err.Error(), \"ffmpeg not found\") {\n    return sendRawAudio(audio) // send original bytes instead\n}","preventionTips":["Install ffmpeg in the deployment image as part of infrastructure-as-code.","Check `ffmpeg -encoders | grep opus` in CI to confirm libopus support.","Pin an explicit PATH in the service definition.","Probe for ffmpeg at process startup and surface a doctor/diagnostic warning."],"tags":["ffmpeg","external-dependency","audio","opus"],"backgroundTag":"command-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}