0

I have a raspberry pi that I'm trying to make display videos via controls on a web app. I'm using omxplayer the way described here. My PHP problem file only contains this line (modified for testing):

exec("/home/pi/master/playmovie.sh test.mp4");

referenceing the file /home/pi/master/playmovie.sh:

omxplayer -o hdmi /home/pi/Videos/$1 < /home/pi/master/cmd > /dev/null &
echo . > /home/pi/master/cmd

When I execute this php file or the command itself locally via putty everything works fine, but when I try to execute it via the web it locks up and the movie never starts.

Important:

  • playmovie.sh has execute permissions
  • master/cmd has 777 permissions
  • writing to master/cmd and executing other scripts works fine both locally and online via php
  • from php online I can execute omxplayer -h, ls -l /home/pi/Videos/test.mp4, echo -n p > /home/pi/master/cmd so it definitely recognizes those all as valid.

I feel like I'm going crazy and this is literally the last thing I need to do on this project to make it functional please help!!

Community
  • 1
  • 1
JoeS
  • 1

1 Answers1

0

My guess is it's because your actual exec command doesn't handle stdout, stderr and stdin. When invoked from the command line PHP has no output buffer, but from the browser it does.

It sounds like it's getting some output so then waiting for the script to finish executing and eventually timing out, hence it appears to be doing nothing.

What happens if you use nohup?

exec("nohup /home/pi/master/playmovie.sh test.mp4 &");

miknik
  • 5,748
  • 1
  • 10
  • 26