Skip to content

[Bug]: RIFF and data chunk sizes incorrect on wav export #458

Description

@sam1am

Before reporting

  • I'm on the latest release and the issue still happens.
  • I searched existing issues and didn't find a duplicate.

What happened?

When a wav is exported, the RIFF and data chunk sizes are never written, so the placeholders are left at 0xFFFFFFFF (~4GB). This causes breaking issues on some playback devices.

app/api/stems.py, get_mixdown() around line 734–740 at HEAD 6ab7edc:

cmd += [
    "-filter_complex", ";".join(filters),
    "-map", out_label,
    *post_seek,
    *codec,        # for wav: ["-c:a","pcm_s16le","-f","wav"]
    *rate,
    "pipe:1",      # <-- the problem
]
return StreamingResponse(_stream_ffmpeg(cmd, ..., cache_path=cache_path), ...)

ffmpeg's WAV muxer writes the RIFF and data chunk sizes as placeholders (0xFFFFFFFF) and patches them at the end by seeking back. pipe:1 is not seekable, so the placeholders are never patched. Every WAV streamed from these endpoints ends up with header sizes claiming ~4 GB of audio.

A few ways to fix this, but I suggest rendering to a temp file, then stream that. The cache temp file already exists, so write ffmpeg output to tmp_path directly and stream/rename it after exit.

I'd be happy to submit a PR implementing this approach. I have a commit on my fork here: sam1am@5ae52b4

I didn't see any direct report of this issue, but I did see several upstream issues that this could potentially be a root cause of.

Steps to reproduce

  1. Export the mix as a wav
  2. Check it with ffprobe [file.wav]

A file with incorrect RIFF and data chunk sizes will show something like:

[wav @ 0x121904080] Ignoring maximum wav data size, file may be invalid
[wav @ 0x121904080] Estimating duration from bitrate, this may be inaccurate

You will not see this on a file with correct values.

Operating system

macOS (Apple Silicon)

StemDeck version

0.14.2

How did you install it?

macOS DMG

Logs / screenshots

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions