derdritte
Posts: 8
Joined: Fri Jul 06, 2012 10:58 pm

Re: omxplayer play controls / input

Fri Jul 06, 2012 11:53 pm

Thanks for all the work & time that has already been put into this thing.

I have now been working on a media-server to do just that for a some time.
It currently runs on flask/python, (given the rights) will read directories and check for Information on imdb.com or thetvdb.com and save some of that data locally. It works with sqlite at the moment and used to hand over commands via dbus to vlc. It had full control and seek ability.
That was the simplest solution for me since I already had an unused PC around and hooking that up to the TV and Lan wasn't really an issue. It – of course – used massive amounts of power compare to what it did and the RPi.

So the new idea was getting a RPi and sticking that to the back of the TV and connect it via HDMI to the TV, the 3.5mm to the stereo (for mpd duty or backup-sound on video) and eth to receive playback-data.
But since the omxplayer didn't really offer any input other than direct piping I was kind of put off.
I honestly would love it if it offered something like dbus, but I realize this is a relatively small project.

I think joeh's approach is the best solution possible at the moment and if anyone is interested I would build that into my "media-server" and have a couple of RPi-users test it.
Actually, I am going to build it in no matter what, but I might clean it up some and polish it a bit if people are going to be using it ;)
I have no timetable at the moment, but the first two weeks of August will be coding-months for me, so it might be a go then.
I'd be happy to discuss features with people, at the moment the server is supposed to
- handle a relative small db (that's why sqlite) that holds title, quality, size, description (and so on) for easy searching and playlist editing
- be able to control a media-player (this part is supposed to change to a class-based model to support multiple different media-players)
- have a templateable web-interface so you can have full-browser or smartphone controls and above mentioned db and playlists on there

Basically it should make it possible for you to control video playback on your TV. I did this because I was pissed off by disk-changing all the time. As it grew I thought why not make it even more extensive/informative than what would usually come with a DVD. Especially The TVDB was pretty awesome when it came to scrape information.

Sorry if I spammed this topic, just thought it was awesome that people already wanted to implement that and give my humble opinion and/or workforce to the idea.

Regards,
derdritte

XavM
Posts: 35
Joined: Thu May 31, 2012 11:29 pm

Re: omxplayer play controls / input

Sat Jul 07, 2012 7:17 am

@derdritte : This is good news that people try to make some wraper around OMXPlayer to control it -> i really encourage you to continue.

Actualy, i have been doing the same for the last couple of days using node.js and it works pretty well.

Basically, it just child.exec an OMXPlayer process from node and expose some simple playback control via HTTP that are passed to the child.exec stdin.

The main problem that I have, is that you will need at some point to hack into the OMXPlayer code to access methodes not exposed to the "one char" stdin OMXPlayer control interface or basic info output.

To tell the truth, it would be really better that the native OMXPlayer evolves and expose all its capabilities thru HTTP or DBus.

By the way, did you check XBMC for the Raspberry Pi : It is just an awsom piece of software with all the possible functionality (OMXPlayer was just a "test bed" for XBMX on the Pi)

XavM
Posts: 35
Joined: Thu May 31, 2012 11:29 pm

Re: omxplayer play controls / input

Sat Jul 07, 2012 7:26 am

Edit to my previous post :

The purpose of my node.js OMX wraper was to write an AirPlayer media back end : this os done and works well for playing back youtube videos from an iDevice, but fails badly when playing Videos from the "picture app", due to buffering not being large enough in OMXPlayer

<- this is where you will have to deep dive into OMXPlayer code

(changing AUDIOBUFFER from OMXAudio.h does not do the trick : if any one knows how it really works ... Some help would be really appreciated :) )

derdritte
Posts: 8
Joined: Fri Jul 06, 2012 10:58 pm

Re: omxplayer play controls / input

Sat Jul 07, 2012 7:41 am

The thing is, XBMC never run very smoothly on the "duty PC" I had there before, also it's kind of an overkill for what I wanted.
This started out as a PHP/Hardware-interaction exercise for me and then slowly changed into some python/mysql/php mix when I decided that I had to kill it off and make something – at least somewhat – consistent. But I think I have been working on that for 1 1/2 years now ;)

And yes, I had a quick look at the source and was somewhat troubled by the missing "jump to"-input-option. I thought that could be easily done with a time-out of maybe two seconds after each character.
So it would be:
q (or whatever to initialize seeking)
1
1
0
m (for minutes, leave out for second-exact seeking)
then time-out to seek.
Would be consistent with the other controls and save you a shitload of jumping around in the file.
Well, I am going to look into it and try to compile my own version eventually, but that could be some time :P

Regards,
derdritte

User avatar
clickykbd
Posts: 117
Joined: Wed Jun 06, 2012 2:21 am
Location: Austin, Texas
Contact: Website

Re: omxplayer play controls / input

Sat Jul 07, 2012 1:50 pm

i'm a noob with omxplayer.
How do I get rid of the console text behind the video overlay?

Also, do you have issues with some DiVX files? I've only tried one that I think was divx, lots of trails in the non key-frames. My xvid test worked like a champ though.

XavM
Posts: 35
Joined: Thu May 31, 2012 11:29 pm

Re: omxplayer play controls / input

Sat Jul 07, 2012 2:45 pm

The playback will automatically start with a blank (black) screen if you use the appropriate version of the omxplayer script present in /usr/bin.

If it does not, update it with the following :

https://github.com/huceke/omxplayer/blo ... /omxplayer

Be carefull to quit the player with 'q' and not using Ctrl-C, or youl will end up with a blank TV screen

Regarding issues with video format, in my experience, it works well or doesn't work at all, but no rendering quality issue so far.

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: omxplayer play controls / input

Sun Jul 08, 2012 4:08 pm

I've uploaded a python interface to omxplayer. Details here

http://www.raspberrypi.org/phpBB3/viewt ... 38&t=10599
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

rpiu314
Posts: 1
Joined: Wed Jul 11, 2012 10:15 pm

Re: omxplayer play controls / input

Wed Jul 11, 2012 10:17 pm

In response to clickykbd

How do I get rid of the console text behind the video overlay?

I used -r option and it seems do the trick.

HKwhyIP
Posts: 7
Joined: Wed Oct 26, 2011 4:04 am

Re: omxplayer play controls / input

Fri Jul 13, 2012 3:13 pm

Hi,

Is there any method to (1) shrink (2) enlarge a video or (3) change the video position under omxplayer?

Say I got a 1920 x 1080 video. Now I want to play the video in half size at the top-right hand side of the screen. Is the possible? If need to modify the source code, any suggestion which file at github I should work on?

Thanks

Kenneth

User avatar
jbaiter
Posts: 13
Joined: Tue Jul 03, 2012 7:52 pm

Re: omxplayer play controls / input

Sun Jul 15, 2012 10:01 pm

Here is another Python wrapper around OMXPlayer, this time without the need for additional shell scripts and FIFOs and a more object-oriented design: https://github.com/jbaiter/pyomxplayer
Hope it can be useful for some and sorry for re-using the name from the other project, but I couldn't come up with anything better :oops:

derdritte
Posts: 8
Joined: Fri Jul 06, 2012 10:58 pm

Re: omxplayer play controls / input

Fri Jul 20, 2012 7:20 pm

@jbaiter
Wow, people are really working on that a lot.
Thanks, this is awesome.
Also like the structure for the unimplemented functions.

Regards

stranzenbach
Posts: 1
Joined: Sun Jul 22, 2012 3:43 pm

Re: omxplayer play controls / input

Sun Jul 22, 2012 3:50 pm

Hallo
has anyone found a method to configure pcmanfm (filemanager) to start a video using omxplayer and leave the keyboard controls of omxplayer active.
I tried the whole day using the above clues, but no success.
Greetings Eddy

JazzyJ
Posts: 1
Joined: Fri Aug 03, 2012 10:30 pm

Re: omxplayer play controls / input

Fri Aug 03, 2012 10:40 pm

This is my very basic php script that i use, using joeh's fifo details, I had actually written it before I found this post just didn't know about being able to use the fifo file to pause and control playback,
Ooh I have no php experience or html btw :)
test.php

Code: Select all

<html>
<head><title>OMXPlayer</title></head>
<?php
if (isset($_GET['play'])) {
                $file = $_GET['play'];
                shell_exec("killall omxplayer");
                shell_exec("killall omxplayer.bin");
                shell_exec("rm /tmp/cmd -f");
                shell_exec("mkfifo /tmp/cmd");
                pclose(popen("omxplayer -o hdmi /hdd/videos/$file </tmp/cmd &",'r'));
                sleep(1);
                shell_exec("echo -n . > /tmp/cmd");
                }
if (isset($_GET['command'])) {
                $command = $_GET['command'];
                switch ($command) {
                        case "pause":
                                shell_exec("echo -n p > /tmp/cmd");
                                break;
                        case "stop":
                                shell_exec("echo -n q > /tmp/cmd");
                                break;
                        case "another":
                                echo "i equals 2";
                                break;
                        }
}

if ($handle = opendir('/hdd/videos')) {
        while (false !== ($entry = readdir($handle))) {
                if ($entry != "." && $entry != "..") {
                echo "$entry";
                ?> <a href=\test.php?play=<?php echo $entry; ?>> Play</a><br><?php
                }
        }

    closedir($handle);
}
echo "<pre><a href=test.php?command=stop>Stop </a>";
echo "<a href=test.php?command=pause>           Pause </a>";
echo "<a href=test.php>         Home </a></pre>";
?>
</html>

Rundfunk
Posts: 3
Joined: Thu Aug 16, 2012 12:24 pm

Re: omxplayer play controls / input

Thu Aug 16, 2012 12:32 pm

I'm also working on a small remote controll app for OMXplayer, and using Node.js for that. It is my goal to be able to control OMXplayer via my mobile phone. So far, I am able to list and select a video file, but when I try to 'exec' or 'spawn' the OMXplayer with some arguments nothing happens on my display. However, if I look at the list of running processes, I see the OMXplayer process has been created.

Does anyone have a pointer for me to continue? I saw the FIFO solution, but would also like to read the output to stdout from OMXplayer. I'm not sure if that is possible via FIFO.

@XavM: could you please share your Node.js code? I understand it might be incomplete, but if I am able to figure out how to correctly create a OMXplayer process it would really help me.

dudewheresmycode
Posts: 16
Joined: Thu Aug 16, 2012 5:28 am

Re: omxplayer play controls / input

Sun Aug 19, 2012 2:26 am

I've also been tinkering with omxplayer as a player for a RaspPi media center. and found this nodejs module to be helpful in understanding controlling omxplayer from node.

https://github.com/rikkertkoppes/omxcontrol


But, I agree that at some point someone will need to crack open omxplayer and create/expose more functions, seeking to X seconds, better playback position information, etc.

Jim Ford
Posts: 17
Joined: Fri Jul 06, 2012 3:43 pm

Re: omxplayer play controls / input

Mon Aug 20, 2012 7:45 pm

I'm trying to write a simple bash script for controlling omxplayer from a command line. I'm a rubbish programmer, particularly with bash. This is what I've got so far:

Code: Select all

#!/bin/bash
#
if [ ! -e /tmp/omxplayer.pipe ]
then
        mkfifo /tmp/omxplayer.pipe
fi
#
( /usr/bin/omxplayer -n -o hdmi $1 < /tmp/omxplayer.pipe & )
#
echo -n . /tmp/omxplayer.pipe
clear
while true
do
echo p for play/pause
echo q for quit
echo b for back 30
echo B for back 600
echo f for forward 30
echo F for forward 600
echo z for info
echo 1 for slower
echo 2 for faster
echo j for previous audio track
echo k for next audio track
echo + for volume up
echo - for volume down
echo i for previous chapter
echo o for next chapter
echo n for previous subtitle track
echo m for next subtitle track
echo s for toggle subtitles
read inp
clear
case $inp in
        p|z|1|2|j|k|+|-|i|o|n|m|s)
                echo -n $inp > /tmp/omxplayer.pipe
                ;;
        q)      echo "Quiting"
                echo -n q > /tmp/omxplayer.pipe
                rm /tmp/omxplayer.pipe
                break
                ;;
        b)      echo -n $'\x1b\x5b\x44' > /tmp/omxplayer.pipe
                ;;
        B)      echo -n $'\x1b\x5b\x41' > /tmp/omxplayer.pipe
                ;;
        f)      echo -n $'\x1b\x5b\x43' > /tmp/omxplayer.pipe
                ;;
        F)      echo -n $'\x1b\x5b\x42' > /tmp/omxplayer.pipe
                ;;
        *)      echo "Please select from above only"
                ;;
esac
done
But it doesn't really work as expected.

I'd welcome suggestions , please!

Jim

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer play controls / input

Thu Aug 23, 2012 8:05 am

How about joining forces to build web interface for smartphone screen using PHP to control omxplayer through pipes. And sending commands using web javascript ajax without pages reload. You just layout buutons on web page with omxplayer functions and sends ajax to running php to control omxplayer. Pretty easy and straightforward. If someone can help me with php' proc_open and pipes I can do the rest!
For now I have problems with pipes to running omxplayer using proc_open.
Exactly when I run omxplayer from proc_open it won't display image for some reason!

Juggler
Posts: 35
Joined: Wed Aug 08, 2012 7:29 am

Re: omxplayer play controls / input

Thu Aug 23, 2012 10:32 am

it seems that php process creation with pipes is buggy and it is easier to use system pipes to control it...

venkat03
Posts: 1
Joined: Sat Aug 18, 2012 10:36 am

Re: omxplayer play controls / input

Sat Aug 25, 2012 5:50 am

i am new to raspbian.. installed omxplayer in my raspbian.. i think its running.. but i can't hear sound... help me..

Chuckaluphagus
Posts: 23
Joined: Sat Jun 30, 2012 9:05 pm

Re: omxplayer play controls / input

Fri Aug 31, 2012 1:40 pm

venkat03 wrote:i am new to raspbian.. installed omxplayer in my raspbian.. i think its running.. but i can't hear sound... help me..
venkat, are you trying to output sound via the HDMI cable, or the analog audio port? If you're doing it over HDMI, you might need to tell the program to output the audio that way, by running the command as

Code: Select all

omxplayer -o hdmi <your file name>
If you're outputting sound via the analog audio port, it's

Code: Select all

omxplayer -o local <your file name>
Hope that helps.

Holgi
Posts: 1
Joined: Wed Sep 12, 2012 10:16 am

Re: omxplayer play controls / input

Wed Sep 12, 2012 10:44 am

joeh,

thanks for sharing this. May I ask which webserver you have used on your raspi ?
I tried a slightly modified version of your scripts together with lighttpd and as it seems the chrooting of the webserver content isolates the cgi scripts. Thus they are not capable of accessing my videos.

TIA,
Holgi
joeh wrote: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;
...

mrpackethead
Posts: 5
Joined: Fri Sep 21, 2012 9:48 am

Re: omxplayer play controls / input

Sat Sep 22, 2012 12:29 am

Hi,

I am trying to control omxplayer using DMX commands and a fun little package called OLA ( open lighting architecture ).. We have a system called ola_trigger, which essentially lets us run arbitory shell commands when the incoming data from the dmx ( or artnet/e1.31 ) matches a certain condition. OLA is already ported to Rasbpian and works well.. What i want to do is make ola_trigger start a video playback... its actually working now, but i have a problem.. Its teh amount of time it takes for OMXplayer to actually start playing the video from the time you send the command.. I'm guessing that it takes some time to 'get' started and load the files etc..

I need to accruately and repeatably start the video to a 'que', so its important that it starts at exactly the right time.

I could 'premptively' start the video before i need it, to compenstate for the delay, but i've noticed that the delay is'nt consistent..

Is there a way of starting the video, and imediately pausing it, ( call this a "video load" ) and then pushing "pause" sometime later to make it start.. I could include 'n' frames of black on teh start of the video clip if needed.

I also could convert my video files to any format that helps...

Any suggestions.

Howard
Posts: 64
Joined: Sun Mar 04, 2012 7:38 pm
Contact: Website

Re: omxplayer play controls / input

Sun Sep 23, 2012 2:09 am

There are a few gotchas when doing a wrapper around omxplayer that I found when doing my own (I used Java, but the same applies to most languages):

omxplayer outputs somethings to stdout, some to stderr. This means either your wrapper has to monitor both, or you use the shell to connect the two together (eg: 2>&1)

The response to +/- is output (in the source I have) on stdout. This means you won't see it too soon because stdout is BUFFERED and the stream is not flushed. I recompiled for stderr and its fine.

Sending key strokes into omxplayer (from a program, not a script) can suffer the same problems: be sure to flush the stream to get your keys out of your program!

omxplayer does the equivalent of stty -icanon -echo -echoe -min 1 (and perhaps a few more I have forgotten). Whether this gets in the way of pipes or named pipes I am not sure but it all worked better for me when I changed it to polling stdin with non-blocking input.

The output that -s generates can be rather overwhelming - about 150 times a second (on stdout) which means your script/program needs to process it fairly quickly. I recompiled to output just the position data to stderr about twice a second.

Having done these things I find it works reliably and I have ended up with a media control GUI similar to what to might see on VLC or QuickTime Player.

Good job omxplayer!

mrpackethead
Posts: 5
Joined: Fri Sep 21, 2012 9:48 am

Re: omxplayer play controls / input

Sun Sep 23, 2012 3:14 am

I haven't launched head long into the code base yet, but do you think its viable to add to some extra 'transport' controls.. Ie; start at n:nn:nn,..

thedewpoint
Posts: 9
Joined: Mon Dec 31, 2012 4:50 am

Re: omxplayer play controls / input

Mon Dec 31, 2012 4:53 am

I ran into this same issue but solved it a different way. I used xdotool
sudo apt-get install xdotool
and I can send terminal commands while the video is playing by doing xdotool key p (to pause) or xdotool key q (to quit) etc. I noticed if I try to use these commands through ssh, but if I run the code from the pi and watch the video there, The code works and pauses it. I'm new to linux so this might be a really bad way of doing it but it's working for now.

Return to “Graphics, sound and multimedia”