For the past 2-3 hours I have been watching movies on my television in my living room from a memory stick through my Raspberry Pi all without bothering with GUI interface and only using the command line interface to do it. And here’s how!
First I made sure that their was a media player installed that could be run from the command line, lucky for me I had one already installed called omxplayer and you probably do too! But in case you don’t here is the command to install it:
sudo apt-get install omxplayer
Of course you will need to be connected to the internet to use this but that’s the only time you will need to be connected for this tutorial so after installing omxplayer you can take your Pi wherever you like without worrying about an internet connection, which is handy because my living room hasn’t got one yet, and I have had trouble using my wireless dongle in the past.
To make sure it’s installed correctly, try running it:
You should get output that looks something like this:
Usage: omxplayer [OPTIONS] [FILE] Options : -h / --help print this help -n / --aidx index audio stream index : e.g. 1 -o / --adev device audio out device : e.g. hdmi/local -i / --info dump stream format and exit -s / --stats pts and buffer stats -p / --passthrough audio passthrough -d / --deinterlace deinterlacing -w / --hw hw audio decoding -3 / --3d switch tv into 3d mode -y / --hdmiclocksync adjust display refresh rate to match video -t / --sid index show subtitle with index -r / --refresh adjust framerate/resolution to video --boost-on-downmix boost volume when downmixing --subtitles path external subtitles in UTF-8 srt format --font path subtitle font (default: /usr/share/fonts/truetype/freefont/FreeSans.ttf) --font-size size font size as thousandths of screen height (default: 55) --align left/center subtitle alignment (default: left) --lines n number of lines to accommodate in the subtitle buffer (default: 3)
Now you have omxplayer installed on your Raspberry Pi you can simply play media files on it and have the audio come out of the HDMI lead using the command:
omxplayer -o hdmi [Your-File-here]
But if like me you want to be able to play media off a memory stick plugged into your Raspberry Pi you will also need to mount it when it’s been plugged in! I found a good guide on how to do this here.
Basically the gist of it is that you need to create a directory in your /mnt/ folder for the device you want to mount, I went with the folder name usb:
sudo mkdir /mnt/usb
Then all you need to do is mount the drive to that directory using the command:
sudo mount /dev/sda1 /mnt/usb
NOTE: Your device might not be sda1! You will need to find out what device it is! I found a good tutorial about this here. Again, the gist of it is as follows:
Run the command:
tail -f /var/log/messages
Then simply plug in your memory stick and you should see a few messages appear telling you what your device is called.
Now you can run your mount command using the right parameters! After doing this you should then change directory to where you mounted the memory stick to (in my case /mnt/usb) and run omxplayer on the media using the aforementioned command.
Something to note about controlling playback is that from what I read on the omxplayer website there doesn’t appear to be a way of specifying a time stamp to start watching from, the only controls are:
z Show Info 1 Increase Speed 2 Decrease Speed j Previous Audio stream k Next Audio stream i Previous Chapter o Next Chapter n Previous Subtitle stream m Next Subtitle stream s Toggle subtitles d Subtitle delay -250 ms f Subtitle delay +250 ms q Exit OMXPlayer Space or p Pause/Resume - Decrease Volume + Increase Volume Left Arrow Seek -30 Right Arrow Seek +30 Down Arrow Seek -600 Up Arrow Seek +600
But those are adequate enough for the most part! Hopefully this will come in handy for anyone not wanting to install XBMC!