{"record":{"id":"f336442aa0b6ba6e","repo":"nilaoda/N_m3u8DL-RE","slug":"decryptionbinarypath","errorCode":null,"errorMessage":"{DecryptionBinaryPath}","messagePattern":"\\{DecryptionBinaryPath\\}","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/N_m3u8DL-RE/Program.cs","lineNumber":156,"sourceCode":"        Logger.Extra($\"ffmpeg => {option.FFmpegBinaryPath}\");\n\n        // 预先检查mkvmerge\n        if (option is { MuxOptions.UseMkvmerge: true, MuxAfterDone: true })\n        {\n            option.MkvmergeBinaryPath ??= GlobalUtil.FindExecutable(\"mkvmerge\");\n            if (string.IsNullOrEmpty(option.MkvmergeBinaryPath) || !File.Exists(option.MkvmergeBinaryPath))\n            {\n                throw new FileNotFoundException(ResString.mkvmergeNotFound);\n            }\n            Logger.Extra($\"mkvmerge => {option.MkvmergeBinaryPath}\");\n        }\n\n        // 预先检查\n        if (option.Keys is { Length: > 0 } || option.KeyTextFile != null)\n        {\n            if (!string.IsNullOrEmpty(option.DecryptionBinaryPath) && !File.Exists(option.DecryptionBinaryPath))\n            {\n                throw new FileNotFoundException(option.DecryptionBinaryPath);\n            }\n            switch (option.DecryptionEngine)\n            {\n                case DecryptEngine.SHAKA_PACKAGER:\n                {\n                    var file = FindShakaPackager();\n                    if (file == null) throw new FileNotFoundException(ResString.shakaPackagerNotFound);\n                    option.DecryptionBinaryPath = file;\n                    Logger.Extra($\"shaka-packager => {option.DecryptionBinaryPath}\");\n                    break;\n                }\n                case DecryptEngine.MP4DECRYPT:\n                {\n                    var file = GlobalUtil.FindExecutable(\"mp4decrypt\");\n                    if (file == null) throw new FileNotFoundException(ResString.mp4decryptNotFound);\n                    option.DecryptionBinaryPath = file;\n                    Logger.Extra($\"mp4decrypt => {option.DecryptionBinaryPath}\");\n                    break;","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/nilaoda/N_m3u8DL-RE/blob/e113dee70c924ee08dae5460624909b04d84cb76/src/N_m3u8DL-RE/Program.cs#L138-L174","documentation":"DoWorkAsync validates that a user-supplied decryption binary (--decryption-binary-path) actually exists on disk when keys are provided. The thrown FileNotFoundException's message is the path itself, so the error text is the missing file path.","triggerScenarios":"option.DecryptionBinaryPath is set (e.g. via --decryption-binary-path) and non-empty, but File.Exists returns false, while option.Keys or --key-text-file indicates decryption will be needed.","commonSituations":"Typo in the path to mp4decrypt/shaka-packager; binary moved after an upgrade; relative path resolved from a different working directory; Windows users quoting the path incorrectly.","solutions":["Correct --decryption-binary-path to the full absolute path of the binary","Verify the file exists: ls <path> / dir <path>","Reinstall mp4decrypt (from Bento4) or shaka-packager and use the new path","Run from a working directory where the relative path resolves, or switch to an absolute path"],"exampleFix":"// before\n--decryption-binary-path mp4decrypt\n// after\n--decryption-binary-path /usr/local/bin/mp4decrypt","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrEmpty(decryptionBinaryPath) && !File.Exists(decryptionBinaryPath))\n    throw new FileNotFoundException($\"decryption binary missing: {decryptionBinaryPath}\");","typeGuard":"static bool DecryptionBinaryValid(CLIOptions o) => string.IsNullOrEmpty(o.DecryptionBinaryPath) || File.Exists(o.DecryptionBinaryPath);","tryCatchPattern":"try { await DoWorkAsync(option); }\ncatch (FileNotFoundException ex) when (ex.FileName == null && ex.Message.Contains(\"decrypt\") || ex.Message.EndsWith(\".exe\"))\n{\n    Console.Error.WriteLine($\"decryption binary not found: {ex.Message}\");\n}","preventionTips":["Always use absolute paths for --decryption-binary-path","Re-check paths after upgrading Bento4/shaka-packager","Note the thrown message is the raw path — use it to identify which file was missing"],"tags":["csharp","decryption","file-not-found","cli"],"backgroundTag":"file-not-found","analyzedSha":"e113dee70c924ee08dae5460624909b04d84cb76","analyzedAt":"2026-09-13T02:43:21.078Z","contentChangedAt":"2026-09-13T02:43:21.078Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}