feat: 服务端 promotion 视频自动转码;首页宣传册预览与 mp4 配置
Made-with: Cursor
This commit is contained in:
40
scripts/transcode-promotion-videos.ps1
Normal file
40
scripts/transcode-promotion-videos.ps1
Normal file
@@ -0,0 +1,40 @@
|
||||
# 将 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
|
||||
Reference in New Issue
Block a user