Sound uploader: accept Ogg, MP3, Opus and FLAC, re-encoded to Ogg Vorbis like WAV #808

Closed
opened 2026-10-17 15:47:06 +00:00 by sky_line · 1 comment
Owner

The sound uploader only takes WAV today. The viewer converts it to Ogg Vorbis for upload, the format the server stores. It should also accept common compressed formats, decode them in the viewer and re-encode to Ogg Vorbis through the same path as WAV.

Formats to accept: Ogg Vorbis (.ogg), MP3 (.mp3), Opus (.opus, also Opus inside .ogg), FLAC (.flac).

Behaviour

  • Decode to PCM in the viewer, then go through the existing WAV path unchanged: the same resampling and channel handling, the same length limit and the same Vorbis encode settings. The uploaded asset is identical in kind to one made from a WAV.
  • Treat an .ogg input as untrusted too: decode it and re-encode it. Never pass a user's Ogg file through as-is, so the server only ever gets our own encode, with a known quality, sample rate and channel count.
  • Check the length after decoding, so the limit applies to the real audio, not to a header's claim. This pairs with #807: a long file in any of these formats could be offered for splitting.
  • Show the detected format, duration, sample rate and channels in the preview before upload.
  • Add the new extensions to the file picker filter, and keep WAV.

Details to get right

  • Decoder libraries: pick ones with acceptable licences that are maintained and safe on untrusted input (malformed files must fail cleanly, never crash). libvorbis is already present; Opus, FLAC and MP3 decoders (e.g. libopus + opusfile, libFLAC or dr_flac, minimp3 or dr_mp3) would need adding as 3p packages or vendored single-header decoders, on Linux and Windows.
  • Opus decodes at 48 kHz: resample to the rate the uploader encodes at, as for any other non-matching WAV.
  • MP3: handle encoder delay and padding (LAME / Xing gapless info) so clips don't gain leading silence.
  • Bound memory and time: decode in a streaming way or cap the decoded size before allocating (a tiny compressed file can claim a huge length).
  • Error messages should name the problem (unsupported codec inside the container, corrupt file, too long), not just "upload failed".
The sound uploader only takes WAV today. The viewer converts it to Ogg Vorbis for upload, the format the server stores. It should also accept common compressed formats, decode them in the viewer and re-encode to Ogg Vorbis through the same path as WAV. **Formats to accept:** Ogg Vorbis (`.ogg`), MP3 (`.mp3`), Opus (`.opus`, also Opus inside `.ogg`), FLAC (`.flac`). **Behaviour** - Decode to PCM in the viewer, then go through the existing WAV path unchanged: the same resampling and channel handling, the same length limit and the same Vorbis encode settings. The uploaded asset is identical in kind to one made from a WAV. - Treat an `.ogg` input as untrusted too: decode it and re-encode it. Never pass a user's Ogg file through as-is, so the server only ever gets our own encode, with a known quality, sample rate and channel count. - Check the length after decoding, so the limit applies to the real audio, not to a header's claim. This pairs with #807: a long file in any of these formats could be offered for splitting. - Show the detected format, duration, sample rate and channels in the preview before upload. - Add the new extensions to the file picker filter, and keep WAV. **Details to get right** - Decoder libraries: pick ones with acceptable licences that are maintained and safe on untrusted input (malformed files must fail cleanly, never crash). libvorbis is already present; Opus, FLAC and MP3 decoders (e.g. libopus + opusfile, libFLAC or dr_flac, minimp3 or dr_mp3) would need adding as 3p packages or vendored single-header decoders, on Linux and Windows. - Opus decodes at 48 kHz: resample to the rate the uploader encodes at, as for any other non-matching WAV. - MP3: handle encoder delay and padding (LAME / Xing gapless info) so clips don't gain leading silence. - Bound memory and time: decode in a streaming way or cap the decoded size before allocating (a tiny compressed file can claim a huge length). - Error messages should name the problem (unsupported codec inside the container, corrupt file, too long), not just "upload failed".
sky_line added this to the Slipstream project 2026-10-17 15:47:06 +00:00
Author
Owner

Shipped in 1.4.0 Beta 2. Closing; reopen if it misbehaves.

Shipped in 1.4.0 Beta 2. Closing; reopen if it misbehaves.
sky_line 2026-10-20 15:03:20 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream#808
No description provided.