diff --git a/README.md b/README.md index 61a24c2..66a8a9e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A PowerShell script to convert videos to the HEVC video format utilizing GPU har The main benefit being that you can save disk space significantly (most of the time). -## Space Saving Examples 💡 +## Space Saving Examples - 2.5GB MP4 to 500MB HEVC MP4 - 3GB MP4 to 800MB HEVC MP4 diff --git a/convert_Videos.ps1 b/convert_Videos.ps1 index 1da794a..5f02219 100644 --- a/convert_Videos.ps1 +++ b/convert_Videos.ps1 @@ -1,37 +1,26 @@ -# Converts videos to HEVC for all paths in "video_file_list.txt" - -# Note: To copy paths in Windows File Explorer -# Hold down the shift key and right click a selection of video files, -# click "Copy as Path" and paste into "video_file_list.txt" and save. +# Converts videos to HEVC for given path: # Ref: https://trac.ffmpeg.org/wiki/Encode/H.265 +# https://github.com/rigaya/NVEnc/releases + +$videoPath = 'M:\1_movies\kids.movies\Alvin und die Chipmunks (1-3)\' -# Start Edits (4 in total) -# Edit 1 of 4 - Set to the path of ffmepg.exe: -$ffmpegEXE = 'Z:\Commands\ffmpeg.exe' -# Edit 2 of 4 - Presets are ultrafast, superfast, veryfast, -# faster, fast, medium, slow, slower, or veryslow: -$preset = 'medium' -# Edit 3 of 4: Video List File: -$videosListFile = "$PSScriptRoot\video_file_list.txt" -# Edit 4 of 4: -# Default 'hevc_nvenc' is for recent nVidia GPU. -# Set it to 'hevc_vaapi' if you are using a recent AMD video card instead. -$hardwareEncoder = 'hevc_nvenc' -# End Edits -# DO NOT EDIT BELOW HERE ================================================== +# HEVC : main, main10, main444 +$profile = 'main10' +$NVEncoder = "$PSScriptRoot\encoder\NVEncC64.exe" $arguments = '' -if(!(Test-Path $ffmpegEXE -PathType leaf)) +if(!(Test-Path $NVEncoder -PathType leaf)) { - Write-Host "ffmpeg.exe not found, please check path in `$ffmpegEXE." -ForegroundColor Yellow + Write-Host "NVEncC64.exe not found, please check path in `"$NVEncoder`"." -ForegroundColor Yellow exit } + # Gets Video List File Contents -$videos = Get-Content -Path $videosListFile +$videos = Get-ChildItem -Path $videoPath -Name -Recurse -Include ('*.avi', '*.mp4', '*.mkv') $videoID = 1 $count = $videos.Count if($videos.Count -lt 1) @@ -44,31 +33,20 @@ Write-Host "Converting $count videos.." -ForegroundColor Cyan foreach($video in $videos) { - # Converts using ffmpeg + # Converts video using NVEncC64 $video = $video.Replace("`"", "") - $inputFile = $video - #$inputFolder = (Get-Item $inputFile).Directory.FullName - $outputFile = $video.Insert(($video.Length - 4), '(HEVC)') - #$outputFolder = $inputFolder - #$inputFile - #$outputFile + $inputFile = $videoPath + $video + $outputFile = $videoPath + $video.Insert(($video.Length - 4), '(HEVC)') Write-Host Write-Host "Converting video ($videoID of $count), please wait.." -ForegroundColor Magenta Write-Host "$video `nto:`n$outputFile" -ForegroundColor White Write-Host - #$outputFilePath = "$outputFolder\$outputFileName" testing: -threads 2 - # hevc_nvenc - # libx265 - $arguments = "-i `"$inputFile`" -hide_banner -y -xerror -threads 2 -c:a copy -c:s copy -c:v $hardwareEncoder " + - "-crf 28 -preset $preset `"$outputFile`"" - #$arguments - #$outputFile - #exit - #$videoID - #Start-Process $ffmpegEXE -ArgumentList $arguments -WindowStyle Minimized -Wait - Start-Process $ffmpegEXE -ArgumentList $arguments -WindowStyle Minimized - $processName = 'ffmpeg' + $arguments = "--input `"$inputFile`" --codec hevc --audio-copy 1,2 --profile $profile --output `"$outputFile`"" + + Start-Process $NVEncoder -ArgumentList $arguments -WindowStyle Minimized + + $processName = 'NVEncC64' Start-Sleep -Seconds 8 # Sets to use 3 cores (always set to one less core that your CPU has) # 2 Cores = 3, 3 Cores = 7, 4 cores = 15, 5 cores = 31, 6 cores = 63 @@ -87,12 +65,18 @@ foreach($video in $videos) # Waits for process to complete $processID = (Get-Process $processName).id Wait-Process -Id $processID - + + if(Test-Path $outputFile) + { + Write-Host "CONVERSION WORKED! FILE: `"$outputFile`" FOUND" -ForegroundColor Yellow + # TODO delete old and Move file name! + } + # Increments video counter $videoID = $videoID + 1 Start-Sleep -Seconds 4 } -Write-Host "Finished converting $count videos." -ForegroundColor Green +Write-Host "Finished converted $count videos." -ForegroundColor Green exit \ No newline at end of file diff --git a/encoder/NVEncC64.exe b/encoder/NVEncC64.exe new file mode 100644 index 0000000..698d7c3 Binary files /dev/null and b/encoder/NVEncC64.exe differ diff --git a/encoder/avcodec-58.dll b/encoder/avcodec-58.dll new file mode 100644 index 0000000..8089214 Binary files /dev/null and b/encoder/avcodec-58.dll differ diff --git a/encoder/avfilter-7.dll b/encoder/avfilter-7.dll new file mode 100644 index 0000000..ed1653e Binary files /dev/null and b/encoder/avfilter-7.dll differ diff --git a/encoder/avformat-58.dll b/encoder/avformat-58.dll new file mode 100644 index 0000000..0278eb0 Binary files /dev/null and b/encoder/avformat-58.dll differ diff --git a/encoder/avutil-56.dll b/encoder/avutil-56.dll new file mode 100644 index 0000000..6b42a8a Binary files /dev/null and b/encoder/avutil-56.dll differ diff --git a/encoder/hdr10plus_gen.exe b/encoder/hdr10plus_gen.exe new file mode 100644 index 0000000..f9b3351 Binary files /dev/null and b/encoder/hdr10plus_gen.exe differ diff --git a/encoder/libass-9.dll b/encoder/libass-9.dll new file mode 100644 index 0000000..f008e0f Binary files /dev/null and b/encoder/libass-9.dll differ diff --git a/encoder/nvrtc-builtins64_101.dll b/encoder/nvrtc-builtins64_101.dll new file mode 100644 index 0000000..305c998 Binary files /dev/null and b/encoder/nvrtc-builtins64_101.dll differ diff --git a/encoder/nvrtc64_101_0.dll b/encoder/nvrtc64_101_0.dll new file mode 100644 index 0000000..be95aaa Binary files /dev/null and b/encoder/nvrtc64_101_0.dll differ diff --git a/encoder/swresample-3.dll b/encoder/swresample-3.dll new file mode 100644 index 0000000..dc8baba Binary files /dev/null and b/encoder/swresample-3.dll differ