Play .rar files with mplayer v2.0: now with seeking

It really started bothering me that its impossible to seek in media files when using my previous playrar script:

Now im writing a bit more complex version which supports seeking!

I got a tips about using rarfs, a FUSE based filesystem mounter. What it does is making your .rar archives into a virtual filesystem. (like the .rar archive really isnt a archive, but real files on a filesystem)
This makes your media files seekable. (mkv,avi,iso(vob), younameit)

Firstly you need to install rarfs on your system. You need to install some deps:
sudo apt-get install automake1.9 libfuse-dev subversion
When you have done this, you are ready to checkout the svn tree on sourceforge:
svn co https://rarfs.svn.sourceforge.net/svnroot/rarfs rarfs
cd rarfs/trunk/rarfs/
./configure && make && sudo make install

(seems here i got a error with doc/Makefile.in, borked release in trunk)
FIX: touch doc/Makefile.in
./configure
make
sudo make install
ls -l /usr/local/bin/rarfs

If it returned your file in /usr/local/bin/rarfs we are good to go!

Now we can mount a .rar file with the following command: rarfs bladdiblah.rar /tmp/rar
This seems a bit hard to type everytime you want to play a file, so we make a shellscript to fix this:
#!/bin/bash
RARFILE=$1
TMPDIR="/tmp/playrar/"
RARFS="/usr/local/bin/rarfs"
if [ ! -d /tmp/playrar ]; then
mkdir -p /tmp/playrar
fi
$RARFS $RARFILE $TMPDIR
mplayer -fs $TMPDIR/`ls $TMPDIR`
fusermount -u $TMPDIR

What this script does, is to mount the file, play the files inside the rar file, and then unmount the .rar archive.
You can easily wget this script: playrar.sh
Place it in $PATH and give it chmod +x playrar.sh (and change your media player as suited)

This howto was intended to Ubuntu users, but should be done on other linux distributions as well (maybe OS X as well?)

One step closer to easier movie playback :-)

Be Sociable, Share!

Tags: , , ,

3 Responses to “Play .rar files with mplayer v2.0: now with seeking”

  1. Play .rar files with vlc / mplayer | dingleberry.me Says:

    [...] Play .rar files with mplayer v2.0: now with seeking | dingleberry.me Says: August 9th, 2009 at 11:58 [...]

  2. Angus Says:

    This is a cool trick. It does have problems with playing more than one file in an archive and also playing files with spaces in the names. The way that I fixed these issues was to change “mplayer -fs $TMPDIR/`ls $TMPDIR`” to “find $TMPDIR -type f -exec mplayer -fs ‘{}’ +”. I also had to add “all” and “install” targets to the makefile in rarfs/doc in addition to creating the file “doc/Makefile.in” to get rarfs to install properly.

    Thanks

  3. ssn Says:

    This does not work with newer Ubuntu versions (im running lucid). Even if you link the install.sh to the newer automake, ./configure and make fail.

Leave a Reply