evanc577/download-iglive

can't download past video and audio segments somtimes

Opened this issue · 7 comments

When try to record (download) IG LIVE with this sometimes can't download past segments
Why happened like this?

same here.
stuck forever at random segment range.

I've expanded the initial search range in v0.1.6, which should help

@evanc577 I'm still having same issue on some live stream
This is a 1.5 hour long stream I found today.

mpd expired

Can't download past segments beyond segment 5003 (past video and audio stuck at checking segment no. 1k - 3k)

This also happens to me more often than not.
When it happens, it seems to always get stuck at the very beginning of the stream (<5k segments), and it keeps checking the same few segments over and over. This probably hints at something going wrong when detecting the beginning of the stream / no more segments.
It's not a very big deal because only a few segments are lost and you can still merge the rest manually, but it'd be great for it to be fixed so that program finishes properly and automerges the video (in my setup I'm using this while monitoring for live streams so the program not ending messes things up).

I've recently had it happen with a >20k segment, so it's not limited to the first few segments.
If it helps, looking at the checked segments it seems like it always keeps retrying the same few segments when it gets stuck instead of moving on and bruteforcing the ones it hasn't tried.

I suspect this could be fixed by extending max_diff to 17, since deltas have a difference of 33. Right now it's missing 13 values in the middle of each two deltas.

To summarize, yes, changing max_diff fixes it. The problem is that max_diff together with the 10..40 deltas make finding a segment with an unusual number take a really long time.

I've solved it by updating the state.deltas during the forward downloading too (the delta for the latest segment is a very good hint for possible past deltas) and reworking the backwards downloader to use an increasing window for max_diff (starting at 2 and +1 each time we run out of items in the current OffsetIterator. This ensures we'll pick up the deltas coming from the forward downloads quickly. I also moved the visited HashSet outside of the outer loop and I reset it (together with the max_diff window) only when we find a good segment.

It sometimes still takes a while to find a good segment, but it speeds things up considerably.

I have no idea about Rust though so my code is just a bunch of hacks glued together, hopefully the author can implement it properly based on this description :)