Files
web/scripts/transcode-promotion-videos.sh

41 lines
1.1 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.
#!/usr/bin/env bash
# 将 web/promotion/social 下产品视频从 .mov 转为网页通用 .mp4H.264 + AACfaststart
# 依赖:已安装 ffmpegmacOS: brew install ffmpegUbuntu: apt install ffmpeg
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DIR="$ROOT/web/promotion/social"
if ! command -v ffmpeg >/dev/null 2>&1; then
echo "未找到 ffmpeg请先安装https://ffmpeg.org/download.html"
exit 1
fi
# 与 web/src/data/promotionVideos.js 中 relVideo 基名一致(输出为同名 .mp4
FILES=(
"video-calc-demo-1.mov"
"video-calc-demo-2.mov"
"video-aiword.mov"
"video-voice-office.mov"
"video-invoice-ai.mov"
)
for f in "${FILES[@]}"; do
src="$DIR/$f"
base="${f%.mov}"
dst="$DIR/${base}.mp4"
if [[ ! -f "$src" ]]; then
echo "[跳过] 无源文件: $src"
continue
fi
echo "[转码] $src -> $dst"
ffmpeg -y -i "$src" \
-c:v libx264 -profile:v high -pix_fmt yuv420p \
-c:a aac -b:a 128k \
-movflags +faststart \
"$dst"
echo "[完成] $dst"
done
echo "全部处理结束。请部署生成的 .mp4确认后可删除本地 .mov 以减小体积(可选)。"