Audio export: real FLAC + tag metadata for all formats

- FLAC is now real FLAC via ffmpeg, not WAV bytes in a .flac file. 16-bit uses
  S16, 24-bit uses S32 (ffmpeg's flac encoder emits bits_per_raw_sample=24).
  The flush emits a trailing empty packet that the FLAC muxer rejects as
  "invalid data" — it's skipped.

- Tag metadata (title/artist/album/genre/year/track/comment) written into every
  format via each container's native tags: ID3v2 (MP3), MP4 atoms (M4A), Vorbis
  comments (FLAC) set through ffmpeg's output metadata; RIFF LIST/INFO appended
  to the hound-written WAV (with a fixed-up RIFF size). New AudioMetadata type
  on AudioExportSettings; dialog gains a Tags section and defaults Title to the
  project name.

Tests: FLAC is a real fLaC container with round-tripped tags; WAV keeps a valid
RIFF with a working INFO chunk.
This commit is contained in:
Skyler Lehmkuhl
2026-07-09 12:52:37 -04:00
parent 6b8a1f1386
commit 15bdf80ec1
4 changed files with 99 additions and 516 deletions
@@ -153,6 +153,11 @@ impl ExportDialog {
else if only_raster { ExportType::Image }
else { self.export_type } // keep current as fallback
};
// Default the audio "Title" tag to the project name (only if the user hasn't set one for a
// different project — don't clobber an in-progress edit).
if self.audio_settings.metadata.title.is_empty() && !same_project {
self.audio_settings.metadata.title = project_name.to_owned();
}
self.current_project = project_name.to_owned();
// Restore the last exported path if available; otherwise default to project name.
@@ -475,10 +480,42 @@ impl ExportDialog {
ui.add_space(8.0);
// Tag metadata (ID3 / MP4 / Vorbis / RIFF-INFO depending on format).
self.render_audio_metadata(ui);
ui.add_space(8.0);
// Time range
self.render_time_range(ui);
}
/// Render the audio tag-metadata fields (title/artist/album/…). Written into the file on export.
fn render_audio_metadata(&mut self, ui: &mut egui::Ui) {
let m = &mut self.audio_settings.metadata;
ui.label(egui::RichText::new("Tags").strong());
egui::Grid::new("audio_metadata_grid")
.num_columns(2)
.spacing([8.0, 4.0])
.show(ui, |ui| {
let row = |ui: &mut egui::Ui, label: &str, val: &mut String, hint: &str| {
ui.label(label);
ui.add(
egui::TextEdit::singleline(val)
.hint_text(hint)
.desired_width(260.0),
);
ui.end_row();
};
row(ui, "Title", &mut m.title, "Track title");
row(ui, "Artist", &mut m.artist, "Artist");
row(ui, "Album", &mut m.album, "Album");
row(ui, "Genre", &mut m.genre, "Genre");
row(ui, "Year", &mut m.year, "e.g. 2026");
row(ui, "Track", &mut m.track, "e.g. 1 or 1/12");
row(ui, "Comment", &mut m.comment, "Comment");
});
}
/// Video presets: (name, codec, quality, width, height, fps)
const VIDEO_PRESETS: &'static [(&'static str, VideoCodec, VideoQuality, u32, u32, f64)] = &[
("1080p H.264 (Standard)", VideoCodec::H264, VideoQuality::High, 1920, 1080, 30.0),