User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

how to keep omxplayer alive after shell is logout?

Sun Jun 23, 2013 2:33 pm

Greetings.

I connected pi to a TV with hdmi and using wifi to ssh to pi.

The problem is that I'm using an iPhone to ssh to pi. iPhone will kill socket after 10min if the program is in background. So if I turn off iPhone's screen, ssh shell will drop after 10min. And omxplayer will down with the shell. I cant watch any movie longer than 10min....iOS is just great :D

Is there a way to keep the omxplayer running even if the shell is down?

And another question: why I didnt pass '-o hdmi' to omxplayer and I still can hear audio? If I pass '-o hdmi', volume gonna to be louder. But without it, everything works well.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: how to keep omxplayer alive after shell is logout?

Sun Jun 23, 2013 3:21 pm

You need to replace your omxplayer command with: sudo -u pi nohup omxplayer (path to video) >/dev/null 2>&1
i.e. sudo -u pi nohup omxplayer /opt/vc/src/hello_pi/hello_video/test.h264 >/dev/null 2>&1

Richard S.
Last edited by redhawk on Sun Jun 23, 2013 3:24 pm, edited 1 time in total.

User avatar
rpdom
Posts: 17171
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: how to keep omxplayer alive after shell is logout?

Sun Jun 23, 2013 3:22 pm

To keep the connection alive, install the "screen" program. Then ssh to the Pi, type "screen omxplayer (rest of command line)" and it will start the command inside a "screen" session which will keep running even if your ssh session disconnects. You can then ssh in again and reconnect to the same session with "screen -r".

[edit]
I also believe you can "ssh pi@yourhostname screen omxplayer (rest of command line)" to start everything in one go - an alias for that lot would make typing easier, and "ssh pi@yourhostname screen -r" to reconnect.

Return to “General discussion”