Skip to content

Commit 50ecdb9

Browse files
committed
MP4: Demote missing mdat atom error
1 parent 43ce6f2 commit 50ecdb9

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lofty/src/mp4/properties.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,18 @@ where
517517
if duration > 0 {
518518
// TODO: We should keep track of the `mdat` length when first reading the file.
519519
// This extra read is unnecessary.
520-
let mdat_len = mdat_length(reader)?;
520+
let mdat_len;
521+
match mdat_length(reader) {
522+
Ok(len) => mdat_len = len,
523+
Err(err) => {
524+
if parse_mode == ParsingMode::Strict {
525+
return Err(err);
526+
}
527+
528+
log::warn!("No \"mdat\" atom found, any audio properties will be useless.");
529+
return Ok(properties);
530+
},
531+
}
521532

522533
if let Some(stts) = stts {
523534
let stts_specifies_duration =
@@ -547,8 +558,7 @@ where
547558
if properties.audio_bitrate == 0 {
548559
log::warn!("Estimating audio bitrate from 'mdat' size");
549560

550-
properties.audio_bitrate =
551-
(u128::from(mdat_length(reader)? * 8) / duration_millis) as u32;
561+
properties.audio_bitrate = (u128::from(mdat_len * 8) / duration_millis) as u32;
552562
}
553563
}
554564

0 commit comments

Comments
 (0)