Audio Volume Analysis and Adjustment with FFmpeg

  1. Inspecting Media File Metadata

To examine basic properties of a media file such as trailer.mp4, use either ffprobe or ffmpeg -i:

$ ffprobe -hide_banner trailer.mp4
$ ffmpeg -i trailer.mp4 -hide_banner

The output reveals key audio characteristics:

  • Channels: stereo, 5.1, etc.
  • Audio codec: e.g., AAC
  • Sample rate: typically 44100 Hz or 48000 Hz
  • Bitrate: e.g., 125 kb/s

Video details (e.g., resolution, frame rate, codec) are also displayed but are not the focus here.

  1. Detecting Audio Volume Levels

Use the volumedetect filter to analyze loduness:

$ ffmpeg -i trailer.mp4 -hide_banner -filter_complex volumedetect -c:v copy -f null /dev/null

Relevant output includes:

[Parsed_volumedetect_0] mean_volume: -17.2 dB
[Parsed_volumedetect_0] max_volume: -1.8 dB

mean_volume indicates average perceived loudnesss; max_volume shows peak level. Values closer to 0 dB are louder.

  1. Generating Audio Waveform Visualizations

3.1 Combined Stereo Waveform

$ ffmpeg -i trailer.mp4 -filter_complex "showwavespic=s=640x120" -frames:v 1 waveform_combined.png

3.2 Separate Channel Waveforms

$ ffmpeg -i trailer.mp4 -filter_complex "showwavespic=s=640x240:split_channels=1" -frames:v 1 waveform_split.png

The split_channels=1 option renders each audio channel independently.

  1. Adjusting Audio Volume

4.1 Using the Legacy -vol Option

The -vol flag uses a scale where 256 = 100% volume:

$ ffmpeg -i input.mp4 -vol 128 output_quiet.mp4    # 50% volume
$ ffmpeg -i input.mp4 -vol 512 output_loud.mp4     # 200% volume

Note: -vol is deprecated in favor of the volume audio filter.

4.2 Proportional Volume Scaling

Use the volume filter with ratios or decimals:

$ ffmpeg -i input.aac -af "volume=0.5" output_half.aac
$ ffmpeg -i input.aac -af "volume=2/3" output_two_thirds.aac

4.3 Absolute Volume Adjustment in Decibels

Apply fixed dB gain or attenuation:

$ ffmpeg -i input.mkv -af "volume=10dB" louder.mkv
$ ffmpeg -i input.mkv -af "volume=-10dB" quieter.mkv

  1. Comparing Volume Adjustment Methods

5.1 Parameter Equivalence Reference

-vol (base 256) -af volume= (ratio) Decibel (dB)
64 1/4 0.25
128 1/2 0.5
171 2/3 0.67
256 1.0 0 dB
384 3/2 1.5
512 2 2.0
1024 4 4.0

Conversion: volume_ratio = vol_value / 256. Decibel values are approximate due to logarithmic perception.

  1. Batch Processing Script

The following Bash script automates waveform generation for all .aac files:

#!/bin/bash
for file in *.aac; do
    echo "# ====== $file = mean_volume = global ====" >> analysis.md
    date >> analysis.md

    # Uncomment desired operation:
    # ffmpeg -i "$file" -filter_complex "showwavespic=s=640x120" -frames:v 1 "combined_$file.png"
    ffmpeg -i "$file" -filter_complex "showwavespic=s=640x240:split_channels=1" -frames:v 1 "split_$file.png"

    date >> analysis.md
    echo >> analysis.md
done

Features:

  • Processes multiple files in sequence
  • Logs timestamps for performance tracking
  • Generates per-file waveform images
  • Output metadata appended to analysis.md to easy review

Tags: ffmpeg audio-processing volume-normalization waveform-visualization bash-scripting

Posted on Tue, 26 May 2026 17:07:17 +0000 by syamswaroop