DOC Post Services for Laptop Ministries

Site Logo
Documents Code Admin Login

1759377358_normall.sh

Description: This script normalizes and compresses the audio for all videos in current folder.

Download File

Try wget https://doc.laptopministry.org/uploads/1759377358_normall.sh from the console

#!/bin/bash

# This script normalizes and compresses the audio for all videos in current folder.

# Check if ffmpeg is installed
if ! command -v ffmpeg &> /dev/null; then
    echo "Error: ffmpeg is not installed. Please install it first."
    exit 1
fi

# Supported video file extensions
EXTENSIONS=("webm" "m4v" "mp4" "mkv")

# Find and process video files
for ext in "${EXTENSIONS[@]}"; do
    find . -maxdepth 1 -type f -iname "*.$ext" | while read -r file; do
        echo "Processing: $file"
        
        # Get filename without extension
        filename=$(basename "$file")
        name="${filename%.*}"
        
        # Create output filename
        output="normalized_${name}.${ext}"
        
        # Normalize audio and apply compressor to enhance highs
        ffmpeg -i "$file" -c:v copy -af "compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0, loudnorm=I=-16:TP=-1.5:LRA=11" "$output"
        
        if [ $? -eq 0 ]; then
            echo "Successfully normalized: $output"
        else
            echo "Error processing: $file"
        fi
    done
done

echo "Audio normalization and compression complete!"
Back to Codes