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

相关推荐
MediaTea1 小时前
Pr 视频过渡:沉浸式视频 - VR 色度泄漏
音视频·vr
LNTON羚通1 小时前
算法定制LiteAIServer摄像机实时接入分析平台烟火检测算法的主要功能
音视频·视频监控
EasyCVR7 小时前
EHOME视频平台EasyCVR视频融合平台使用OBS进行RTMP推流,WebRTC播放出现抖动、卡顿如何解决?
人工智能·算法·ffmpeg·音视频·webrtc·监控视频接入
简鹿办公8 小时前
使用 FFmpeg 进行音视频转换的相关命令行参数解释
ffmpeg·简鹿视频格式转换器·ffmpeg视频转换
冷凝女子9 小时前
【QT】海康视频及openCv抓拍正脸接口
qt·opencv·音视频·海康
安步当歌10 小时前
【WebRTC】视频编码链路中各个类的简单分析——VideoStreamEncoder
音视频·webrtc·视频编解码·video-codec
顾北川_野10 小时前
Android CALL关于电话音频和紧急电话设置和获取
android·音视频
顶呱呱程序10 小时前
2-143 基于matlab-GUI的脉冲响应不变法实现音频滤波功能
算法·matlab·音视频·matlab-gui·音频滤波·脉冲响应不变法
EasyCVR11 小时前
萤石设备视频接入平台EasyCVR多品牌摄像机视频平台海康ehome平台(ISUP)接入EasyCVR不在线如何排查?
运维·服务器·网络·人工智能·ffmpeg·音视频
runing_an_min11 小时前
ffmpeg 视频滤镜:屏蔽边框杂色- fillborders
ffmpeg·音视频·fillborders