Skip to content

Instantly share code, notes, and snippets.

@Wllew4
Last active December 6, 2022 02:04
Show Gist options
  • Save Wllew4/0bca364a69ef3b9f04476643d2b2039f to your computer and use it in GitHub Desktop.
Save Wllew4/0bca364a69ef3b9f04476643d2b2039f to your computer and use it in GitHub Desktop.
Convert all files to h.264 for Plex direct play, eliminate transcoding.
Get-ChildItem -Recurse -File | ForEach-Object {
$tempName = "$($PSItem.Directory)\temp_$($PSItem.Name)"
$realName = $PSItem.FullName
$codec = & ffprobe.exe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 $PSItem
if ($codec -eq "hevc") {
Write-Output "$codec : $PSItem"
& ffmpeg.exe -hwaccel cuda -i $realName -pix_fmt yuv420p -map 0:v:0 -map 0:a? -map 0:s? -c:v h264_nvenc -c:a copy -c:s copy $tempName 2>&1
Remove-Item -LiteralPath $realName
Rename-Item $tempName $realName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment