Last active
December 17, 2023 22:38
-
-
Save redfellow/970ec6ebfa8380d604aeedbf12a3020f to your computer and use it in GitHub Desktop.
Powershell script to batch-encode recursively, using a custom handbrake preset
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
$filelist = Get-ChildItem "F:\path\to\vids\" -filter *.avi -recurse | |
$num = $filelist | measure | |
$filecount = $num.count | |
$i = 0; | |
ForEach ($file in $filelist) | |
{ | |
$i++; | |
$oldfile = $file.DirectoryName + "\" + $file.BaseName + $file.Extension; | |
$newfile = $file.DirectoryName + "\" + $file.BaseName + ".mp4"; | |
$progress = ($i / $filecount) * 100 | |
$progress = [Math]::Round($progress,2) | |
Clear-Host | |
Write-Host ------------------------------------------------------------------------------- | |
Write-Host Handbrake Batch Encoding | |
Write-Host "Processing - $oldfile" | |
Write-Host "File $i of $filecount - $progress%" | |
Write-Host ------------------------------------------------------------------------------- | |
Start-Process "C:\Program Files\HandBrake\HandBrakeCLI.exe" -ArgumentList "--preset-import-file `"C:\Program Files\HandBrake\plex.json`" -Z `"Plex`" -i `"$oldfile`" -o `"$newfile`" --verbose=0" -Wait -NoNewWindow | |
} |
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
{ | |
"PresetList": [ | |
{ | |
"AudioCopyMask": [ | |
"copy:aac" | |
], | |
"AudioEncoderFallback": "av_aac", | |
"AudioLanguageList": [ | |
"eng", | |
"fin", | |
"und" | |
], | |
"AudioList": [ | |
{ | |
"AudioBitrate": 160, | |
"AudioCompressionLevel": 0.0, | |
"AudioDitherMethod": null, | |
"AudioEncoder": "av_aac", | |
"AudioMixdown": "dpl2", | |
"AudioNormalizeMixLevel": false, | |
"AudioSamplerate": "auto", | |
"AudioTrackQualityEnable": false, | |
"AudioTrackQuality": -1.0, | |
"AudioTrackGainSlider": 0.0, | |
"AudioTrackDRCSlider": 1.0 | |
} | |
], | |
"AudioSecondaryEncoderMode": true, | |
"AudioTrackSelectionBehavior": "first", | |
"ChapterMarkers": false, | |
"ChildrenArray": [], | |
"Default": true, | |
"FileFormat": "av_mp4", | |
"Folder": false, | |
"FolderOpen": false, | |
"Mp4HttpOptimize": false, | |
"Mp4iPodCompatible": false, | |
"PictureAutoCrop": true, | |
"PictureBottomCrop": 0, | |
"PictureLeftCrop": 0, | |
"PictureRightCrop": 0, | |
"PictureTopCrop": 0, | |
"PictureDARWidth": 0, | |
"PictureDeblock": 4, | |
"PictureDeinterlaceFilter": "off", | |
"PictureCombDetectPreset": "off", | |
"PictureCombDetectCustom": null, | |
"PictureDeinterlacePreset": "", | |
"PictureDeinterlaceCustom": "", | |
"PictureDenoiseCustom": "", | |
"PictureDenoiseFilter": "off", | |
"PictureDenoisePreset": "medium", | |
"PictureDenoiseTune": "none", | |
"PictureDetelecine": "off", | |
"PictureDetelecineCustom": "", | |
"PictureItuPAR": false, | |
"PictureKeepRatio": true, | |
"PictureLooseCrop": false, | |
"PictureModulus": 2, | |
"PicturePAR": "auto", | |
"PicturePARWidth": 0, | |
"PicturePARHeight": 0, | |
"PictureRotate": "0:0", | |
"PictureWidth": null, | |
"PictureHeight": null, | |
"PictureForceHeight": 0, | |
"PictureForceWidth": 0, | |
"PresetDescription": null, | |
"PresetName": "Plex", | |
"Type": 1, | |
"UsesPictureFilters": false, | |
"UsesPictureSettings": 2, | |
"SubtitleAddCC": false, | |
"SubtitleAddForeignAudioSearch": false, | |
"SubtitleAddForeignAudioSubtitle": false, | |
"SubtitleBurnBehavior": "none", | |
"SubtitleBurnBDSub": false, | |
"SubtitleBurnDVDSub": false, | |
"SubtitleLanguageList": [ | |
"eng", | |
"fin", | |
"und" | |
], | |
"SubtitleTrackSelectionBehavior": "first", | |
"VideoAvgBitrate": 0, | |
"VideoColorMatrixCode": 0, | |
"VideoEncoder": "x264", | |
"VideoFramerate": "", | |
"VideoFramerateMode": "vfr", | |
"VideoGrayScale": false, | |
"VideoHWDecode": false, | |
"VideoScaler": "swscale", | |
"VideoPreset": "fast", | |
"VideoTune": "", | |
"VideoProfile": "baseline", | |
"VideoLevel": "4.1", | |
"VideoOptionExtra": "", | |
"VideoQualityType": 2, | |
"VideoQualitySlider": 18.0, | |
"VideoQSVDecode": true, | |
"VideoQSVAsyncDepth": 4, | |
"VideoTwoPass": false, | |
"VideoTurboTwoPass": false, | |
"x264Option": "", | |
"x264UseAdvancedOptions": false | |
} | |
], | |
"VersionMajor": "11", | |
"VersionMicro": "0", | |
"VersionMinor": "0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment