Friday, August 10, 2012

Setting up OMXPlayer GUI on the Raspberry Pi (Updated)

This is a nice little trick to get OMXPlayer to work nice and pretty within the file manager so that the keypresses work and you don't need to use the command line. 

I got my Raspberry Pi in the mail and started setting it up as a  media server with my projector, external HDDs, and sound system.

You can do this in Arch Arm or in Raspbian Wheezy (It's easier in Wheezy since in Arch you have to get LXDE and omxplayer installed).

First thing, I noticed that the resolution auto-selection script didn't work properly with my projector.
I went into /opt/vc/bin and ran:
tvservice -d /home/pi/projector
edidparser /home/pi/projector /home/pi/available

Most of the options you need to change are in /boot/config.txt

This will give you the available resolutions. Each one has a code associated with it and is either a CEA code (hdmi_group=1) or a DMT code (hdmi_group=2). Then you can set the code with the hdmi_mode=? (I like hdmi_mode=15 and hmdi_mode=5).
Sometimes audio doesn't work over HDMI. If it doesn't, set hdmi_drive=2

Overclocking the Raspberry Pi is really easy, you can definitely get up to 850 MHz by adding this into the /boot/config.txt file:

I got up to 1 GHz easily with the following options:

I made the mistake of installing vlc. Don't! The ARM processor can't really handle it (unless overclocked and then it's still buggy).
Use omxplayer instead.

Unfortunately omxplayer is a command line tool and that can get bothersome. To easily get around this and use it, install xterm by running:

Note: You don't have to use xterm, you can use the built in lxterminal instead by replacing xterm with lxterminal in all the examples below. However, xterm allows for the nice fullscreen option that omxplayer messes up.

sudo apt-get install xterm

Then right click one of your avi files and select open with, then click custom command line tool, type in:
xterm -fullscreen -fg black -bg black -e omxplayer -o hdmi -r %f

and check the box saying always do this so you only have to double click on any avi file in the future and it will do the same thing.

This opens up omxplayer in a new terminal so the key presses, such as p (pause) and q (quit), work. It also opens it up in fullscreen (the -r flag and the -fullscreen flag for xterm). Note: The rest of the display goes to sleep after a while so if the screen is black when the movie quits, shake the mouse or press a key to wake it up.

Omxplayer Problems

For detail on issues and how to fix them, see here:
Updating Raspberry Pi packages, kernel, and firmware (also fixing omxplayer)

If you are having problems with the video not working or not showing or the screen locking, make sure your raspberry pi is up to date by running:
sudo apt-get update && sudo apt-get upgrade

**HELP my mouse and keyboard don't work  (SOLUTION)**
If it still doesn't work, you may need to upgrade your firmware (which is generally a good idea anyways) using:
sudo apt-get -y dist-upgrade
and also 
sudo rpi-update
The guide for updating your firmware can be found here:

Also make sure your gpu_mem split is at a reasonable level such as 128/128 by adding the line
in the /boot/config.txt file in the newer firmware versions

To be able to easily find and intelligently play videos automatically, see this page:

Omxplayer Key Bindings:

  • 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
  • q Exit
  • Space or p Pause/Resume
  • - Decrease Volume
  • + Increase Volume
  • Left Seek -30
  • Right Seek +30
  • Down Seek -600
  • Up Seek +600

Check out my other Raspberry Pi Fixes/How tos:

Consider donating to further my tinkering.

Places you can find me