FFMpeg 获取音频音量、提高音量

查看音量

准备原生音频original.mp3

查看original.mp3的音量信息:

bash 复制代码
ffmpeg -i original.mp3 -filter_complex volumedetect -c:v copy -f null /dev/null

输出:

bash 复制代码
Input #0, mp3, from 'original.mp3':
  Metadata:
    artist          : Administrator
    encoder         : Studio One 6.0.1.90430
    TBPM            : 120
    date            : 2023
  Duration: 00:00:26.41, start: 0.025057, bitrate: 320 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
    Metadata:
      encoder         : LAME3.100
[Parsed_volumedetect_0 @ 0x55d0ba56dac0] n_samples: 0
Stream mapping:
  Stream #0:0 (mp3float) -> volumedetect:default
  volumedetect:default -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
  Metadata:
    artist          : Administrator
    date            : 2023
    TBPM            : 120
    encoder         : Lavf60.3.100
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc60.3.100 pcm_s16le
size=N/A time=00:00:26.35 bitrate=N/A speed= 684x    A    
video:0kB audio:4544kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_volumedetect_0 @ 0x55d0ba59c280] n_samples: 2326514
[Parsed_volumedetect_0 @ 0x55d0ba59c280] mean_volume: -35.5 dB
[Parsed_volumedetect_0 @ 0x55d0ba59c280] max_volume: -13.8 dB
[Parsed_volumedetect_0 @ 0x55d0ba59c280] histogram_13db: 8
[Parsed_volumedetect_0 @ 0x55d0ba59c280] histogram_14db: 99
[Parsed_volumedetect_0 @ 0x55d0ba59c280] histogram_15db: 189
[Parsed_volumedetect_0 @ 0x55d0ba59c280] histogram_16db: 191
[Parsed_volumedetect_0 @ 0x55d0ba59c280] histogram_17db: 273
[Parsed_volumedetect_0 @ 0x55d0ba59c280] histogram_18db: 596
[Parsed_volumedetect_0 @ 0x55d0ba59c280] histogram_19db: 1003

音量平均值:mean_volume: -35.5 dB

音量最大值:max_volume: -13.8 dB

提高音量

bash 复制代码
ffmpeg -i original.mp3 -af "volume=3.0,highpass=f=200,lowpass=f=3000,afftdn=nr=50" original.volume=3.0,highpass=f=200,lowpass=f=3000,afftdn=nr=50.wav

参数简单说明下:

volume:提供响度,3.0表示提高为原来的3倍;

hightpass:高通滤波器;

lowpass:低通滤波器;

afftdn:使用FFT对音频样本进行降噪

输出:

bash 复制代码
Input #0, mp3, from 'original.mp3':
  Metadata:
    artist          : Administrator
    encoder         : Studio One 6.0.1.90430
    TBPM            : 120
    date            : 2023
  Duration: 00:00:26.41, start: 0.025057, bitrate: 320 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
    Metadata:
      encoder         : LAME3.100
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'original.volume=3.0,highpass=f=200,lowpass=f=3000,afftdn=nr=50.wav':
  Metadata:
    IART            : Administrator
    ICRD            : 2023
    TBPM            : 120
    ISFT            : Lavf60.3.100
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc60.3.100 pcm_s16le
size=    4544kB time=00:00:26.37 bitrate=1411.4kbits/s speed= 165x       
video:0kB audio:4544kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.002450%

在提高音量后,再看看音量信息:

bash 复制代码
ffmpeg -i original.volume\=3.0\,highpass\=f\=200\,lowpass\=f\=3000\,afftdn\=nr\=50.wav -filter_complex volumedetect -c:v copy -f null /dev/null

输出:

bash 复制代码
Input #0, wav, from 'original.volume=3.0,highpass=f=200,lowpass=f=3000,afftdn=nr=50.wav':
  Metadata:
    artist          : Administrator
    date            : 2023
    encoder         : Lavf60.3.100
  Duration: 00:00:26.38, bitrate: 1411 kb/s
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
[Parsed_volumedetect_0 @ 0x55819c4a4200] n_samples: 0
Stream mapping:
  Stream #0:0 (pcm_s16le) -> volumedetect:default
  volumedetect:default -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
  Metadata:
    artist          : Administrator
    date            : 2023
    encoder         : Lavf60.3.100
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc60.3.100 pcm_s16le
size=N/A time=00:00:26.35 bitrate=N/A speed=1.88e+03x     
video:0kB audio:4544kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_volumedetect_0 @ 0x55819c4c35c0] n_samples: 2326514
[Parsed_volumedetect_0 @ 0x55819c4c35c0] mean_volume: -33.3 dB
[Parsed_volumedetect_0 @ 0x55819c4c35c0] max_volume: -7.7 dB
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_7db: 6
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_8db: 18
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_9db: 63
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_10db: 78
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_11db: 123
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_12db: 236
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_13db: 324
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_14db: 474
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_15db: 732
[Parsed_volumedetect_0 @ 0x55819c4c35c0] histogram_16db: 1144

音量平均值:mean_volume: -33.3 dB

音量最大值:max_volume: -7.7 dB

相关推荐
问道飞鱼5 小时前
【工具介绍】Ffmpeg工具介绍与简单使用
ffmpeg·视频工具
l***775210 小时前
从MySQL5.7平滑升级到MySQL8.0的最佳实践分享
ffmpeg
ZouZou老师16 小时前
FFmpeg性能优化经典案例
性能优化·ffmpeg
极智-99617 小时前
视频文件格式?【图文详解】视频文件后缀名?视频文件格式转换?
音视频·视频文件格式·视频文件后缀名·视频文件格式转换
Android系统攻城狮17 小时前
Android16音频之设置HDMI音频setHdmiSystemAudioSupported:用法实例(一百一十六)
音视频·android16·音频进阶·hdmi音频
aqi0018 小时前
FFmpeg开发笔记(九十)采用FFmpeg套壳的音视频转码百宝箱FFBox
ffmpeg·音视频·直播·流媒体
颜颜yan_19 小时前
基于昇腾CANN的智能视频分析系统落地实践
架构·音视频·昇腾
齐齐大魔王20 小时前
FFmpeg
ffmpeg
你好音视频1 天前
FFmpeg RTSP拉流流程深度解析
ffmpeg
顾道长生'1 天前
(Arxiv-2025)ID-COMPOSER:具有分层身份保持的多主体视频合成
计算机视觉·音视频·composer