deezer/spleeter · error · SpleeterError
FFMPEG error: {process.stderr.read()}
Error message
FFMPEG error: {process.stderr.read()} What it means
When saving, spleeter pipes raw float32 PCM bytes into a running ffmpeg process's stdin. If writing to stdin, closing it, or waiting on the process raises IOError (typically because ffmpeg died and closed the pipe), spleeter wraps it in a `SpleeterError` containing ffmpeg's stderr output.
Source
Thrown at spleeter/audio/ffmpeg.py:184
logger.debug(f"Writing file {path}")
input_kwargs = {"ar": sample_rate, "ac": data.shape[1]}
output_kwargs = {"ar": sample_rate, "strict": "-2"}
if bitrate:
output_kwargs["audio_bitrate"] = bitrate
if codec is not None and codec != "wav":
output_kwargs["codec"] = self.SUPPORTED_CODECS.get(codec, codec)
process = (
ffmpeg.input("pipe:", format="f32le", **input_kwargs)
.output(path, **output_kwargs)
.overwrite_output()
.run_async(pipe_stdin=True, pipe_stderr=True, quiet=True)
)
try:
process.stdin.write(data.astype("<f4").tobytes())
process.stdin.close()
process.wait()
except IOError:
raise SpleeterError(f"FFMPEG error: {process.stderr.read()}")
logger.info(f"File {path} written succesfully")
View on GitHub (pinned to c8854001ac)
Solutions
- Read the embedded ffmpeg stderr in the error message for the concrete ffmpeg failure
- Try a safe default first: `codec='wav'` with no bitrate to isolate the issue
- Validate the codec/bitrate/filename-extension combination is supported by your ffmpeg build (`ffmpeg -codecs`)
Example fix
// before
adapter.save('out.ogg', data, 44100, codec='opus', bitrate='999k')
// after
adapter.save('out.wav', data, 44100, codec='wav') # confirm pipeline works, then retry desired codec Defensive patterns
Strategy: try-catch
Validate before calling
# sanity-check inputs before saving
import shutil
assert shutil.which('ffmpeg') is not None
assert data.ndim == 2, 'data must be (samples, channels)'
extension = path.rsplit('.', 1)[-1].lower()
assert extension in ('wav', 'mp3', 'ogg', 'flac', 'm4a'), f'unsupported extension: {extension}' Try / catch
try:
adapter.save(path, data, sample_rate, codec='wav')
except Exception as e:
if 'FFMPEG error' in str(e):
logger.error('ffmpeg failed writing %s: %s', path, str(e))
adapter.save(path.with_suffix('.wav'), data, sample_rate, codec='wav')
else:
raise Prevention
- Start with codec='wav' and no bitrate; only add codec/bitrate after verifying ffmpeg support
- Check `ffmpeg -codecs` for codec/bitrate availability in your build
- Ensure data is float32 with shape (samples, channels) and sample_rate matches content
When it happens
Trigger: Calling `adapter.save(path, data, sample_rate, ...)` where the spawned ffmpeg process exits early or fails: bad codec/bitrate combination, unsupported output extension, ffmpeg crashing on the data shape/channels.
Common situations: Requesting an exotic codec or bitrate (e.g. with `codec='aac'` and an unsupported bitrate), writing to a filename with an extension ffmpeg cannot infer a format from, out-of-memory kill of the ffmpeg process, or incompatible `strict -2` format options.
Related errors
- An error occurs with ffprobe (see ffprobe output below) {}
- {} binary not found
- No stream was found with ffprobe
- output directory does not exists: {directory}
AI-assisted analysis of deezer/spleeter@c8854001ac (2026-08-28).
Data as JSON: /api/errors/b257724693339fdb.
Report an issue: GitHub.