I'm working on setting up a mediacentre controlled over http (through a smartphone web interface). Have successfully got omxplayer set up and running to play a video on command from the web server, however i can't seem to find any way to interact with the player while its running.
Does omxplayer have any facility for user input (play/pause/fast-forward/volume etc) via a command or pipe input?
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 5708
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: omxplayer play controls / input
You can ssh in to pi, and then the keypresses work for play/pause/skip.
However it would be nice to have a http interface for control like xbmc.
However it would be nice to have a http interface for control like xbmc.
Re: omxplayer play controls / input
cheers for the speedy reply dom, but keypresses alone don't seem to do anything... do i need to echo them to a display or a pipe or what? typing into an ssh shell alone wont/doesnt do anything surely?
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 5708
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: omxplayer play controls / input
Yes, from ssh shell that launches omxplayer, typing 'q' will quit, left will skip backwards, right will skip forwards etc.
Re: omxplayer play controls / input
ah yes... not quite sure how i missed that... thnx...
next question... d'ya rekkon i could pipe that input into it from a different shell session?
next question... d'ya rekkon i could pipe that input into it from a different shell session?
Re: omxplayer play controls / input
Tried controlling omxplayer using Putty on a Windows laptop, a Fedora/LXDE laptop, and also on the pi as localhost. However no success.
I can run the video and ^C stops it but it does no respond to keypresses while running. I am using the .deb version of omxplayer.
Any ideas what I might be doing wrong.
I'm trying to do something similar to Alan but I want to eventually use buttons attached to the GPIO for play and pause
Alan, could use a python or php ssh client package running from the webserver, I would use one to poll the GPIO.
I can run the video and ^C stops it but it does no respond to keypresses while running. I am using the .deb version of omxplayer.
Any ideas what I might be doing wrong.
I'm trying to do something similar to Alan but I want to eventually use buttons attached to the GPIO for play and pause
Alan, could use a python or php ssh client package running from the webserver, I would use one to poll the GPIO.
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com
Download from http://pipresents.wordpress.com
Re: omxplayer play controls / input
OK managed to get input into omxplayer from a separate process, albeit by a rather convoluted method. If anyone has any ideas about improving/streamlining the process please let me know, as i cant help but feel this method is somewhat wasteful...
For reference this is the Debian img from the download page.
rPI boots up, autologin and starts a script process (lets call it runtime.php - i wrote it in php cos it's what i know best)
The script process basically runs in an infinite loop, sleeping for half a second each time, checking a certain file (lets call it input.txt) for changes, and running functions based on the updated content...
A separate php script running on an apache server (for the web interface) sends commands to input.txt (e.g. play file, pause, ffwd, rewind)
Now the convoluted part... back in runtime.php, when a play command is received, it opens up an ssh shell via php-ssh2 to itself, and runs the omxplayer command through that. This means that there is a persistent connection to omxplayer to pass commands to.
Next, when a pause command is passed from the web server, via input.txt, to runtime.php, it then writes a 'p' to the ssh shell (which at this point is listening for omxplayer). This has the desired effect of pausing the player.
As I said, it works, but just seems over complicated. Plus i cant get the volume to work (but that might just be omx). I've attached an image of the process flow as best as i can describe it visually -
For reference this is the Debian img from the download page.
rPI boots up, autologin and starts a script process (lets call it runtime.php - i wrote it in php cos it's what i know best)
The script process basically runs in an infinite loop, sleeping for half a second each time, checking a certain file (lets call it input.txt) for changes, and running functions based on the updated content...
A separate php script running on an apache server (for the web interface) sends commands to input.txt (e.g. play file, pause, ffwd, rewind)
Now the convoluted part... back in runtime.php, when a play command is received, it opens up an ssh shell via php-ssh2 to itself, and runs the omxplayer command through that. This means that there is a persistent connection to omxplayer to pass commands to.
Next, when a pause command is passed from the web server, via input.txt, to runtime.php, it then writes a 'p' to the ssh shell (which at this point is listening for omxplayer). This has the desired effect of pausing the player.
As I said, it works, but just seems over complicated. Plus i cant get the volume to work (but that might just be omx). I've attached an image of the process flow as best as i can describe it visually -
-
- Posts: 39
- Joined: Tue Jun 05, 2012 3:00 am
Re: omxplayer play controls / input
I would love to see some more control over omxplayer. I hate that you have to start the video at the beginning and just keep on hitting the right key until you get to the part you wanted to watch. Very tedious.
- slackstone
- Posts: 1
- Joined: Sat Jun 02, 2012 2:33 am
- Contact: Website
Re: omxplayer play controls / input
I'm following this thread with interest. It would be great if you could pipe commands to the omxplayer. I've tried to echo "p" to /dev/tty which works but omxplayer doesn't see the key. Someone on IRC gave the suggestion of using FIFO to accomplish this. Piping commands (keys) between processes is a move I've never done before so I've had no luck with this -- yet. If anyone has a good idea on how to accomplish please share. (syntax sample)
Seems like there should be a simpler solution to what's presented above.
Also, omxplayer on RPI is great! does a fine job at playing my collection.
Seems like there should be a simpler solution to what's presented above.
Also, omxplayer on RPI is great! does a fine job at playing my collection.
Re: omxplayer play controls / input
Ok I had some success with the following (running standard debian image);
mkfifo /tmp/cmd
omxplayer -ohdmi mymedia.avi < /tmp/cmd
echo . > /tmp/cmd (Start omxplayer running as the command will initial wait for input via the fifo)
echo -n p > /tmp/cmd - Playback is paused
echo -n q > /tmp/cmd - Playback quits
Would really like to get this running via a simple web interface alongside airplay, I currently have shairport running on the standard debian image for audio streaming and would like to try getting airplay video (via airplayer.py) streaming to enable me to play videos off my NAS via a web interface or streaming services like iPlayer via an iPad.
mkfifo /tmp/cmd
omxplayer -ohdmi mymedia.avi < /tmp/cmd
echo . > /tmp/cmd (Start omxplayer running as the command will initial wait for input via the fifo)
echo -n p > /tmp/cmd - Playback is paused
echo -n q > /tmp/cmd - Playback quits
Would really like to get this running via a simple web interface alongside airplay, I currently have shairport running on the standard debian image for audio streaming and would like to try getting airplay video (via airplayer.py) streaming to enable me to play videos off my NAS via a web interface or streaming services like iPlayer via an iPad.
Re: omxplayer play controls / input
Ahhh now thats the method i was looking for! Bugger all this ssh-to-self malarkey! Will be rewriting to version 2 this weekend then!
Easiest way to control over http would be set up a lamp server and use php to issue the shell commands via ajax requests from a browser. Working on my own implementation using a Sencha Touch SDK for a proper app styley ui =)
As for nas playback, the easiest solution i found was to use fusesmb (sudo apt-get install fusesmb). It will scan the local network for windows shares and mount all of them in a specified directory. That way omxplayer will be playing 'local' files and roberts-your-relative.
Easiest way to control over http would be set up a lamp server and use php to issue the shell commands via ajax requests from a browser. Working on my own implementation using a Sencha Touch SDK for a proper app styley ui =)
As for nas playback, the easiest solution i found was to use fusesmb (sudo apt-get install fusesmb). It will scan the local network for windows shares and mount all of them in a specified directory. That way omxplayer will be playing 'local' files and roberts-your-relative.
Re: omxplayer play controls / input
Alanpich
Would love to look at your web interface if your willing to share !
Would love to look at your web interface if your willing to share !
Re: omxplayer play controls / input
Once it's built i'll post some screenies or a demo somewhere. It's just ugly text/html atm till i got the control interface sorted.
I'll see if i can put together an easy-install javascript/php for omxplayer
I'll see if i can put together an easy-install javascript/php for omxplayer
Re: omxplayer play controls / input
Ok here's the the very basic scripts I put together based on using a fifo to control omxplayer it allows me to select a video from a form, play it then pause or stop playback from a web browser;
============= index.cgi ============
#!/bin/bash -e
echo "Content-type: text/html"
echo ""
echo "<html><body>"
echo "<h3>Movie Player</h3>"
echo "<br>"
echo "<form action="/cgi-bin/check.cgi" method="get">"
echo "<select name="movie">"
for myfiles in /mnt/media/Videos/LowDef/*
do
video=$(basename "$myfiles")
echo "<option>$video</option>"
done
echo "<input type="submit" value="Play" />"
echo "</select></form></body></html>"
================check.cgi=================
#!/bin/bash
movie=`echo "$QUERY_STRING" | sed -n 's/^.*movie=\([^&]*\).*$/\1/p' | sed -e 's/+/ /g'`
movie="/mnt/media/Videos/LowDef/$movie"
echo "Content-type: text/html"
echo ""
echo "<html><body>"
echo "<h3>Movie Player</h3>"
echo "<br>"
echo $movie
echo "<br>"
echo "<a href="/cgi-bin/pause.cgi">Pause</a>"
echo "<a href="/cgi-bin/stop.cgi">stop</a>"
echo "<a href="/">Home</a></body></html>"
/var/www/cgi-bin/movie2.sh "$movie" >&- &2>-&
==============movie2.sh==============
#!/bin/bash
echo $1 > /tmp/mylog
/var/www/cgi-bin/startplay.sh&
/usr/bin/omxplayer -ohdmi "$1" </tmp/cmd
=============startplay.sh=============
#!/bin/sh
sleep 1
echo -n . >/tmp/cmd
===========stop.cgi==============
#!/bin/sh
echo -n q >/tmp/cmd
============pause.cgi===========
#!/bin/sh
echo -n p >/tmp/cmd
============= index.cgi ============
#!/bin/bash -e
echo "Content-type: text/html"
echo ""
echo "<html><body>"
echo "<h3>Movie Player</h3>"
echo "<br>"
echo "<form action="/cgi-bin/check.cgi" method="get">"
echo "<select name="movie">"
for myfiles in /mnt/media/Videos/LowDef/*
do
video=$(basename "$myfiles")
echo "<option>$video</option>"
done
echo "<input type="submit" value="Play" />"
echo "</select></form></body></html>"
================check.cgi=================
#!/bin/bash
movie=`echo "$QUERY_STRING" | sed -n 's/^.*movie=\([^&]*\).*$/\1/p' | sed -e 's/+/ /g'`
movie="/mnt/media/Videos/LowDef/$movie"
echo "Content-type: text/html"
echo ""
echo "<html><body>"
echo "<h3>Movie Player</h3>"
echo "<br>"
echo $movie
echo "<br>"
echo "<a href="/cgi-bin/pause.cgi">Pause</a>"
echo "<a href="/cgi-bin/stop.cgi">stop</a>"
echo "<a href="/">Home</a></body></html>"
/var/www/cgi-bin/movie2.sh "$movie" >&- &2>-&
==============movie2.sh==============
#!/bin/bash
echo $1 > /tmp/mylog
/var/www/cgi-bin/startplay.sh&
/usr/bin/omxplayer -ohdmi "$1" </tmp/cmd
=============startplay.sh=============
#!/bin/sh
sleep 1
echo -n . >/tmp/cmd
===========stop.cgi==============
#!/bin/sh
echo -n q >/tmp/cmd
============pause.cgi===========
#!/bin/sh
echo -n p >/tmp/cmd
Re: omxplayer play controls / input
I like this 
I'm also impressed with omxplayer, great quality & performance - I also love being able to control it via command line over SSH, but my family were less impressed by me getting them to press 'p' on my android phone
So I wondered about hacking together an android app to act as a GUI, but implementing a web interface would be much easier!
I'd also love to be able to hack the get_iplayer web-based PVR GUI to have a button to play recorded shows in omxplayer....
And then there's youtube with yt/whitey...

I'm also impressed with omxplayer, great quality & performance - I also love being able to control it via command line over SSH, but my family were less impressed by me getting them to press 'p' on my android phone

So I wondered about hacking together an android app to act as a GUI, but implementing a web interface would be much easier!
I'd also love to be able to hack the get_iplayer web-based PVR GUI to have a button to play recorded shows in omxplayer....
And then there's youtube with yt/whitey...

I ate all the Pi
Re: omxplayer play controls / input
nice n concise joeh... far simpler than my first attempt... will definitely be taking that on board.
for those who are interested, I plan to keep my web interface source on github at https://github.com/alanpich/rPImc
I will also be maintaining an installer script to make setup from scratch a breeze:https://github.com/alanpich/rPI-media-centre-installer
for those who are interested, I plan to keep my web interface source on github at https://github.com/alanpich/rPImc
I will also be maintaining an installer script to make setup from scratch a breeze:https://github.com/alanpich/rPI-media-centre-installer
Re: omxplayer play controls / input
This is great !! I didn't even think about using "< fifo" for controling omxplayer
@Joeh : Did you try to write an airplayer Media Backends for omxplayer using this fifo method ?
@Joeh : Did you try to write an airplayer Media Backends for omxplayer using this fifo method ?
Re: omxplayer play controls / input
Just a quick update for those who could be interested.
"Right arrow" and "Left arrow" allow you to "fast forward/backward" with omxplayer.
To simulate it using fifo to control omxplayer you can :
#Right arrow :
echo -n $'\x1b\x5b\x43' > /tmp/cmd
#Left arrow :
echo -n $'\x1b\x5b\x44' > /tmp/cmd
"forward/backward" work when playing from the local SDCard or a plugged USB Stick, but don't when playing from "http://"
Works with either movies or mp3 (any thing you can feed omxplayer with I guess).
----
There is many others keys that can control volume, subtitles, etc ... <- See :
https://github.com/huceke/omxplayer/blo ... player.cpp
Example :
z : m_tv_show_info = !m_tv_show_info;
1 : SetSpeed(m_av_clock->OMXPlaySpeed() - 1);
2 : SetSpeed(m_av_clock->OMXPlaySpeed() + 1);
j : m_omx_reader.SetActiveStream(OMXSTREAM_AUDIO, m_omx_reader.GetAudioIndex() - 1);
k : m_omx_reader.SetActiveStream(OMXSTREAM_AUDIO, m_omx_reader.GetAudioIndex() + 1);
etc ...
I have not been able to use "+" and "-" for controlling volume
This has been added just a few days ago <- See : https://github.com/huceke/omxplayer/com ... 24cb828ffe
The omxplayer binaries included in Wheezy must be older than that.
I will try recompiling it using dom's (really really quick) instructions and tell you <- see : http://www.raspberrypi.org/phpBB3/viewt ... f=2&t=5061
Last time a tried this same set of instructions for compiling XBMC, I couldn't pass the step : "make -C tools/rbp/depends all" ; <- see :
http://www.raspberrypi.org/phpBB3/viewt ... f=9&t=5037
I always had this error on the build machine :
XavM
"Right arrow" and "Left arrow" allow you to "fast forward/backward" with omxplayer.
To simulate it using fifo to control omxplayer you can :
#Right arrow :
echo -n $'\x1b\x5b\x43' > /tmp/cmd
#Left arrow :
echo -n $'\x1b\x5b\x44' > /tmp/cmd
"forward/backward" work when playing from the local SDCard or a plugged USB Stick, but don't when playing from "http://"
Works with either movies or mp3 (any thing you can feed omxplayer with I guess).
----
There is many others keys that can control volume, subtitles, etc ... <- See :
https://github.com/huceke/omxplayer/blo ... player.cpp
Example :
z : m_tv_show_info = !m_tv_show_info;
1 : SetSpeed(m_av_clock->OMXPlaySpeed() - 1);
2 : SetSpeed(m_av_clock->OMXPlaySpeed() + 1);
j : m_omx_reader.SetActiveStream(OMXSTREAM_AUDIO, m_omx_reader.GetAudioIndex() - 1);
k : m_omx_reader.SetActiveStream(OMXSTREAM_AUDIO, m_omx_reader.GetAudioIndex() + 1);
etc ...
I have not been able to use "+" and "-" for controlling volume
This has been added just a few days ago <- See : https://github.com/huceke/omxplayer/com ... 24cb828ffe
The omxplayer binaries included in Wheezy must be older than that.
I will try recompiling it using dom's (really really quick) instructions and tell you <- see : http://www.raspberrypi.org/phpBB3/viewt ... f=2&t=5061
Last time a tried this same set of instructions for compiling XBMC, I couldn't pass the step : "make -C tools/rbp/depends all" ; <- see :
http://www.raspberrypi.org/phpBB3/viewt ... f=9&t=5037
I always had this error on the build machine :
That is odd, assuming that the file is there :make[2]: /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++: Command not found
Even more surprising, I get the same error if I launch it from the command line :mxav@ubuntu:~/xbmc-rbp$ ll /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++
-rwxr-xr-x 1 mxav mxav 245260 2012-06-21 00:49 /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++*
@dom : if you read this post and have 1 minute to show me the way, I would really appreciatemxav@ubuntu:~/xbmc-rbp$ /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++
bash: /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++: No such file or directory

XavM
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 5708
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: omxplayer play controls / input
@XavM
I believe the Wheezy image does include the latest omxplayer mods.
I believe the Wheezy image does include the latest omxplayer mods.
-
- Posts: 100
- Joined: Sun Jun 24, 2012 1:36 am
Re: omxplayer play controls / input
So I'm a bit confused-- the controls actually work for me fine out of the box, but it seems like at the end of the video I'm testing, I can't pause or rewind/fastforward anymore. it's like it eventually stops listening to me. any ideas?
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 5708
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: omxplayer play controls / input
I think that is a bug in omxplayer. I believe once the file has reached EOF, but buffered data is still playing out, the keys are ignored. For high bitrate files this is only a couple of seconds, but for low bitrate it can be much longer.BenWiley4000 wrote:So I'm a bit confused-- the controls actually work for me fine out of the box, but it seems like at the end of the video I'm testing, I can't pause or rewind/fastforward anymore. it's like it eventually stops listening to me. any ideas?
Please post an issue on omxplayer GitHub.
-
- Posts: 100
- Joined: Sun Jun 24, 2012 1:36 am
Re: omxplayer play controls / input
thanks much! I posted an issue, hopefully it will be resolved.dom wrote:I think that is a bug in omxplayer. I believe once the file has reached EOF, but buffered data is still playing out, the keys are ignored. For high bitrate files this is only a couple of seconds, but for low bitrate it can be much longer.BenWiley4000 wrote:So I'm a bit confused-- the controls actually work for me fine out of the box, but it seems like at the end of the video I'm testing, I can't pause or rewind/fastforward anymore. it's like it eventually stops listening to me. any ideas?
Please post an issue on omxplayer GitHub.
Re: omxplayer play controls / input
"+" and "-" to adjust the volume :
The Debian Wheezy Beta image does not include the last version of OMXPlayer.
I have built OMXPlayer with the last version available on Github.
This version adds "Volume control" with "+" and "-" and a few other things <- See : https://github.com/huceke/omxplayer/commits/master
You can now "echo -n + > /tmp/cmd" and "echo -n - > /tmp/cmd" to adjust the volume.
---
- Dirty install :
wget https://dl.dropbox.com/s/9hoxtq1ebrhd9t ... ist.tar.gz
tar zxvf ./omxplayer-dist.tar.gz
- Run :
LD_LIBRARY_PATH=omxplayer-dist/usr/lib/omxplayer ./omxplayer-dist/usr/usr/bin/omxplayer.bin -o hdmi ../big_buck_bunny_1080p_h264_ac3.mkv
It works for me ... it should work for you.
(I am no Linux or Cross-Compile Guru and it took me some time to go to the end of the build process with no error; If you want to do it yourself see this post : http://www.raspberrypi.org/phpBB3/viewt ... 235#p67235 )
XavM
The Debian Wheezy Beta image does not include the last version of OMXPlayer.
I have built OMXPlayer with the last version available on Github.
This version adds "Volume control" with "+" and "-" and a few other things <- See : https://github.com/huceke/omxplayer/commits/master
You can now "echo -n + > /tmp/cmd" and "echo -n - > /tmp/cmd" to adjust the volume.
---
- Dirty install :
wget https://dl.dropbox.com/s/9hoxtq1ebrhd9t ... ist.tar.gz
tar zxvf ./omxplayer-dist.tar.gz
- Run :
LD_LIBRARY_PATH=omxplayer-dist/usr/lib/omxplayer ./omxplayer-dist/usr/usr/bin/omxplayer.bin -o hdmi ../big_buck_bunny_1080p_h264_ac3.mkv
It works for me ... it should work for you.
(I am no Linux or Cross-Compile Guru and it took me some time to go to the end of the build process with no error; If you want to do it yourself see this post : http://www.raspberrypi.org/phpBB3/viewt ... 235#p67235 )
XavM
Re: omxplayer play controls / input
this post may be useful, it talks about using xautomation to simulate key presses and mouse moves, as well as a series of combinations of those-- rather handy I think
http://stackoverflow.com/a/5714298/1298523
http://stackoverflow.com/a/5714298/1298523
Re: omxplayer play controls / input
joeh wrote: mkfifo /tmp/cmd
omxplayer -ohdmi mymedia.avi < /tmp/cmd
echo . > /tmp/cmd (Start omxplayer running as the command will initial wait for input via the fifo)
I have been absolutely happy with controlling omxplayer via screen. It will listen to the keys, even if you moved the screen session from the vt to an ssh login and vv. Of course this doesn't give you the full and nice automation some are looking for

Try this from any shell, either the VT (no X) or a lxterminal etc:
Code: Select all
screen
omxplayer spam.mp4
<press cursor keys to jump>
<press 'Ctrl-A d' to detach the screen session, playback continues>
Code: Select all
screen -r # resumed detached screen
<use cursor keys as before>
hth,
D