我正在使用Windows Server Edition 2012,并且使用Powershell非常新.基本上,我试图将目录中的一堆视频文件转换为.flv.我使用的代码是这样的:
$inProcessPath = "E:\Random Videos\In Process\$env:username\"
$oldVideos = Get-ChildItem -Include @("*.mp4", "*.avi", "*.divx", "*.mov", "*.mpg", "*.wmv", "*.mkv") -Path $inProcessPath -Recurse #gets all of the videos
cd "E:\FFMPEG\bin\"
foreach ($oldVideo in $oldVideos) {
$newVideo = [io.path]::ChangeExtension($oldSong.FullName, '.flv')
.\ffmpeg.exe -i $oldVideo -y -async 1 -b 2000k -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset superfast $newVideo
}
Run Code Online (Sandbox Code Playgroud)
每当我运行它时,我都没有收到任何错误消息,但ffmpeg也没有运行.我敢肯定我忽视了一些东西,但不知道那可能是什么.我搜索了网站,并将代码与其他人进行了比较,但仍然不知道.
任何帮助将非常感谢.
Tre*_*van 10
它很可能与您的命令行参数有关.由于文件系统路径中包含空格,因此您需要确保引用文件系统路径.
给这个代码一个镜头:
$inProcessPath = "E:\Random Videos\In Process\$env:username\"
$oldVideos = Get-ChildItem -Include @("*.mp4", "*.avi", "*.divx", "*.mov", "*.mpg", "*.wmv", "*.mkv") -Path $inProcessPath -Recurse;
Set-Location -Path 'E:\FFMPEG\bin\';
foreach ($oldVideo in $oldVideos) {
$newVideo = [io.path]::ChangeExtension($oldSong.FullName, '.flv')
# Declare the command line arguments for ffmpeg.exe
$ArgumentList = '-i "{0}" -y -async 1 -b 2000k -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset superfast "{1}"' -f $oldVideo, $newVideo;
# Display the command line arguments, for validation
Write-Host -ForegroundColor Green -Object $ArgumentList;
# Pause the script until user hits enter
$null = Read-Host -Prompt 'Press enter to continue, after verifying command line arguments.';
# Kick off ffmpeg
Start-Process -FilePath c:\path\to\ffmpeg.exe -ArgumentList $ArgumentList -Wait -NoNewWindow;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10443 次 |
| 最近记录: |