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

  • A+
所属分类:linux技术
摘要

omxplayer 在github中的描述是一个弃子,原文是这样的: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.


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

omxplayer介绍

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

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.

这段话大概的意思是,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)

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

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

自己动手丰衣足食!欢迎大家留言交流啊!