Last active
September 18, 2020 06:22
-
-
Save OhkuboSGMS/8813ac43ccc1e8c0e8b43c6d2151d5cf to your computer and use it in GitHub Desktop.
ffmpeg resize with cuvid (gpu encode) power shell
This file contains hidden or 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
| Param($searchPath) | |
| if (!$searchPath) { | |
| Write-Warning "Pass Search Directory Path" | |
| exit | |
| } | |
| Get-ChildItem $searchPath | |
| if (![bool] (Get-Command ffmpeg -ErrorAction SilentlyContinue)) { | |
| Write-Output "Not Install ffmpeg" | |
| exit | |
| } | |
| $Resize = "1280:720" | |
| $MP4 = Get-ChildItem -Recurse ($searchPath + "\*.mp4") | Where-Object { $_.BaseName -notlike "*-Resize" } | Select-Object | |
| foreach ($f in $MP4) { | |
| $basename = $f.BaseName | |
| $fullname = $f.FullName | |
| $ext = $f.Extension | |
| $directoryPath = $f.Directory.FullName | |
| $input = $fullname | |
| $output = $directoryPath + "/" + $basename + "-Resize" + $ext | |
| Write-Output ("Input:" + $input ) | |
| Write-Output ("Output:" + $output) | |
| ffmpeg -y -hwaccel cuvid -i $f -c:v hevc_nvenc -vf scale_cuda=$Resize -f mp4 $output | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C#と大体同じ感じで書けていいですね
ls(Get-ChildItem)でオブジェクトが返ってくるので修正しやすい,Select,WhereとかはLINQ指向で慣れれば大体使えそう