#1: BitTorrent integration

Contents
  1. Motivation
  2. Proposal
  3. Progress log
  4. Participants
by and_ last modified Jun 11, 2006 12:20 AM

When a file is uploaded to the server a .torrent is automatically created for the video and is displayed along with the number of seeders and downloaders on the video display page.

Proposed by
and_
Seconded by
Nate Aune
Proposal type
User interface, Architecture
Repository branch
bittorrent
State
in-progress

Motivation

BitTorrent is a peer-2-peer application that distributes the load of serving large video files amongst many computers. It reduces bandwidth costs and can speed up the rate of download.

Proposal

When video files are uploaded to the server via http/ftp/tramline a script is run to create a .torrent file. The tracker is then listed on the video display page along with the number of current seeders and downloaders.

Look at how http://www.blogtorrent.com does it using PHP.
BroadCast Machine http://participatoryculture.org/broadcast/ is also using PHP.
Demo site http://participatoryculture.org/demo/bm/library.php?i=1

Progress log

On the snowsprint 2006 Andy and me (Wolfgang) worked on the BitTorrent integration into ATVideo. The results of this work is this:

  • all the BitTorrent stuff is in ATMediaFile, because then it can be used for all ATMediaFile based contenttypes
  • work has been done in the bittorrent branch of ATMediaFile and ATVideo
  • we use BitTorrent 4.4.x (has support for twisted)
  • a howto install is in the bt_server directory
  • i added a portal tool to ATMediaFile for configuration of the BitTorrent support: you can enable/disable (disabled by default) the BitTorrent support and you can configure the tracker url (will be hardcoded into each newly created BitTorrent file)
  • the portal tool has a function which checks for BitTorrent support and returns True or False
  • ATVideo has 3 lines of code in the process form method to create the .torrent file - but it's checked if support is enabled otherwise no .torrent will be created
  • tramline support is included (experimental)
  • relies on ExternalStorage
  • when using ExternalStorage the process is as follows: the portal tool has a function (createTorrent) which has the (video) file object as a parameter. From this file the BitTorrent python script (maketorrent.py) computes the hash, gets the trackerurl from the preferences and then creates the .torrent file which will be stored right next to the (video)file in the ExternalStorage repository on the filesystem. Then - this can be used for transcoding maybe in a similar way - the .torrent file gets renamed to <filename>_tmp, a new object of type "BitTorrentFile" gets created in the ZODB with the same name as the .torrent file on the filesystem and the resulting (empty) file on the extenal storage repository gets deleted and the tempfile gets renamed to its original filename. With this workaround its possible to inject a file on the filesystem into the ZODB without the need of reading and storing the file contents in the memory, nor is it nessecary to copy the file on the filesystem. After the .torrent got created on the filesystem and succesfully got injected into ZODB the resulting BitTorrentFile object gets related with the (video)fileobject and as a result you have a (video)object with its corresponding .torrent nicely show in Plone :-)
  • to seed the files you can use the python script "launchmany-console.py" of the BitTorrent source installation to scan a folder on the filesystem recursively (best to use the ExternalStorage repository directory). It scans this directory all 60 sec (can be changed) and seeds each new .torrent file automatically
  • to run your own tracker use "bittorrent-tracker.py" - the usage of both scripts is documented in the INSTALL.txt and README.txt in the bt_server folder of ATMediaFile
  • if your server is behind a NAT router or a firewall make sure to open port 6969 for the tracker and range 6881 - 6999 (default port range) and maybe range 49152 - 65535 (suggested by azureus) to have the best possible performace for your BitTorrent system

SVN repositories:

https://svn.plone.org/svn/collective/ATMediaFile/branches/bittorrent/

https://svn.plone.org/svn/collective/ATVideo/branches/bittorrent/

Participants

_and <andy (at) cat.org.au>

wreutz <wolfgang.reutz (at) vol.at>

Comments (1)

andy nicholson Jan 24, 2006 06:16 PM