{"record":{"id":"be0d5069942ce877","repo":"commaai/openpilot","slug":"clip-encoding-failed-s","errorCode":null,"errorMessage":"clip encoding failed: %s\n","messagePattern":"clip encoding failed: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"openpilot/system/loggerd/encoderd.cc","lineNumber":207,"sourceCode":"      int bitrate = 5'000'000;\n      int speedup = 1;\n      std::string metadata;\n      int input_arg = 5;\n      while (input_arg < argc && std::string(argv[input_arg]).rfind(\"--\", 0) == 0) {\n        const std::string option = argv[input_arg++];\n        if (option == \"--\") break;\n        if (input_arg == argc) throw std::invalid_argument(\"missing clip option value\");\n        if (option == \"--bitrate\") bitrate = std::stoi(argv[input_arg++]);\n        else if (option == \"--speedup\") speedup = std::stoi(argv[input_arg++]);\n        else if (option == \"--metadata\") metadata = argv[input_arg++];\n        else throw std::invalid_argument(\"unknown clip option: \" + option);\n      }\n      if (input_arg == argc) throw std::invalid_argument(\"missing clip input\");\n      std::vector<std::string> inputs(argv + input_arg, argv + argc);\n      return encode_clip(inputs, argv[2], std::stod(argv[3]), std::stod(argv[4]),\n                         bitrate, speedup, metadata);\n    } catch (const std::exception &e) {\n      fprintf(stderr, \"clip encoding failed: %s\\n\", e.what());\n      return 1;\n    }\n  }\n#endif\n  if (!Hardware::PC()) {\n    int ret;\n    ret = util::set_realtime_priority(52);\n    assert(ret == 0);\n    ret = util::set_core_affinity({3});\n    assert(ret == 0);\n  }\n  if (argc > 1) {\n    std::string arg1(argv[1]);\n    if (arg1 == \"--stream\") {\n      encoderd_thread(stream_cameras_logged);\n    } else {\n      LOGE(\"Argument '%s' is not supported\", arg1.c_str());\n    }","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/commaai/openpilot/blob/516ec1e68203439a73f340f1d0b3b91eabc626ee/openpilot/system/loggerd/encoderd.cc#L189-L225","documentation":"Printed by encoderd's --clip error handler when any exception escapes clip setup or encode_clip(): std::stoi/std::stod conversion failures (\"stod\"), the explicit invalid_argument messages from the option parser ('missing clip option value', 'unknown clip option: X', 'missing clip input'), or errors raised inside encode_clip itself. It prints e.what() and exits 1.","triggerScenarios":"Passing a non-numeric value to --bitrate/--speedup or START/DURATION (std::stoi/stod throw), a flag like --bitrate as the last argument with no value, an unknown option (e.g. --fps), no segment numbers at all, or encode_clip failing on missing/corrupt input segments.","commonSituations":"Shell scripts passing empty variables (\"$START\" unset -> stod('') throws), decimal locale differences, typos like --speed=2, or referencing a segment number that doesn't exist in the route so encode_clip cannot open the logs.","solutions":["Read e.what() in the printed message — it names the exact failing part ('stod', 'unknown clip option: --fps', etc.).","Quote and check your script variables: empty or non-numeric START/DURATION/bitrate are the most common cause.","Verify the segment numbers you passed exist in the route directory before invoking.","Spell options exactly --bitrate, --speedup, --metadata (unsigned values with no '=')."],"exampleFix":"# before\nencoderd --clip out.mp4 \"$START\" 10 5 --bitrate 4M   # stod('') / stoi('4M') throw\n\n# after\nencoderd --clip out.mp4 30 10 5 --bitrate 4000000","handlingStrategy":"validation","validationCode":"def is_num(s):\n    try:\n        float(s); return True\n    except ValueError:\n        return False\n\nfor v in (start, duration):\n    assert is_num(v), f'{v!r} must be numeric seconds'\nassert str(bitrate).isdigit(), 'bitrate must be integer bps'\nsubprocess.run(['encoderd', '--clip', out, start, duration, *segments, '--bitrate', str(bitrate)], check=True)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set and validate script variables before substitution (empty strings break stod).","Use integer bps for --bitrate, plain integers for --speedup.","Confirm segment numbers exist in the route directory."],"tags":["cli","encoderd","clip","argument-parsing","openpilot"],"backgroundTag":null,"analyzedSha":"516ec1e68203439a73f340f1d0b3b91eabc626ee","analyzedAt":"2026-08-15T00:17:37.461Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}