Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $TARGETSIZE = 2800;
  2.  
  3.  
  4. Add-Type -AssemblyName System.Windows.Forms
  5.  
  6. $ofd = New-Object System.Windows.Forms.OpenFileDialog -Property @{
  7.     InitialDirectory = [Environment]::GetFolderPath('Desktop')
  8.     Multiselect = $true
  9. }
  10.  
  11. if ($ofd.ShowDialog() -ne "OK") {
  12.     exit
  13. }
  14.  
  15.  
  16. $ofd.FileNames | foreach {
  17.     echo converting $_
  18.     $fileName = [System.IO.Path]::GetFileNameWithoutExtension($_)
  19.     $filePath = [System.IO.Path]::GetDirectoryName($_)
  20.     $convertedFilePath = [System.IO.Path]::Combine($filePath, "$($fileName)_4chan.webm")
  21.     $fileInfo = $(ffprobe -v quiet -print_format json -show_format -show_streams "$($_)" | ConvertFrom-Json)
  22.     $duration = $fileInfo.format.duration
  23.    
  24.     $targetRate = "$([Math]::Round([Math]::Min($TARGETSIZE * 8 / $duration, 4000)))k"
  25.  
  26.     ffmpeg -y -i "$($_)" -vf "scale=-1:`'min(ih,720)`'" -sn -an -c:v libvpx -b:v $targetRate -quality best -f webm -pass 1 NUL
  27.     ffmpeg -y -i "$($_)" -vf "scale=-1:`'min(ih,720)`'" -sn -an -c:v libvpx -b:v $targetRate -quality best -f webm -pass 2 "$($convertedFilePath)"
  28.    
  29.     echo "saved to $convertedFilePath `n`n`n"
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement