To provide more accurate information for playback through scripts, there are 3 ways to change the sound volume in the current version of omxplayer, and the values ββare not so intuitive:
- at command prompt, param
--vol YYY , double millibels, default 0, range [-6000: 0] - via stdin interface, sending +/- to omxplayer will increase / decrease the volume for 300 dmbels
- with DBUS interface, cmd 'set volume', value
double:XXX , default 1, range [0: 1]
From xxx to yyy ratio: XXX = 10 ^ (YYY / 2000) ... according to omxplayer.cpp source code, the inverse formula is: YYY = 2000 * (log XXX) .
therefore, if we need:
- volume 1%, XXX = 0.01 and YYY = -4000
(10^(-4000/2000)=10^-2=0.01 - volume 10%, XXX = 0.1 and YYY = -2000
(10^(-2000/2000)=10^-1=0.1 - volume 50%, XXX = 0.5 and YYY = -602
(10^(-602/2000))~=0.5 - volume 100%, XXX = 1 and YYY = 0
(10^(0/2000)=10^0=1) - volume 150%, XXX = 1.5, and YYY = 352 ... (for the increase test, normal values ββare <= 100%)
Running a bash script for dbus volume command:
export DBUS_SESSION_BUS_ADDRESS=$(cat /tmp/omxplayerdbus.${USER:-root}) dbus-send --print-reply --session --reply-timeout=500 \ --dest=org.mpris.MediaPlayer2.omxplayer \ /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set \ string:"org.mpris.MediaPlayer2.Player" \ string:"Volume" double:0.5
at startup it is equal to the volume parameter:
omxplayer --vol -602 mediaFileName.mp4
... both set the sound volume to 50%.
source share