Page 1 of 1
cgi scripting and omxplayer
Posted: Sun Jan 06, 2013 6:43 am
by unclejed613
i've been trying to use a cgi script to play video on omxplayer. the idea is to use a web page to remote control the pi to play video on a TV connected to the pi. the problem is, i can execute the cgi script manually, and it plays the video, but when trying to execute it through apache, the script returns the following error:
here's the cgi script:
Code: Select all
#!/bin/bash
echo Content-type: text/html
echo ""
echo "$(omxplayer /home/pi/test2/Movies_on_linbox/Browse\ Folders/oldies/superman_1941_512kb.mp4)"
anybody got any ideas why it's not working? other scripts work ok, and they all have the same permissions, and are in /usr/cgi-bin/ as they're supposed to be for apache.
Re: cgi scripting and omxplayer
Posted: Sun Jan 06, 2013 9:35 am
by Heater
Not sure but I imagine that apache is running cgi scripts as user root. Or perhaps some other user. And does not have access to whatever it requires to run omxplayer.
There must be a way to do this. I have fired up omxplayer from an ssh session from another machine essentially doing what you want to do, starting omxplayer remotely. It worked fine.
Re: cgi scripting and omxplayer
Posted: Sun Jan 06, 2013 9:54 am
by camh
The default permissions on /dev/vchiq only allow a process running as root, or running with group "video" to open it. Make sure whatever user is running omxplayer has permission to open /dev/vchiq.
Re: cgi scripting and omxplayer
Posted: Sun Jan 06, 2013 10:22 am
by ghans
Re: cgi scripting and omxplayer
Posted: Sun Jan 06, 2013 7:56 pm
by unclejed613
i'll try the php script. i had installed php when i installed apache. so i gave it another thought and added sudo to the beginning of the command line in the script. it didn't return the error about not being able to start a vchiq instance, but instead had the following in the error log:
Code: Select all
[Sun Jan 06 06:25:21 2013] [notice] Apache/2.2.22 (Debian) PHP/5.4.4-10 configured -- resuming normal operations
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1]
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] We trust you have received the usual lecture from the local System
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] Administrator. It usually boils down to these three things:
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1]
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] #1) Respect the privacy of others.
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] #2) Think before you type.
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] #3) With great power comes great responsibility.
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1]
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] sudo
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] :
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1] no tty present and no askpass program specified
[Sun Jan 06 12:21:37 2013] [error] [client 127.0.0.1]
[Sun Jan 06 12:22:00 2013] [error] [client 127.0.0.1] sudo
[Sun Jan 06 12:22:00 2013] [error] [client 127.0.0.1] :
[Sun Jan 06 12:22:00 2013] [error] [client 127.0.0.1] no tty present and no askpass program specified
[Sun Jan 06 12:22:00 2013] [error] [client 127.0.0.1]
so it's two steps forward and one step back i guess.... unless there's a way around this... i'm still going to look at the php script, as it looks like a good solution. what i was trying to do ultimately was to make a list on the web page of the contents of a directory full of videos (and maybe even have a snapshot from each video) and a html link to a cgi script to run that video in omxplayer. as you can tell (partially) from the error file, the web browser is talking to apache through a TOR hidden service.
Re: cgi scripting and omxplayer
Posted: Sun Jan 06, 2013 8:10 pm
by unclejed613
i noticed some java scripts in the package, do i need java on the pi? i thought that java wasn't working on hard float (armhf)
Re: cgi scripting and omxplayer
Posted: Mon Jan 07, 2013 12:05 am
by unclejed613
ok, i tried the php script, but it's returning this error even after running the sudo usermod command as it says:
Code: Select all
/dev/vchiq is not writable for httpd user
you have to run shell command:
sudo usermod -a -G video www-data
this will allow http server user which runs omxplayer access /dev/vchiq to display video
so it still no workie.....
Re: cgi scripting and omxplayer
Posted: Sun Apr 20, 2014 2:45 am
by foley
I got your script to work. The main trick is that the bash script has to have group www-data. It also needs to return a variable from its environment. I. I also added the -ohdmi option to omxplayer.
Code: Select all
sudo chgrp www-data /usr/lib/cgi-bin/test.cgi
Here is the modified bash script
Code: Select all
#!/bin/bash
# $URL$
# $Id$
# Simple BASH script to start videos from web interface
# Put this file in /usr/lib/cgi-bin/test
# sudo chgrp www-data test
# sudo usermod -a -G video www-data
echo Content-type: text/html
echo ""
# For some weird reason, this only works if I leave the following line uncommented
echo "$USER"
#echo "`groups`"
echo "$(omxplayer -ohdmi /home/pi/Serenity-trailer.mp4)"