Skip to content

Commit

Permalink
M4A/MP4 : Improve duration detection for fragmented MP4s
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeugma440 committed Jan 23, 2025
1 parent 2477295 commit 2267f39
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ATL/AudioData/IO/MP4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,9 @@ private void readMoof(Stream s)
if (s.Read(data, 0, 4) < 4) break;
var mdatSize = StreamUtils.DecodeBEUInt32(data);
s.Seek(mdatSize - 4, SeekOrigin.Current);
if (s.Read(data, 0, 4) < 4) break;
moofSize = StreamUtils.DecodeBEUInt32(data);
if (s.Read(data, 0, 4) < 4) break;
var atomName = Utils.Latin1Encoding.GetString(data);
if (!atomName.Equals("moof")) break;

// Look for the next moof atom; other atoms may exist between successive moof atoms
moofSize = navigateToAtom(s, "moof");
}

calculatedDurationMs = durationAll * 1000.0 / SampleRate;
Expand Down

0 comments on commit 2267f39

Please # to comment.