>>146157$ErrorActionPreference = 'Continue'
$logPath = Join-Path $PSScriptRoot 'ffmpeg_log.txt'
"Starting at $(Get-Date)" | Out-File -FilePath $logPath -Encoding utf8
$extensions = '*.mp4','*.avi','*.mkv','*.mov','*.flv','*.wmv','*.m4v','*.webm'
$files = Get-ChildItem -LiteralPath $PSScriptRoot -Include $extensions -File
Write-Host "Found $($files.Count) video files"
Write-Host ""
foreach ($file in $files) {
$name = $file.BaseName
$ext = $file.Extension
if ($name -like '*_fixed*') {
"Skipping: $($file.Name) [contains _fixed]" | Tee-Object -FilePath $logPath -Append
continue
}
if ($name -like '*_noaudio*') {
"Skipping: $($file.Name) [contains _noaudio]" | Tee-Object -FilePath $logPath -Append
continue
}
$outFile = Join-Path $file.DirectoryName ($name + '_fixed' + $ext)
"---" | Out-File -FilePath $logPath -Append -Encoding utf8
"Processing: $($file.Name)" | Out-File -FilePath $logPath -Append -Encoding utf8
Write-Host "Processing: $($file.Name)"
& ffmpeg -i $file.FullName -c:v copy -c:a copy $outFile *>> $logPath
if ($LASTEXITCODE -eq 0) {
"OK: $($file.Name)" | Out-File -FilePath $logPath -Append -Encoding utf8
Write-Host " OK"
} else {
"FAIL: $($file.Name) [exit $LASTEXITCODE]" | Out-File -FilePath $logPath -Append -Encoding utf8
Write-Host " FAIL"
}
}
"Done" | Out-File -FilePath $logPath -Append -Encoding utf8
Write-Host ""
Write-Host "Done - see ffmpeg_log.txt"
you need ffmpeg