bittorrent2player

NAME
DESCRIPTION
OPTIONS
EXAMPLES
AUTHOR

NAME

bittorrent2player - transfers data from the BitTorrent network to another protocol (currently HTTP) which is more suitable for media players

DESCRIPTION

*

Server - this program. Server consists of 2 parts: a BitTorrent client and a HTTP server.

*

Client - a program which reads data from the HTTP part of Server. Typically Client is a media (video, audio) player.

*

Peer - a computer in the network which sends data to the BitTorrent part of Server.

*

piece_size - Data in a torrent are divided into parts, called "pieces", each part is of size "piece_size". This is a property of the BitTorrent protocol. To learn how to determine this parameter, search "parameters of the torrent" in this document.

*

media_speed - speed (bitrate) of all streams (video, audio) which Client reads. E.g. if you play a "mkv" file with streams "video 2 Mb/s, audio 0.2 Mb/s" and external audio in a "mp3" file "audio 0.4 Mb/s", then video_speed=2+0.2+0.4.

Server can manage only 1 torrent. Server lists files and some parameters of the torrent on the HTML page accessible via HTTP at "/". That page also shows hyperlinks to the files of the torrent.

Client should use a big buffer and a long connection timeout. You can calculate the timeout and size of the buffer by formulas given in the explanation of the option --piece-par or adjust them experimentally. Practically every media player implements a buffer inside, you just need to enable it. The connection timeout implemented in "mplayer" by default is insufficient, change it with http://www.beroal.in.ua/prg/bittorrent2player/mplayer-big-timeout.patch .

"bt2p" is the official abbreviation of the name of this program.

OPTIONS

--hash-file and --save-path are mandatory. See default values of options in the source code, the file "main.py", search "configuration" there.
--save-path=$X

Save downloaded data to the directory X. If X contains a partially downloaded file, Server will catch it, like normal BitTorrent clients do.

BitTorrent parameters
--hash-file=$X

Download the torrent which is described by the file X. X normally has the extension "torrent".

--piece-par=$X

Server downloads X pieces in parallel. If X=1, then your downloading speed is most likely several times less then the speed of your internet connection. This is due to a fact that downloading speed of a piece is 0 during some intervals of time due to unpredictability of the BitTorrent network. If several pieces are downloaded in parallel and if some piece is not completed but its speed is 0, another piece probably has non-0 speed.

It should be > internet_speed*piece_downloading_time/piece_size, where "piece_downloading_time" is a period of time from the moment when downloading of some piece is turned on to the moment when this piece is completed. In practice the parameter "piece_downloading_time" depends on "quality" of Peers of a particular torrent, i.e. it is hard to choose the optimal X once and for all.

To understand further discussion you need to know how Server downloads pieces. When Client requests some byte in some piece Y, Server turns on downloading of a sequence (called "S" below) of pieces, S has length X and the first piece in S is Y.

Increasing X has this drawback: if Client requests the last byte of a file, Server downloads X-1 unnecessary pieces.

Pieces in S are downloaded in whatever order, the worst case is when the first piece in S is downloaded last. Client reads a file sequentially, therefore Client does not receive any data until all pieces in S is downloaded. Let par_size=piece_par*piece_size. Therefore Client’s connection timeout >par_size/media_speed. Further, Client is feeding on its buffer during downloading of S, so size of Client’s buffer >par_size.

You can change this option during the operation of Server, by sending to Server’s HTTP part a "GET" request "/?piece_par=$PIECE_PAR".
--resume=$X

Server reads/writes so called "resume data" of a torrent from/to the file X. This allows faster startup of dowloading. Read about "resume data" on http://www.rasterbar.com/products/libtorrent/manual.html#save-resume-data .

HTTP parameters
--domain-name=$X
--port=$X

Logging
Either of the options below turns on logging.

--log

Parameters of logging is in the file "/etc/bittorrent2player/logging.conf".

--log-conf=$X

Parameters of logging is in the file X. How to write parameters of logging is described in the Python manual at http://docs.python.org/library/logging.html , see also an example on http://docs.python.org/howto/logging.html#configuring-logging .

EXAMPLES

bittorrent2player --hash-file=/tmp/movie.torrent --save-path=/tmp

mplayer -cache 32768 -cache-min 20 http://127.0.0.1:17580/movie.avi

AUTHOR

This manual page was written by Roman Beslik <rabeslik@gmail.com>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Lesser General Public License, version 2.1 or any later version published by the Free Software Foundation