omxplayer play controls / input
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=38&t=7987
omxplayer play controls / input
Does omxplayer have any facility for user input (play/pause/fast-forward/volume etc) via a command or pipe input?
- Posts: 9
- Joined: Sat Jun 09, 2012 9:20 pm
However it would be nice to have a http interface for control like xbmc.
- Moderator
- Posts: 3563
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
- Posts: 9
- Joined: Sat Jun 09, 2012 9:20 pm
- Moderator
- Posts: 3563
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
next question… d’ya rekkon i could pipe that input into it from a different shell session?
- Posts: 9
- Joined: Sat Jun 09, 2012 9:20 pm
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.
Download from http://pipresents.wordpress.com
- Posts: 439
- Joined: Tue Jan 24, 2012 9:30 am
- Location: Hertfordshire, UK
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 -
- Attempt at a process flow diagram
- flowchart.jpg (59.52 KiB) Viewed 17752 times
- Posts: 9
- Joined: Sat Jun 09, 2012 9:20 pm
- Posts: 37
- Joined: Tue Jun 05, 2012 3:00 am
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.
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.
- Posts: 6
- Joined: Tue Jun 12, 2012 9:29 pm
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.
- Posts: 9
- Joined: Sat Jun 09, 2012 9:20 pm
Would love to look at your web interface if your willing to share !
- Posts: 6
- Joined: Tue Jun 12, 2012 9:29 pm
I’ll see if i can put together an easy-install javascript/php for omxplayer
- Posts: 9
- Joined: Sat Jun 09, 2012 9:20 pm
============= 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
- Posts: 6
- Joined: Tue Jun 12, 2012 9:29 pm
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…
- Posts: 36
- Joined: Sun Jun 10, 2012 10:17 am
- Location: UK
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
- Posts: 9
- Joined: Sat Jun 09, 2012 9:20 pm
@Joeh : Did you try to write an airplayer Media Backends for omxplayer using this fifo method ?
- Posts: 35
- Joined: Thu May 31, 2012 11:29 pm
“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 : viewtopic.php?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 :
viewtopic.php?f=9&t=5037
I always had this error on the build machine :
make[2]: /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++: Command not found
That is odd, assuming that the file is there :
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++*
Even more surprising, I get the same error if I launch it from the command line :
mxav@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
@dom : if you read this post and have 1 minute to show me the way, I would really appreciate
XavM
- Posts: 35
- Joined: Thu May 31, 2012 11:29 pm
I believe the Wheezy image does include the latest omxplayer mods.
- Moderator
- Posts: 3563
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
- Posts: 100
- Joined: Sun Jun 24, 2012 1:36 am
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?
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.
Please post an issue on omxplayer GitHub.
- Moderator
- Posts: 3563
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
dom wrote:
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?
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.
Please post an issue on omxplayer GitHub.
thanks much! I posted an issue, hopefully it will be resolved.
- Posts: 100
- Joined: Sun Jun 24, 2012 1:36 am
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 : viewtopic.php?p=67235#p67235 )
XavM
- Posts: 35
- Joined: Thu May 31, 2012 11:29 pm
- Posts: 15
- Joined: Wed Jun 27, 2012 12:09 pm
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>
Then grab another terminal, or ssh into you pi and issue
- CODE: SELECT ALL
screen -r # resumed detached screen
<use cursor keys as before>
When playback has finished, use ‘Ctrl-D’ to finish screen.
hth,
D