Sunday, October 18, 2015

Peerflix: Stream Torrents With VLC Or MPlayer Via Command Line

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, then install Peerflix using "npm install -g peerflix".

1. To install Peerflix in Ubuntu, firstly you'll have to add the Node.js PPA and install nodejs:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
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/failsdownloads/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/failsdownloads/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)

Example:
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

Peerflix

Then open some video player like Totem for instance, select to open location and enter the location displayed by Peerflix ("http://192.168.1.6:8888/" 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 torrent_file_or_url [options]

Options:
-c, --connections max connected peers [default: 100]
-p, --port change the http port [default: 8888]
-i, --index changed streamed file (index)
-t, --subtitles load subtitles file
-q, --quiet be quiet
-v, --vlc autoplay in vlc*
-m, --mplayer autoplay in mplayer**
-o, --omx autoplay in omx**
-j, --jack autoplay in omx** using the audio jack
--clean remove the tmp buffer file after peerflix closes
--path change buffer file path

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

No comments:

Post a Comment