Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $TARGETSIZE = 2800;
- Add-Type -AssemblyName System.Windows.Forms
- $ofd = New-Object System.Windows.Forms.OpenFileDialog -Property @{
- InitialDirectory = [Environment]::GetFolderPath('Desktop')
- Multiselect = $true
- }
- if ($ofd.ShowDialog() -ne "OK") {
- exit
- }
- $ofd.FileNames | foreach {
- echo converting $_
- $fileName = [System.IO.Path]::GetFileNameWithoutExtension($_)
- $filePath = [System.IO.Path]::GetDirectoryName($_)
- $convertedFilePath = [System.IO.Path]::Combine($filePath, "$($fileName)_4chan.webm")
- $fileInfo = $(ffprobe -v quiet -print_format json -show_format -show_streams "$($_)" | ConvertFrom-Json)
- $duration = $fileInfo.format.duration
- $targetRate = "$([Math]::Round([Math]::Min($TARGETSIZE * 8 / $duration, 4000)))k"
- ffmpeg -y -i "$($_)" -vf "scale=-1:`'min(ih,720)`'" -sn -an -c:v libvpx -b:v $targetRate -quality best -f webm -pass 1 NUL
- ffmpeg -y -i "$($_)" -vf "scale=-1:`'min(ih,720)`'" -sn -an -c:v libvpx -b:v $targetRate -quality best -f webm -pass 2 "$($convertedFilePath)"
- echo "saved to $convertedFilePath `n`n`n"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement