mayankjoin3

ffmpeg video convertor batch powershell profile

Feb 17th, 2026 (edited)
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. date >> time.txt
  2.  
  3. $inputDir  = "D:\Downloads\Marraige Video\video"
  4. $outputDir = Join-Path $inputDir "resize"
  5.  
  6. # Create output folder if missing
  7. New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
  8.  
  9. # ==========================
  10. # Output profiles (keep only what you want; comment others)
  11. # ==========================
  12. $profiles = @(
  13.     # @{ Name="480p";  Height=480;  Fps=30; Crf=23; Preset="medium"; Abitrate="128k" }
  14.     # @{ Name="720p";  Height=720;  Fps=30; Crf=23; Preset="medium"; Abitrate="128k" }
  15.     @{ Name="1080p"; Height=1080; Fps=30; Crf=23; Preset="medium"; Abitrate="128k" }
  16.     # @{ Name="2k";    Height=1440; Fps=30; Crf=23; Preset="medium"; Abitrate="160k" }
  17.     # @{ Name="4k";    Height=2160; Fps=30; Crf=23; Preset="slow";   Abitrate="192k" }
  18. )
  19.  
  20. if (-not $profiles -or $profiles.Count -eq 0) {
  21.     Write-Host "No profiles enabled. Uncomment at least one profile in `$profiles."
  22.     exit 1
  23. }
  24.  
  25. Get-ChildItem -Path $inputDir -Filter *.mp4 -File | ForEach-Object {
  26.     $inFile = $_.FullName
  27.     $base   = $_.BaseName
  28.  
  29.     foreach ($p in $profiles) {
  30.         # Output file suffix is profile name (e.g., _1080p)
  31.         $outFile = Join-Path $outputDir ("{0}_{1}.mp4" -f $base, $p.Name)
  32.  
  33.         Write-Host "Converting ($($p.Name)): $inFile -> $outFile"
  34.         & ffmpeg -hide_banner -y -i $inFile `
  35.           -vf "scale=-2:$($p.Height),fps=$($p.Fps)" `
  36.           -c:v libx264 -preset $($p.Preset) -crf $($p.Crf) -pix_fmt yuv420p `
  37.           -c:a aac -b:a $($p.Abitrate) `
  38.           $outFile
  39.     }
  40. }
  41.  
  42. Write-Host "Done. Output in: $outputDir"
  43.  
  44. date >> time.txt
  45.  
Advertisement
Add Comment
Please, Sign In to add comment