Skip to content

Instantly share code, notes, and snippets.

@mrcodetastic
Last active March 2, 2019 20:06
Show Gist options
  • Save mrcodetastic/502eb5ac350751d66e8270cc6d019529 to your computer and use it in GitHub Desktop.
Save mrcodetastic/502eb5ac350751d66e8270cc6d019529 to your computer and use it in GitHub Desktop.
Windows Powershell to recurse through all directories and transcode into HEVC x265 with FFMPEG
# Search through directories for videos and compress t x265 Codec (append x265 to the original file name and possibly rename old file with .orig) also convert sound to aac as well
# Create a new file, exclude any existing x265 filename appended files and don't convert WhatsApp videos already compressed or copied from phone (VID*)
# Change 'D:\Temp\ffmpeg' to the path where your FFMPEG executable is
Get-ChildItem -Recurse -File -Exclude VID-*,*x265* -Include *.mp4,*.mov,*.avi | Foreach {
$newname = $_.fullname.subString(0, $_.fullname.Length-4) + "_x265.mp4";
#$oldname = "$($_.basename).orig$($_.extension)";
D:\Temp\ffmpeg -i $_.fullname -c:v libx265 -preset slow -crf 23 -c:a aac -b:a 128k -y $newname;
echo "Saving as: $($newname)";
#echo "Renaming original file: $($_.fullname) as $($oldname)";
#rename-item -path $_.fullname -newname "$($_.basename).orig$($_.extension)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment