Rebuild script with NVEnc for faster transcoding
This commit is contained in:
parent
c95c1f38e0
commit
3d5061d936
@ -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
|
||||
|
@ -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
|
||||
|
||||
# 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
|
||||
$videoPath = 'M:\1_movies\kids.movies\Alvin und die Chipmunks (1-3)\'
|
||||
|
||||
# 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
|
||||
@ -88,11 +66,17 @@ foreach($video in $videos)
|
||||
$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
|
BIN
encoder/NVEncC64.exe
Normal file
BIN
encoder/NVEncC64.exe
Normal file
Binary file not shown.
BIN
encoder/avcodec-58.dll
Normal file
BIN
encoder/avcodec-58.dll
Normal file
Binary file not shown.
BIN
encoder/avfilter-7.dll
Normal file
BIN
encoder/avfilter-7.dll
Normal file
Binary file not shown.
BIN
encoder/avformat-58.dll
Normal file
BIN
encoder/avformat-58.dll
Normal file
Binary file not shown.
BIN
encoder/avutil-56.dll
Normal file
BIN
encoder/avutil-56.dll
Normal file
Binary file not shown.
BIN
encoder/hdr10plus_gen.exe
Normal file
BIN
encoder/hdr10plus_gen.exe
Normal file
Binary file not shown.
BIN
encoder/libass-9.dll
Normal file
BIN
encoder/libass-9.dll
Normal file
Binary file not shown.
BIN
encoder/nvrtc-builtins64_101.dll
Normal file
BIN
encoder/nvrtc-builtins64_101.dll
Normal file
Binary file not shown.
BIN
encoder/nvrtc64_101_0.dll
Normal file
BIN
encoder/nvrtc64_101_0.dll
Normal file
Binary file not shown.
BIN
encoder/swresample-3.dll
Normal file
BIN
encoder/swresample-3.dll
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user