-
05-07-2019 - |
题
我需要知道的平均量的mp3文件,以便当我把它mp3(在不同的速率)我可以规模的体积太正常化它...
因此我需要一个命令行的工具/红宝石图书馆,让我平均卷在数据库。
解决方案
你可以使用sox(一个开放源命令行音频工具 http://sox.sourceforge.net/sox.html)正常化和代码转换你的文件在同一时间。
编辑
看起来就像它没有选择的位速率。无论如何,sox可能是矫枉过正,如果跛脚的不正常化。
其他提示
你可以使用 瘸腿 编码mp3。它有选择为正规化、扩展和比特率。瘸腿还编制的几乎任何平台。
http://mp3gain.sourceforge.net/ 是一个深思熟虑的解决方案。
我写了一个小包装脚本,基于上述输入:
#!/bin/sh
# Get the current volume (will reset to this later).
current=`amixer -c 0 get Master 2>&1 |\
awk '/%/ {
p=substr($4,2,length($4)-2);
if( substr(p,length(p)) == "%" )
{
p = substr(p,1,length(p)-1)
}
print p
}'`
# Figure out how loud the track is. The normal amplitude for a track is 0.1.
# Ludicrously low values are 0.05, high is 0.37 (!!?)
rm -f /tmp/$$.out
/usr/bin/mplayer -vo null -ao pcm:file=/tmp/$$.out $1 >/dev/null 2>&1
if [ $? = 0 ] ; then
amplitude=`/usr/bin/sox /tmp/$$.out -n stat 2>&1 | awk '/RMS.+amplitude/ {print $NF}'`
fi
rm -f /tmp/$$.out
# Set an appropriate volume for the track.
to=`echo $current $amplitude | awk '{printf( "%.0f%%", $1 * 0.1/$2 );}'`
echo $current $amplitude | awk '{print "Amplitude:", $2, " Setting volume to:", 10/$2 "%, mixer volume:", $1 * 0.1/$2}'
amixer -c 0 set Master $to >/dev/null 2>&1
mplayer -quiet -cache 2500 $1
# Reset the volume for next time.
amixer -c 0 set Master "$current%" >/dev/null 2>&1
它需要一个额外的第二个开始播放文件,并依赖于alsamixer以调节音量,但它没有一个非常好的工作保持必要不断调整主量。它真的不在乎什么输入格式,因为如果下可以发挥它,就可以提取的声音,所以它应工作的现有MP3,Ogg,AVI,无论。
不隶属于 StackOverflow