Last active
September 13, 2022 18:25
-
-
Save ErgEnn/2c19fc12adbb307b4feb321e3794cd09 to your computer and use it in GitHub Desktop.
Due to many video files being in awkward encoding, they can't be easily copied from one site and pasted to another. This script monitors a folder and whenever new file appears, it runs it through ffmpeg and opens the explorer with new file selected
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
$folder = 'D:\Ergo\Videos\convert_queue' | |
$filter = '*.*' | |
$fsw = New-Object IO.FileSystemWatcher $folder, $filter | |
$fsw.IncludeSubdirectories = $false | |
$fsw.NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' | |
$a = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated | |
while($true) { | |
$vnt = Wait-Event -SourceIdentifier FileCreated | |
$name = $vnt.SourceEventArgs.Name | |
$path = $vnt.SourceEventArgs.FullPath | |
&"C:\Users\Ergo\Documents\ShareX\Tools\ffmpeg.exe" -i "$($path)" -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -movflags +faststart -c:a aac -b:a 128k -y "D:\Ergo\Videos\Random\$($name)" | |
Remove-Item $path | |
Start-Process -FilePath C:\Windows\explorer.exe -ArgumentList "/select, ""D:\Ergo\Videos\Random\$($name)""" | |
Remove-Event -SourceIdentifier FileCreated | |
Start-Sleep -Seconds 1 | |
} |
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
PowerShell -Command "Set-ExecutionPolicy -Scope CurrentUser Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 | |
powershell.exe -windowstyle hidden -file "D:\Ergo\Videos\convert_queue\converter.ps1" >> "%TEMP%\StartupLog.txt" 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment