Skip to content

downloads can be saved as flac, in 16 bit since every source is lossy - #15

Merged
1 commit merged into
Ryoku-dev:mainfrom
eximora-private:feat/flac-downloads
Oct 21, 2026
Merged

1 commit merged into
Ryoku-dev:mainfrom
eximora-private:feat/flac-downloads

Conversation

@eximora-private

Copy link
Copy Markdown

Settings > Downloads offers Original, MP3 and Opus. Some players and libraries only take FLAC, so a FLAC choice joins them.

The sources are YouTube and SoundCloud streams, so FLAC here does not mean lossless audio: the file is only as good as the lossy stream it came from. What it does avoid is a second lossy encode on top. The help text and the changelog say that, rather than promising lossless quality.

yt-dlp extracts with --audio-format flac and no --audio-quality, since a lossless encoder has no bitrate to aim for, and ExtractAudio:-sample_fmt s16 makes ffmpeg write 16-bit samples. Without it the decode lands at 24 bit, and the extra bits are decoder noise FLAC cannot compress: on "Me at the zoo" the file goes from 1.37 MB at 24 bit to 504 KB at 16 bit. The existing ffmpeg:-threads 1 still reaches both postprocessors.

Cover art and lyrics go in through the same lofty path as every other format, and find_output_file already knew the flac extension, so nothing else in the pipeline changes. One new test runs embed_tags against a real FLAC with the block layout ffmpeg writes and checks that title, artist, lyrics and the front cover come back out. Another checks the yt-dlp arguments and that the setting serialises as "flac".

Worth knowing

  • Picking FLAC writes "flac" into downloads.json, the frozen settings of history entries included. v1.2.1 and older cannot read that and the daemon does not start, so going back to an older build after choosing FLAC needs the history cleared. Letting load() fall back to Original for an unknown format would stop this from happening with the next format; I left that out of this PR.
  • An integer format clips peaks above full scale, which a loud lossy master can decode to. Original and Opus keep those, since mpv decodes in float.
  • A FLAC with nothing but STREAMINFO makes lofty 0.22.4 panic while rewriting tags. ffmpeg always writes a comment and a padding block, so a download never looks like that, and write_media runs in spawn_blocking, so it would end as a warning anyway.
  • Tracks already saved in another format count as downloaded and are not fetched again as FLAC.

Verified

  • scripts/release-check.sh: release checks completed, with the UI built.
  • cd ui && pnpm check && pnpm build, cargo fmt --all -- --check, cargo test --workspace --locked (skipping the mpv gain test like CI): pass.
  • yt-dlp with these arguments on a YouTube video: audio.flac, 16 bit, 48 kHz, blocks STREAMINFO / VORBIS_COMMENT / PADDING, title embedded.

Not seen in a running client: I did not click through Settings > Downloads on a build from this branch.

… lossy

Settings > Downloads gains a FLAC choice next to Original, MP3 and Opus.
yt-dlp extracts with --audio-format flac and no bitrate, and ffmpeg writes
16-bit samples: the sources are YouTube and SoundCloud streams, so the bits
a 24-bit decode adds are noise FLAC cannot compress, and dropping them makes
the file about half the size. Cover art and lyrics go in through the same
lofty path as the other formats, and the completed-file detection already
knew the flac extension.
@neur0map neur0map closed this pull request by merging all changes into Ryoku-dev:main in a1510fb Oct 21, 2026
@neur0map

Copy link
Copy Markdown
Member

Merged, thank you.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants