RaspberryPi 树莓派 omxplayer 的音量设置方法实测有效!

正确的设置初始音量的方法,其中n/100=你指望的初始dB值, omxplayer --vol n target.media

omxplayer介绍

omxplayer 在github中的描述是一个弃子,原文是这样的:git

Note: omxplayer is being deprecated and resources are directed at improving vlc.
This is due to: omxplayer uses openvg for OSD and subtitles which isn't supported on Pi4. omxplayer uses openmax which has been deprecated for a long time and isn't supported with 64-bit kernels. omxplayer does not support software decode omxplayer does not support advanced subtitles omxplayer does not support playback from ISO files. omxplayer does not integrate with the X desktop
Please try using vlc. If there are features of omxplayer that vlc does not handle then try reporting here.github

这段话大概的意思是,omxplayer使用的库不好劲,不支持这、不支持那的,已经被咱们放弃了,你们也尽快转向vlc吧!
你们也能够尝试使用vlc,加上 -I cli 也能够用命令行控制,也挺好用的。测试

命令解析及发现命令的使用方法的过程

下面这些是 omxplayer 关于音量的帮助,其中 mB=millibels。命令行

--vol n set initial volume in millibels (default 0)
volume = pow(10, mB / 2000.0);
mB = 2000.0 * log10(volume)3d

--vol n 这个参数接受的数字 n 可能会被分为两部分,小于100的部分化为 正真音量的小数点后两位,大于100的化为小数点左边的值。或者说,n/100=实际的音量 dB 值。
而后,我一开始是怀疑个人程序版本更新了,可是网上依然在挂以前的帮助,因此我无法用她们的格式来初始化音量。因此我首先测试的是参数的格式对不对,好比 --vol=n['n']这类的格式看看有没有报错,有没有报错,然而没有。接着我怀疑人家要求的是 double类型的参数,我若是不加一个小数点可能会以错误方式识别。然而,仍是没有反应。
就在我要放弃的时候,忽然发现我在控制界面按 - 减音量的时候,下减的间隔同样,但和以前的最终值不同。我看到了曙光!有了这条线索,我首先从新作了实验!code

实验次数 n的值 第一次按-的返回值 按-的下降间隔
1 -100 -4.00dB 3dB
2 -150 -4.5dB 3dB
3 -15.00 -3.15dB 3dB
4 -6000 -63.00dB 3dB

本身动手丰衣足食!欢迎你们留言交流啊!get