Created
May 20, 2015 02:39
-
-
Save rpunt/27640521034506e5dce1 to your computer and use it in GitHub Desktop.
Batch-encode all .MKV containers in a directory to AppleTV-compatible .MP4
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
$scandir = "d:\video" | |
$outputdir = "d:\encoded" | |
$filelist = Get-ChildItem $scandir -filter *.mkv -recurse | |
$num = $filelist | measure | |
$filecount = $num.count | |
$i = 0; | |
ForEach ($file in $filelist) | |
{ | |
$i++; | |
$oldfile = $file.DirectoryName + "\" + $file.BaseName + $file.Extension; | |
$newfile = $outputdir + "\" + $file.Directory.Name + ".m4v"; | |
$progress = ($i / $filecount) * 100 | |
$progress = [Math]::Round($progress,2) | |
Clear-Host | |
Write-Host ------------------------------------------------------------------------------- | |
Write-Host Handbrake Batch Encoding | |
Write-Host "Processing - $oldfile -> $newfile" | |
Write-Host "File $i of $filecount - $progress%" | |
Write-Host ------------------------------------------------------------------------------- | |
Start-Process "d:\Program Files\HandBrake\HandBrakeCLI.exe" -ArgumentList "-i `"$oldfile`" -t 1 --angle 1 -o `"$newfile`" -f mp4 -w 720 --crop 56:64:10:4 --loose-anamorphic --modulus 2 -e x264 -q 20 -r 30 --pfr -a 1,1 -E av_aac,copy:ac3 -6 dpl2,none -R Auto,Auto -B 160,0 -D 0,0 --gain 0,0 --audio-fallback ac3 --native-language eng --subtitle scan --subtitle-forced --encoder-preset=fast --encoder-level=`"3.0`" --encoder-profile=baseline --verbose=0" -Wait -NoNewWindow | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes that all .mkv files are contained beneath d:\video\MOVIE TITLE*.mkv. Output placed in d:\encoded\MOVIE TITLE.m4v