上述是FFMPEG官方的说明.有PY程序能自动化对影音文件的音量进行重整,统一大小,不至于一首歌大一首歌小.
至于本人: 手动测试了,ffmpeg手动,对音量小的视频进行了放大.
ffmpeg -nostats -i ****.mp4 -filter_complex ebur128 -f null - (过滤器可选为 ebur128 volumedetect任一一种)
得到音频大小. 下述进行更改.
ffmpeg -i ***.mp4 -af volume=32dB -y Rust01.mp4 正向增加 负向减少.
ffmpeg -i input.wav -filter:a "volume=0.5" output.wav 更改为原来的多少倍
上述两方案分贝听说比倍数的好. 但还是不够好,用响度的方案会更好.
响度方案 拿数据
代码: 全选
ffmpeg -i input.wav -af loudnorm=I=-16:TP=-1.5:LRA=11:print_format=json -vn -dn -sn -f null -
"input_i" : "-45.31", 所需参数
"input_tp" : "-12.92", 所需参数
"input_lra" : "12.80", 所需参数
"input_thresh" : "-56.28", 所需参数
"output_i" : "-16.71",
"output_tp" : "-1.50",
"output_lra" : "9.40",
"output_thresh" : "-27.80",
"normalization_type" : "dynamic",
"target_offset" : "0.71" 所需参数
然后再传递参数进行重新编码音频
代码: 全选
ffmpeg -y -i rust更改音量/Rust02.mp4 -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=-13.00:measured_TP=9.10:measured_LRA=14.50:measured_thresh=-25.15:offset=0.80:print_format=summary -c:v copy rust更改音量/Rust02t2.mp4
命令太长,搞成多段式脚本
代码: 全选
#! /bin/bash
#一号参数为要分析的文件名
ffmpeg -i $1 -af loudnorm=I=-16:TP=-1.5:LRA=11:print_format=json -vn -sn -dn -f null -
代码: 全选
sed '11,$d' loud.txt| sed '5,9d' loud.txt >louddel.txt
代码: 全选
sed -i 's/.*" : "//g' louddel.txt; sed -i 's/",//g' louddel.txt; sed -i 's/"//g' louddel.txt
-45.31
-12.92
12.80
-56.28
0.71
转码脚本
代码: 全选
#! /bin/bash
#1号参数为输入文件名,2号参数为输出文件名
str1=`sed -n '1p' louddel.txt`;
str2=`sed -n '2p' louddel.txt`;
str3=`sed -n '3p' louddel.txt`;
str4=`sed -n '4p' louddel.txt`;
str5=`sed -n '5p' louddel.txt`;
# echo $str1,$str2,$str3,$str4,$str5
num1=$(date +%s%N);ffmpeg -y -i $1 -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=$str1:measured_TP=$str2:measured_LRA=$str3:measured_thresh=$str4:offset=$str5:print_format=summary -c:v copy $2 ;num2=$(date +%s%N); echo $(($num2-$num1));