Serial-ATA / Serial-ATA/lofty-rs
MPEG: Downgrade "Using bitrate to estimate duration" log from WARN to DEBUG (at least for CBR MP3)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 359
- Forks
- 77
- Avg merge
- 12h 54m
- Merged PRs (30d)
- 11
Description
Summary
The library currently emits a WARN log when estimating the duration of an MPEG file using its bitrate:
WARN lofty::mpeg::properties: MPEG: Using bitrate to estimate duration
While this warning is accurate for Variable Bitrate (VBR) files without proper headers (where the estimate might be imprecise), it is also triggered for standard Constant Bitrate (CBR) files that simply lack advanced headers (like Xing or VBRI). For CBR files, this calculation is perfectly accurate and expected behavior.
Why this is a problem
When processing large audio libraries or parsing multiple MP3 files at runtime, this warning floods the console/logs with hundreds of identical lines.
Silencing lofty::mpeg::properties warnings entirely via RUST_LOG or logging filters is not a great workaround, as it prevents developers from seeing legitimate, actionable WARN logs (Unless you're telling me that's the only log line that can appear.).
Proposed Solutions
Downgrade this specific log message from WARN to DEBUG or move the log statement after the is_cbr check and split the severity:
let is_cbr = matches!(vbr_header.map(|h| h.ty), Some(VbrHeaderType::Info));
if is_cbr {
log::debug!("MPEG: CBR detected, using bitrate to calculate duration");
properties.audio_bitrate = first_frame_header.bitrate;
} else {
log::warn!("MPEG: No VBR header found, estimating duration from bitrate");
}
This keeps a real warning for the case that actually deserves one (no header, potential VBR, approximate result), and avoids flooding logs with a WARN for every ordinary CBR file, which is what users like myself are hitting in practice.
API design
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the logging statement in lofty::mpeg::properties and inspect how the is_cbr check distinguishes CBR from files without a VBR header. Verify that ordinary CBR files no longer emit a WARN while cases with potentially imprecise bitrate estimates retain an appropriate warning; the issue does not name a specific test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100