Symphonia
Symphonia copied to clipboard
Optimize loading of MP4 on slow media sources
The initial scan of top-level atoms in IsoMp4Reader::try_new
can be slow if the MediaSource
is slow to read and seek. This is particularly bad with fragmented MP4s where there are many MOOF + MDAT pairs. This issue tracks possible optimizations:
-
AtomIterator::next
callsignore_bytes
to skip the body of an unread atom. It should be possible to replaceignore_bytes
with an explicitseek
if the reader is seekable. However, there will still be a lot of seek + small read operations as all the atoms are skipped over. - If the MOOV and FTYP atoms were already encountered, it may be reasonable to terminate scanning of the top-level atoms at the first MOOF or MDAT atom. There'd need to be some documentation (i.e., standards, etc.) or proof that this is a good general optimization that won't break anything. However, this would still defer loading the fragments to the first seek.
- Use the SIDX atom (segment index) to avoid the scanning that would happen on a seek if the 2nd point was implemented.
This issue was promoted by the discussion in #153.