首次提交
This commit is contained in:
26
scripts/set_ffmpeg.sh
Normal file
26
scripts/set_ffmpeg.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# 一键切换项目 bin/ffmpeg 的版本(本机自用 cpu / 打 GPU 包 gpu)
|
||||
# bash temp/set_ffmpeg.sh cpu # johnvansickle 全静态,任何 glibc 都能跑(本机自用)
|
||||
# bash temp/set_ffmpeg.sh gpu # BtbN 含 cuda/nvdec,需 glibc>=2.28(给 GPU 机器)
|
||||
set -euo pipefail
|
||||
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # 项目根
|
||||
V="${1:-cpu}"
|
||||
BIN="$(pwd)/bin"; mkdir -p "$BIN"
|
||||
have(){ command -v "$1" >/dev/null 2>&1; }
|
||||
|
||||
case "$V" in
|
||||
cpu) URL="https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz" ;;
|
||||
gpu) URL="https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz" ;;
|
||||
*) echo "用法: bash temp/set_ffmpeg.sh [cpu|gpu]"; exit 1 ;;
|
||||
esac
|
||||
|
||||
echo "下载 $V 版 ffmpeg ..."
|
||||
tmp="$(mktemp -d)"
|
||||
if have curl; then curl -L "$URL" -o "$tmp/ff.tar.xz"; else wget -O "$tmp/ff.tar.xz" "$URL"; fi
|
||||
tar xf "$tmp/ff.tar.xz" -C "$tmp"
|
||||
ffb="$(find "$tmp" -type f -name ffmpeg | head -1)"
|
||||
ffp="$(find "$tmp" -type f -name ffprobe | head -1)"
|
||||
cp "$ffb" "$ffp" "$BIN/"
|
||||
chmod +x "$BIN/ffmpeg" "$BIN/ffprobe"
|
||||
rm -rf "$tmp"
|
||||
echo "已切到 $V 版: $("$BIN/ffmpeg" -version 2>&1 | head -1 || echo '本机跑不了(若是 gpu 版+老 glibc,正常)')"
|
||||
Reference in New Issue
Block a user