Add loudness data to recording metadata

This commit introduces the `Loudness` struct to store replay-gain data
(mean, max, and calculated gain in dB) derived from `ffmpeg`'s
`volumedetect`.

The `RecordingMeta` struct is updated to include an optional `loudness`
field. This allows for consistent playback volume across recordings with
varying microphone levels by applying gain in the browser.

Additionally, new `server/src/loudness.rs` and
`server/src/transcribe/ffmpeg.rs` modules are added. The former defines
constants for replay-gain targets and logic to compute gain, while the
latter handles audio analysis using `ffmpeg` to extract loudness
metrics.

The `#[serde(default)]` attribute on the `loudness` field in
`RecordingMeta` ensures backward compatibility with older metadata files
that do not contain this field. Tests are included to verify round-trip
serialization and parsing of older formats.
This commit is contained in:
2026-04-27 16:11:02 +02:00
parent 8a531144af
commit 427a28ac6b
7 changed files with 310 additions and 1 deletions
+1
View File
@@ -240,6 +240,7 @@ pub(crate) fn write_recording_meta_sync(
let meta = doctate_common::RecordingMeta {
transcript,
duration_seconds,
loudness: None,
};
let bytes = serde_json::to_vec(&meta).expect("RecordingMeta serializes infallibly");
std::fs::write(