Ubuntu / Linux news and application reviews.

Peerflix is an experimental video streaming BitTorrent client for Node.js. The tool can be used to stream video torrents via command line and play the stream with your favorite video player, such as VLC or MPlayer.

Peerflix Ubuntu VLC

Peerflix supports supports setting the maximum number of connections, changing the port, loading subtitles and more.

The application even supports streaming torrents with multiple video files, although I'm not sure if the video files are played in order (if you try it, let us know in the comments).

Peerflix is actually what Popcorn Time uses under the hood, but you can use it separately so you can stream any video torrent and use any video player you want.

Install Peerflix in Ubuntu

Peerflix should work with most Linux distributions, but the instructions below are for Ubuntu only. For other Linux distributions, install Node.js (you can find official repositories for various distros HERE), then install Peerflix using "npm install -g peerflix".

1. To install Peerflix in Ubuntu or Linux Mint, firstly you'll have to add the Node.js reposiktory and install nodejs:
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install nodejs

2. Next, install Peerflix using the following command:
sudo npm install -g peerflix

Update -> Arch Linux users can install Peerflix via AUR: stable | git.

Optional: Firefox integration (via Pinguy)

Pinguy shared some tweaks for integrating Firefox with Peerflix for both regular torrents and magnet links. Using these tweaks, you'll be able to open torrent files and magnet links from Firefox with Peerflix and directly play them with VLC.

Below you can watch a quick video I recorded a few minutes ago, demoing Peerflix (with VLC) streaming torrents directly from Firefox:

(direct video link)

To set up these tweaks, use the instructions below (requires VLC).

Setting this in Chrome is more complicated, here's an example.

1. Firstly, install vlc, xterm, python-libtorrent and wget:
sudo apt-get install vlc xterm python-libtorrent wget

2. To be able to open torrent files from Firefox and play them with VLC via Peerflix, use the commands below:
wget https://raw.github.com/hotice/webupd8/master/Torrent-Video-Player -O /tmp/Torrent-Video-Player
sudo install /tmp/Torrent-Video-Player /usr/local/bin/
Then, open your web browser and click a video torrent. When it asks what app to use, select Other and browse for /usr/local/bin/Torrent-Video-Player

3. For Magnet Links support, use the commands below:
wget https://raw.github.com/danfolkes/Magnet2Torrent/master/Magnet_To_Torrent2.py -O /tmp/Magnet_To_Torrent2.py
sudo install /tmp/Magnet_To_Torrent2.py /usr/local/bin/
wget https://raw.github.com/hotice/webupd8/master/Magnet-Video-Player -O /tmp/Magnet-Video-Player
sudo install /tmp/Magnet-Video-Player /usr/local/bin/
And just like above, open Firefox, click a magnet link, select Other and browser for /usr/local/bin/Magnet-Video-Player

Using Peerflix

Using the extra tweaks above, you basically don't have to do anything else. But if you want to use Peerflix manually (for instance, to use your favourite video player), here's a quick guide.

To stream a torrent with Peerflix and play it with VLC, use the following command:
peerflix http://some-torrent/movie.torrent --vlc
(replacing "some-torrent/movie.torrent with the link to a video torrent file; update: magnet links are now also supported, so you can use a magnet link instead of a a torrent file link)

peerflix http://download.stefan.ubbink.org/ToS/tears_of_steel_1080p.webm.torrent --vlc

To automatically play the video in MPlayer instead of VLC, use the following command:
peerflix http://some-torrent/movie.torrent --mplayer

If you don't want to use VLC or MPlayer, simply don't append "--vlc" or "--mplayer" to the Peerflix command. Example:
peerflix http://download.stefan.ubbink.org/ToS/tears_of_steel_1080p.webm.torrent


Then open some video player like Totem for instance, select to open location and enter the location displayed by Peerflix ("" in my case - see screenshot above).

It's also worth mentioning that you don't have to use a torrent link - you can use Peerflix with a locally saved torrent file too:
peerflix somevideo.torrent

Peerflix also supports setting the maximum number of connections, changing the port, loading subtitles and more. Here's the complete list of options:
$ peerflix --help
Usage: peerflix magnet-link-or-torrent [options]

  -c, --connections  max connected peers                            [default: 100]
  -p, --port         change the http port                           [default: 8888]
  -i, --index        changed streamed file (index)                
  -l, --list         list available files with corresponding index
  -t, --subtitles    load subtitles file                          
  -q, --quiet        be quiet                                     
  -v, --vlc          autoplay in vlc*                             
  -s, --airplay      autoplay via AirPlay                         
  -m, --mplayer      autoplay in mplayer*                         
  -g, --smplayer     autoplay in smplayer*                        
  --mpchc            autoplay in MPC-HC player*                   
  --potplayer        autoplay in Potplayer*                       
  -k, --mpv          autoplay in mpv*                             
  -o, --omx          autoplay in omx**                            
  -w, --webplay      autoplay in webplay                          
  -j, --jack         autoplay in omx** using the audio jack       
  -f, --path         change buffer file path                      
  -b, --blocklist    use the specified blocklist                  
  -n, --no-quit      do not quit peerflix on vlc exit             
  -a, --all          select all files in the torrent              
  -r, --remove       remove files on exit                         
  -h, --hostname     host name or IP to bind the server to        
  -e, --peer         add peer by ip:port                          
  -x, --peer-port    set peer listening port                      
  -d, --not-on-top   do not float video on top                    
  --on-downloaded    script to call when file is 100% downloaded  
  --on-listening     script to call when server goes live         
  --version          prints current version                       

Options passed after -- will be passed to your player

  "peerflix magnet-link --vlc -- --fullscreen" will pass --fullscreen to vlc

* Autoplay can take several seconds to start since it needs to wait for the first piece
** OMX player is the default Raspbian video player