{"record":{"id":"f1fae2a1e19a79e2","repo":"deezer/spleeter","slug":"output-directory-does-not-exists-directory","errorCode":null,"errorMessage":"output directory does not exists: {directory}","messagePattern":"output directory does not exists: (.+?)","errorType":"exception","errorClass":"SpleeterError","httpStatus":null,"severity":"error","filePath":"spleeter/audio/ffmpeg.py","lineNumber":165,"sourceCode":"            data (np.ndarray):\n                Waveform data to write.\n            sample_rate (float):\n                Sample rate to write file in.\n            codec (Codec):\n                (Optional) Writing codec to use, default to `None`.\n            bitrate (str):\n                (Optional) Bitrate of the written audio file, default to\n                `None`.\n\n        Raises:\n            IOError:\n                If any error occurs while using FFMPEG to write data.\n        \"\"\"\n        if isinstance(path, Path):\n            path = str(path)\n        directory = os.path.dirname(path)\n        if not os.path.exists(directory):\n            raise SpleeterError(f\"output directory does not exists: {directory}\")\n        logger.debug(f\"Writing file {path}\")\n        input_kwargs = {\"ar\": sample_rate, \"ac\": data.shape[1]}\n        output_kwargs = {\"ar\": sample_rate, \"strict\": \"-2\"}\n        if bitrate:\n            output_kwargs[\"audio_bitrate\"] = bitrate\n        if codec is not None and codec != \"wav\":\n            output_kwargs[\"codec\"] = self.SUPPORTED_CODECS.get(codec, codec)\n        process = (\n            ffmpeg.input(\"pipe:\", format=\"f32le\", **input_kwargs)\n            .output(path, **output_kwargs)\n            .overwrite_output()\n            .run_async(pipe_stdin=True, pipe_stderr=True, quiet=True)\n        )\n        try:\n            process.stdin.write(data.astype(\"<f4\").tobytes())\n            process.stdin.close()\n            process.wait()\n        except IOError:","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/deezer/spleeter/blob/c8854001ac8acad34a9bc2bd15f28475541828b1/spleeter/audio/ffmpeg.py#L147-L183","documentation":"`FFMPEGAudioAdapter.save` computes the parent directory of the target path and raises a `SpleeterError` if that directory does not exist. ffmpeg subprocesses cannot create directories, so spleeter fails fast before writing.","triggerScenarios":"Calling `separator.separate_to_file(..., output_path='newdir/sub/')` or `adapter.save(path, ...)` where the target directory (or any parent) has not been created yet.","commonSituations":"Writing separation output to a fresh output folder that was never created, typo in the output path, running from a different working directory than expected.","solutions":["Create the output directory before saving: `os.makedirs(directory, exist_ok=True)`","Or pass a `filename_format`/path inside an already-existing directory","Double-check the output path for typos and relative/absolute path mixups"],"exampleFix":"// before\nseparator.separate_to_file('song.mp3', 'output/vocals_only/song.wav')\n// after\nimport os\nos.makedirs('output/vocals_only', exist_ok=True)\nseparator.separate_to_file('song.mp3', 'output/vocals_only/song.wav')","handlingStrategy":"validation","validationCode":"import os\nout = 'output/vocals_only/song.wav'\nos.makedirs(os.path.dirname(out) or '.', exist_ok=True)","typeGuard":null,"tryCatchPattern":"try:\n    separator.separate_to_file('song.mp3', output_path)\nexcept Exception as e:\n    if 'output directory does not exists' in str(e):\n        os.makedirs(output_path, exist_ok=True)\n        separator.separate_to_file('song.mp3', output_path)\n    else:\n        raise","preventionTips":["Always os.makedirs(output_dir, exist_ok=True) before separating","Resolve output paths to absolute paths to avoid cwd surprises","Check path spelling in config files and CLI arguments"],"tags":["file-io","missing-directory","path"],"backgroundTag":"output-directory-missing","analyzedSha":"c8854001ac8acad34a9bc2bd15f28475541828b1","analyzedAt":"2026-08-28T21:38:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}