script_library/convert_mp3_to_flac/install_ffmpeg.sh
2025-08-25 22:44:32 +08:00

40 lines
1.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
echo "=============================="
echo " FFmpeg 跨平台安装脚本"
echo "=============================="
echo
OS=$(uname -s)
if [[ "$OS" == "Darwin" ]]; then
echo "检测到 macOS 系统"
if ! command -v brew &>/dev/null; then
echo "未检测到 Homebrew正在安装..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
echo "使用 Homebrew 安装 FFmpeg..."
brew install ffmpeg
elif [[ "$OS" == "Linux" ]]; then
echo "检测到 Linux 系统"
if command -v apt &>/dev/null; then
sudo apt update
sudo apt install -y ffmpeg
elif command -v dnf &>/dev/null; then
sudo dnf install -y ffmpeg
elif command -v pacman &>/dev/null; then
sudo pacman -S --noconfirm ffmpeg
else
echo "未检测到常见包管理器,请手动安装 FFmpeg。"
exit 1
fi
else
echo "暂不支持的系统: $OS"
exit 1
fi
echo
echo "安装完成,版本信息:"
ffmpeg -version | head -n 1