Skip to content
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

Sequential Downloads #150

Closed
swrap opened this issue Mar 23, 2017 · 6 comments
Closed

Sequential Downloads #150

swrap opened this issue Mar 23, 2017 · 6 comments

Comments

@swrap
Copy link

swrap commented Mar 23, 2017

Can you add support for sequential downloading.

@anacrolix
Copy link
Owner

Do you mean for cmd/torrent? In the library, just open a reader on the file/torrent you want, and read in the order you want.

@swrap
Copy link
Author

swrap commented Mar 25, 2017

I can use the reader to read in order, but that doesn't ensure the torrent downloads in order. I understand BitTorrent is not optimal to download the data in order, but I wish to use it for video streaming.

@anacrolix
Copy link
Owner

I use the torrent Client myself for video streaming, its piece prioritization is designed to ensure that data is optimized toward satisfying sequential reads from the torrent.Reader type. For example any time the Reader is blocked on a Read, the piece is selected for all current peers. The next piece is also chosen next, only after the next 2 pieces are available does it start to split the peers across the Readahead window set on the Reader. (It's currently 5MB by default.) If you io.Copy(ioutil.Discard, someReader), it will consume the data so quickly it will probably download every single piece in order as it will always be blocked on the next unavailable piece.

Just to check, be sure to stream the data to your player from the torrent.Reader. Don't access the filesystem directly as I've seen people do. When accessing the filesystem, the player won't know that EOF isn't corruption, as it isn't synced with the torrent client as it will be if you feed it from the torrent.Reader yourself. See cmd/torrentfs if you want to go that route.

@swrap
Copy link
Author

swrap commented Mar 29, 2017

Thanks so much! I will check this out and write back about my findings :) Really appreciate the quick response (sorry I took awhile) and love the library!

@antonsoroko
Copy link

@anacrolix
Hi.

For example any time the Reader is blocked on a Read, the piece is selected for all current peers. The next piece is also chosen next, only after the next 2 pieces are available does it start to split the peers across the Readahead window set on the Reader.

Is it possible to somehow force the library to download all the pieces sequentially?
As it done in desktop torrent clients(e.g. qbittorent, piece by piece, maybe with some minor deviations).
Thank you!

@anacrolix
Copy link
Owner

@antonsoroko not currently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants