Created
March 1, 2021 20:25
-
-
Save schtritoff/f71fd77b19835e5c1fda523f5ab3d289 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Use this script to fix AVI Xvid or DivX files to be playable on newer Samsung TV's | |
Do not run this script from Powershell ISE, only run from Powershell terminal window or Windows Terminal | |
Prerequisite: ffmpeg.exe in global path | |
#> | |
# if you want to backup files first before processing set this variable value to $true | |
[bool] $EnableBackup = $false | |
# for example, if backup fails then stop the script | |
$ErrorActionPreference = 'stop' | |
$FilesToProcess = Get-ChildItem -path $PSScriptRoot -Filter *.avi -Recurse | |
for ($i = 0; $i -lt $FilesToProcess.Length; $i++) { | |
$source = $FilesToProcess[$i].FullName | |
Write-Host $("(" + [string]($i+1) + '\' + [string]$FilesToProcess.Length + ") " + $source) -ForegroundColor red -BackgroundColor white | |
# backup | |
if ($EnableBackup -and (-not (Test-Path($($source + ".bak")) ))) { | |
Write-Host "backing up: $source" | |
Copy-Item -PAth $source -Destination $($source + ".bak") | |
} | |
# rename original file | |
Move-Item -Path $source -Destination $($source + '.baksrc') | |
# ffmpeg process, src: https://www.avforums.com/threads/a-simple-trick-to-play-avi-xvid-divx-videos-on-samsung-tv-without-re-encoding.2341579/ | |
& ffmpeg -i $('"' + $source + ".baksrc" + '"') -nostats -loglevel error -c copy -bsf:v mpeg4_unpack_bframes -vtag FMP4 $('"' + $source + '"') | |
# remove original file | |
Remove-Item -Path $($source + '.baksrc') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment