-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize loading of MP4 on slow media sources #175
Comments
From #153
Streaming a normal MP4 works fine. The loading of a fragmented MP4 is slow because of the chunk requests.
I believe the atom skipping is what is causing the HTTP requests to happen, making the loading slow. Therefore, I do not think solution 1 will help (in the case of streaming a fragmented MP4). |
Probably not by much. You can try this to see if optimization 2 helps. In this match case: Symphonia/symphonia-format-isomp4/src/demuxer.rs Lines 384 to 398 in 412f44d
Replace the contents with: if moov.is_some() && ftyp.is_some() {
break;
} Loading should be much faster. |
With that change, initial loading does not download the whole file (good!). When seeking, |
Yes, as mentioned, this defers further scanning to when it seeks. However, you only have to scan from current position to the required position so still a net positive. If implemented, the 1st item should speed the scan up further if you want to try. Of course, the 3rd item would be best, but that's a non-trivial change to even prototype. |
I can give it a go. |
Hello @pdeljanov This is what I got. Let me know if you have any suggestions with the way I implemented it. I used edit: I just made some additional changes here. |
I don't think this is how we would implement it since |
Yeah its a naive implementation. It doesn't completely solve the problem though. I think using the SIDX atom would be the final step. Unfortunately, I do not know how to implement it. |
Yeah, so to recap: the file loads instantly now, but you're seeing multiple seeks as we jump from fragment to fragment until the timestamp is reached? The SIDX atom would help here I think. Though, it is hard to implement and may raise other issues during implementation. Unfortunately, it will take some time. Another thing you could do right now is reuse your HTTP connection(s). I think a lot of time is likely being spent setting up a new connection (especially with SSL) so each seek becomes very expensive. Better yet, if QUIC is offered by the server, it'll be even faster. |
Yes, this is the current behavior.
I will look into this. |
The initial scan of top-level atoms in
IsoMp4Reader::try_new
can be slow if theMediaSource
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.This issue was promoted by the discussion in #153.
The text was updated successfully, but these errors were encountered: