1

I am trying to play a video with omxplayer and have it pause after 10 seconds. To load the video I am using a shell script that runs the command. I would also like the user to be able to resume the video so it can fade out (I am using a video of a still image).

What I have tried is omxplayer --no-osd -b Media/test.flv sleep 3 p

That runs the p after the video plays.

Thank you.

4
  • So, you basically want the video to pause after 10 seconds, but don't know how? Commented Mar 28, 2014 at 17:21
  • @RPiAwesomeness Yes.
    – ben545
    Commented Mar 28, 2014 at 21:06
  • Okay, was kind of hard to understand what your actual question was. Just clarifying. So, you want the video to play and after 10 seconds, go off to this other application. Wouldn't backgrounding (or even killing for that matter) the OMXPlayer process work? Commented Mar 28, 2014 at 21:10
  • 1
    expect is build for this kind of things. Of the top of my head, something like expect -c "spawn omxplayer --no-osd -b Media/test.flv; sleep 3; send p; interact"
    – Gerben
    Commented Mar 29, 2014 at 12:50

1 Answer 1

1

OK. You're on the right track to start with. I believe we can pipe keyboard input into omxplayer from the command line and use that to control it. I'm just going to write it out, then explain what's happening

mkfifo t
cat t | omxplayer --no-osd -b Media/test.flv &
sleep 10s
echo p > t
rm t

First a special type of file called a FIFO, or first-in first-out file is created. Anything we write to the file comes out in the order it was put in when the file is read. The second command cats the output of this and pipes it into omxplayer. There's nothing in the file to start with though, so nothing happens. We wait 10 seconds. We then write "p" into the FIFO file with the echo command. Cat will then see this and pipe that to omxplayer, pausing the video. The last line just removes the FIFO file since we're done with it. If you're doing this lots though, you can just leave it there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.