@ -4,7 +4,7 @@
#-----------------------------------------------------------------------
# Edit the $videoPath variable to point to your video-files folder:
$videoPath = 'M:\ 2_serien\_main.series\Luther \'
$videoPath = 'M:\ 1_movies\kids.movies \'
#-----------------------------------------------------------------------
@ -21,8 +21,9 @@ if(!(Test-Path $NVEncoder -PathType leaf))
}
# Get video list from provided path:
$videos = Get-ChildItem -Path $videoPath -Name -Recurse -Include ( '*.avi' , '*.mp4' , '*.mkv' )
$videoID = 0
$videos = Get-ChildItem -Path $videoPath -Name -Recurse -Include ( '*.mp4' , '*.mkv' ) #('*.avi', '*.mp4', '*.mkv') - avi current doesn't work.
$videoID = 1
$convertedVideos = 0
$notConvertedVideos = 0
$failedVideos = 0
$count = $videos . Count
@ -33,6 +34,9 @@ if($videos.Count -lt 1)
}
Write-Host " Found $count videos. - starting converter.. " -ForegroundColor Cyan
Write-Host
Write-Host
Write-Host " ------------------------------------------------------------------------------------------------ "
foreach ( $video in $videos )
{
@ -55,11 +59,11 @@ foreach($video in $videos)
} else {
$outputFile = $videoPath + $video . Insert ( ( $video . Length - 4 ) , '-HEVC' )
}
Write-Host
Write-Host " Converting video ( $videoID of $count ), please wait.. " -ForegroundColor Magenta
Write-Host " Analyzing video ( $videoID of $count ), starting convertion of number: $convertedVideos please wait.. " -ForegroundColor Magenta
Write-Host " $video `n to: `n $outputFile " -ForegroundColor White
Write-Host
# If the Subtitles should also copied, add "--sub-copy 1,2" behind the --audio-copy argument.
$arguments = " --input `" $inputFile `" --codec hevc --audio-copy 1,2 --profile $profile --output `" $outputFile `" "
Start-Process $NVEncoder -ArgumentList $arguments -WindowStyle Minimized
@ -105,42 +109,49 @@ foreach($video in $videos)
{
# Delete old video File!
Write-Host " Conversion Successful! - Deleting old file.. "
Write-Host
Write-Host " ------------------------------------------------------------------------------------------------ "
Remove-Item -Path $inputFile
$convertedVideos = $convertedVideos + 1
} else
{
# Delete corrupt File!
Write-Host " Conversion Failded! - Deleting new converted file.. "
Write-Host " Conversion Failded! - Deleting new converted file.. " -ForegroundColor Red
Write-Host
Write-Host " ------------------------------------------------------------------------------------------------ "
Remove-Item -Path $outputFile
$failedVideos = $failedVideos + 1
$notConvertedVideos = $notConvertedVideos + 1
$videoID = $videoID - 1
}
}
# Increments video counter:
$videoID = $videoID + 1
Start-Sleep -Seconds 4
} else
{
# Alert if video doesn't need conversion:
Write-Host " Analyzing video ( $videoID of $count ) - skip " -ForegroundColor Magenta
Write-Host " $video is already in correct format! " -ForegroundColor Green
Write-Host
Write-Host " ------------------------------------------------------------------------------------------------ "
# Increments not converted video counter:
$notConvertedVideos = $notConvertedVideos + 1
Start-Sleep -Seconds 4
}
# Increments video counter:
$videoID = $videoID + 1
}
# If confersion is done:
if ( $notConvertedVideos -eq 0 )
{
Write-Host " Finished converted $ videoID out of $count videos. " -ForegroundColor Green
Write-Host " Finished converted $ convertedVideos out of $count videos. " -ForegroundColor Green
} else
{
if ( $failedVideos -eq 0 )
{
Write-Host " Finished converted $ videoID out of $count videos. - $notConvertedVideos where not converted because of already correct codec! " -ForegroundColor Green
Write-Host " Finished converted $ convertedVideos out of $count videos. - $notConvertedVideos where not converted because of already correct codec! " -ForegroundColor Green
} else
{
Write-Host " Finished converted $ videoID out of $count videos. - $notConvertedVideos where not converted because error or already correct codec!! " -ForegroundColor Green
Write-Host " Finished converted $ convertedVideos out of $count videos. - $notConvertedVideos where not converted because error or already correct codec!! " -ForegroundColor Green
Write-Host " $failedVideos have failed! " -ForegroundColor Red
}