0

After running: omxplayer -o hdmi myVideo.mp4, if I wanna increase/decrease volume, I just have to type + / - Ok. That's working fine. But I have another scenario, can you help me please? How can I increase/decrease volume from another terminal? What's the command or script that I have to run?

Thanks a lot!

(raspberry pi 3)

lmendivil
  • 157
  • 2
  • 12

1 Answers1

0

You can control omxplayer by connecting its stdin to a named pipe.
As a first step, create a fifo:

mkfifo /tmp/omx-control

Then start omxplayer with its stdin connected to the fifo:

omxplayer yourVideo.mp4 < /tmp/omx-control &

Now you can control omxplayer via the pipe:

echo -ne "+" > /tmp/omx-control     # Increase Volume

Hope this helps.

tshiono
  • 21,248
  • 2
  • 14
  • 22
  • Well, after run "omxplayer -o hdmi Videos/kpop.mp4 < /tmp/omx-control &" I got this: [1] 2323 And the video is not playing – lmendivil Oct 22 '18 at 17:58
  • Try to say `echo -ne p > /tmp/omx-control` after the command above. – tshiono Oct 23 '18 at 07:56
  • tshiono, thanks. And do you know If it can increase/decrease the volume by quantity? I mean, imagine if I an using a slider control (not a terminal, a user interface) Like doing this echo -ne "+" > /tmp/omx-control many times in succession. – lmendivil Oct 30 '18 at 15:07
  • And another question please, this *mkfifo /tmp/omx-control* can I create in a permanent way? (not temporal, just one time) I say this because when I reboot my raspberry, I need to do this again mkfifo /tmp/omx-control Thanks in advance. – lmendivil Oct 30 '18 at 15:10
  • There are three ways to control the volume of omxplayer. Refer to [here](https://stackoverflow.com/questions/33162820/adjust-audio-volume-level-with-cli-omxplayer-raspberry-pi). As for the stdin interface, there may not be a direct (with absolute value) control. Try instead something like `echo -ne "++++" > /tmp/omx-control` for multiple-time increases (sorry, not tested). Regarding the `named pipe` you can create the fifo wherever you want. For instance try `mkfifo > ~/omx-control` (under home directory) then control with `echo -ne "command" > ~/omx-control`. BR. – tshiono Oct 31 '18 at 03:56