179 lines · 4.1 KB · executable
#!/usr/bin/env bash
#
# Remove audio from video files
# Usage: mute.sh [options] <input> [output]

set -e

# Default values
VCODEC="copy"
OVERWRITE=false

# Show usage
usage() {
    cat <<'EOF'
Usage: mute.sh [options] <input> [output]

Options:
    -c, --copy       Copy video stream without re-encoding (default, fastest)
    -v, --vcodec     Video codec for re-encoding (e.g., libx264, libx265)
    -y, --yes        Overwrite output without asking
    -h, --help       Show this help

Examples:
    mute.sh input.mp4 output.mp4         # Remove audio, copy video
    mute.sh input.mp4                    # Creates input-muted.mp4
    mute.sh -c input.mp4                 # Same as above (explicit copy)
    mute.sh -v libx264 input.mp4         # Re-encode with H.264
    mute.sh -y *.mp4                     # Batch mute, overwrite existing
EOF
    exit 0
}

# Check if ffmpeg is installed
check_deps() {
    if ! command -v ffmpeg &>/dev/null; then
        echo "Error: ffmpeg not found. Please install ffmpeg." >&2
        echo "  macOS: brew install ffmpeg" >&2
        echo "  Ubuntu/Debian: sudo apt-get install ffmpeg" >&2
        echo "  Arch: sudo pacman -S ffmpeg" >&2
        return 1