41 lines
1.4 KiB
PowerShell
41 lines
1.4 KiB
PowerShell
# 将 web\promotion\social 下产品视频从 .mov 转为网页通用 .mp4(H.264 + AAC,faststart)
|
||
# 依赖:已安装 ffmpeg 并在 PATH 中(Windows: https://www.gyan.dev/ffmpeg/builds/ 或 winget install ffmpeg)
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
$Root = Split-Path -Parent $PSScriptRoot
|
||
$Dir = Join-Path $Root "web\promotion\social"
|
||
|
||
$ffmpeg = Get-Command ffmpeg -ErrorAction SilentlyContinue
|
||
if (-not $ffmpeg) {
|
||
Write-Host "未找到 ffmpeg。请安装并加入 PATH:https://ffmpeg.org/download.html" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
$files = @(
|
||
"video-calc-demo-1.mov",
|
||
"video-calc-demo-2.mov",
|
||
"video-aiword.mov",
|
||
"video-voice-office.mov",
|
||
"video-invoice-ai.mov"
|
||
)
|
||
|
||
foreach ($f in $files) {
|
||
$src = Join-Path $Dir $f
|
||
$base = [System.IO.Path]::GetFileNameWithoutExtension($f)
|
||
$dst = Join-Path $Dir "$base.mp4"
|
||
if (-not (Test-Path -LiteralPath $src)) {
|
||
Write-Host "[跳过] 无源文件: $src" -ForegroundColor Yellow
|
||
continue
|
||
}
|
||
Write-Host "[转码] $src -> $dst"
|
||
& ffmpeg -y -i $src `
|
||
-c:v libx264 -profile:v high -pix_fmt yuv420p `
|
||
-c:a aac -b:a 128k `
|
||
-movflags +faststart `
|
||
$dst
|
||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||
Write-Host "[完成] $dst" -ForegroundColor Green
|
||
}
|
||
|
||
Write-Host "全部处理结束。请部署生成的 .mp4;确认后可删除本地 .mov(可选)。" -ForegroundColor Cyan
|