Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Audio Converter (ac.py)

Features

  • Convert between multiple audio formats
  • Support for 13+ input formats (FLAC, WAV, AAC, M4A, OGG, WMA, etc.)
  • Multiple output formats (MP3, AAC, OGG, WAV, FLAC, Opus)
  • Batch processing, recursive scanning, smart conversion

Quick Install

1. Run installer (lib.sh)

#!/bin/bash
# lib.sh - Auto-detect OS and install dependencies
# Author: Kenneth Panio
# Universal ffmpeg installer - auto detects OS

set -e

echo "=== FFmpeg Auto-Installer ==="
echo "Detecting operating system..."

# Detect OS
if [ -f /etc/os-release ]; then
    . /etc/os-release
    OS=$ID
    VERSION=$VERSION_ID
elif [ -f /etc/debian_version ]; then
    OS="debian"
elif [ -f /etc/alpine-release ]; then
    OS="alpine"
elif [[ "$OSTYPE" == "darwin"* ]]; then
    OS="macos"
else
    OS="unknown"
fi

echo "Detected: $OS"

case $OS in
    alpine)
        echo "📦 Using apk package manager..."
        apk update
        apk add ffmpeg
        ;;
    debian|ubuntu|raspbian)
        echo "📦 Using apt package manager..."
        apt update
        apt install -y ffmpeg
        ;;
    centos|rhel|fedora)
        echo "📦 Using yum/dnf package manager..."
        if command -v dnf &> /dev/null; then
            dnf install -y ffmpeg
        else
            # EPEL repo needed for CentOS/RHEL
            yum install -y epel-release
            yum install -y ffmpeg ffmpeg-devel
        fi
        ;;
    arch|manjaro)
        echo "📦 Using pacman package manager..."
        pacman -Sy --noconfirm ffmpeg
        ;;
    opensuse*|suse)
        echo "📦 Using zypper package manager..."
        zypper install -y ffmpeg
        ;;
    macos)
        echo "📦 Using Homebrew..."
        if ! command -v brew &> /dev/null; then
            echo "Installing Homebrew first..."
            /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
        fi
        brew install ffmpeg
        ;;
    *)
        echo "❌ Unsupported OS: $OS"
        echo "Please install ffmpeg manually: https://ffmpeg.org/download.html"
        exit 1
        ;;
esac

echo -e "\n✅ Verifying installation..."
if command -v ffmpeg &> /dev/null; then
    FFMPEG_VERSION=$(ffmpeg -version | head -n1 | cut -d' ' -f3)
    echo "✓ ffmpeg: $FFMPEG_VERSION"
else
    echo "❌ ffmpeg installation failed!"
    exit 1
fi

if command -v ffprobe &> /dev/null; then
    FFPROBE_VERSION=$(ffprobe -version | head -n1 | cut -d' ' -f3)
    echo "✓ ffprobe: $FFPROBE_VERSION"
fi

echo -e "\n📊 Installation info:"
if command -v du &> /dev/null; then
    which ffmpeg ffprobe 2>/dev/null | xargs du -sh 2>/dev/null || echo "  Size info unavailable"
fi

echo -e "\n🎉 FFmpeg installation complete!"

pip3 install -r requirements.txt
echo "Done! Run: python3 ac.py"

Make it executable:

chmod +x lib.sh
sudo ./lib.sh

2. requirements.txt

pydub==0.25.1

Usage

python3 ac.py

Follow the interactive menu to select:

  • Source/destination folders
  • Output format (MP3 default)
  • Bitrate
  • Recursive scan
  • Delete originals

Examples

Source folder (default: 'original'): my_music
Destination folder (default: 'converted'): compressed
Output format (default: mp3): mp3
Select bitrate (default: 192k): 3
Search subfolders? (y/N): y
Delete original files? (y/N): n

Supported Formats

Input: .flac .wav .aac .m4a .ogg .wma .aiff .ape .opus .ac3 .dts .dsf .dff .mp3

Output: mp3, aac, ogg, wav, flac, opus

Size Comparison

Format Bitrate Size vs FLAC
MP3 320k 30-40% smaller
MP3 192k 50-60% smaller
MP3 128k 70-80% smaller

About

A lightweight Python tool that converts audio files between multiple formats with compression options.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages