Guest User

Untitled

a guest
Feb 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. param (
  2. [Parameter(Mandatory = $true)][string]$inputFolder
  3. )
  4.  
  5. Get-ChildItem -File -Recurse $inputFolder | ForEach-Object {
  6. $fullName = $_.fullname
  7. $cmdOutput = ffmpeg -i "$fullName" 2>&1
  8. #if no video or no audio, skip
  9. $hasVideo = $cmdOutput|Select-String -Pattern "Video:"
  10. $hasAudio = $cmdOutput|Select-String -Pattern "Audio:"
  11. if ($hasVideo -and $hasAudio) {
  12. #Is already h264
  13. $VideoCodec = "copy"
  14. $AudioCodec = "copy"
  15. $Video = $cmdOutput|Select-String -Pattern "Video:"|Select-String -Pattern "h264"
  16. if (!$Video) {
  17. $VideoCodec = "libx264"
  18. }
  19.  
  20. $Video = $cmdOutput|Select-String -Pattern "Video:"|Select-String -Pattern "High 10"
  21. if ($Video) {
  22. $VideoCodec = "libx264"
  23. }
  24.  
  25.  
  26. $Audio = $cmdOutput|Select-String -Pattern "Audio:"|Select-String -Pattern "aac"
  27. if (!$Audio) {
  28. $AudioCodec = "aac"
  29. }
  30.  
  31. "$VideoCodec $AudioCodec $fullName"
  32. #is Already AAC
  33. if ($AudioCodec -ne "copy" -or $VideoCodec -ne "copy") {
  34. $newName = "$fullName.converted.avi"
  35. ffmpeg -i "$fullName" -y -f mp4 -acodec $AudioCodec -ab 192k -ac 2 -absf aac_adtstoasc -async 2 -vcodec $VideoCodec -vsync 0 -level 4.1 -qmax 22 -qmin 20 -x264opts no-cabac:ref=2 -threads 0 $newName
  36. Remove-Item -Path "$fullName"
  37. Rename-Item -Path $newName $fullName
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment