Adding review feature and one sec tolerance

windows-hevc-converter
Michael Reber 4 years ago
parent 852bce9c61
commit f7768b4a68

@ -4,6 +4,7 @@
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# Edit the $videoPath variable to point to your video-files folder: # Edit the $videoPath variable to point to your video-files folder:
#$videoPath = 'M:\1_movies\_main.movies\'
$videoPath = 'M:\2_serien\_main.series\' $videoPath = 'M:\2_serien\_main.series\'
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -12,7 +13,7 @@ $profile = 'main10'
$NVEncoder = "$PSScriptRoot\encoder\NVEncC64.exe" $NVEncoder = "$PSScriptRoot\encoder\NVEncC64.exe"
$fileTester = "$PSScriptRoot\mediainfo.exe" $fileTester = "$PSScriptRoot\mediainfo.exe"
$reviewPlayer = "C:\Program Files\VideoLAN\VLC\vlc.exe"
############################################################################################################# #############################################################################################################
# Testing and conversion preparations # # Testing and conversion preparations #
@ -29,7 +30,7 @@ $videos = Get-ChildItem -LiteralPath $videoPath -Name -Recurse -Include ('*.mp4'
# Instantiating used variables: # Instantiating used variables:
$videoID = 1 $videoID = 1
$convertedVideos = 1 $convertedVideos = 0
$notConvertedVideos = 0 $notConvertedVideos = 0
$failedVideos = 0 $failedVideos = 0
# Square brackets are used as wildcards in Powershell. # Square brackets are used as wildcards in Powershell.
@ -89,7 +90,7 @@ foreach($video in $videos)
} else { } else {
$outputFile = $videoPath + $video.Insert(($video.Length - 4), '-HEVC') $outputFile = $videoPath + $video.Insert(($video.Length - 4), '-HEVC')
} }
Write-Host "Analyzing video ($videoID of $count), starting convertion of number: $convertedVideos please wait.." -ForegroundColor Magenta Write-Host "Analyzing video ($videoID of $count), starting convertion of number: $($convertedVideos + 1) please wait.." -ForegroundColor Magenta
Write-Host "$video `nto:`n$outputFile" -ForegroundColor White Write-Host "$video `nto:`n$outputFile" -ForegroundColor White
Write-Host Write-Host
@ -148,19 +149,31 @@ foreach($video in $videos)
$Logfile = "$PSScriptRoot\logs\$logFolderName\successfully_converted.log" $Logfile = "$PSScriptRoot\logs\$logFolderName\successfully_converted.log"
LogWrite "$outputFile" LogWrite "$outputFile"
} else } else
{ {
# Delete corrupt File! if (($StreamSize_new -eq $($StreamSize_old - 1)) -or ($($StreamSize_new - 1) -eq $StreamSize_old))
Write-Host "Conversion Failded! - Deleting new converted file.." -ForegroundColor Red {
Write-Host # Delete old video File!
Write-Host "------------------------------------------------------------------------------------------------" Write-Host "Conversion Done! - But streamsize is not exactly the same. - Please review!"
Remove-Item -LiteralPath $outputFile Write-Host
$failedVideos = $failedVideos + 1 Write-Host "------------------------------------------------------------------------------------------------"
$notConvertedVideos = $notConvertedVideos + 1 $review = $true
$Logfile = "$PSScriptRoot\logs\$logFolderName\error_during_conversion.log" $convertedVideos = $convertedVideos + 1
LogWrite "$inputFile" $Logfile = "$PSScriptRoot\logs\$logFolderName\review_needed.log"
LogWrite "$inputFile,$outputFile"
} else
{
# Delete corrupt File!
Write-Host "Conversion Failded! - Deleting new converted file.." -ForegroundColor Red
Write-Host
Write-Host "------------------------------------------------------------------------------------------------"
Remove-Item -LiteralPath $outputFile
$failedVideos = $failedVideos + 1
$notConvertedVideos = $notConvertedVideos + 1
$Logfile = "$PSScriptRoot\logs\$logFolderName\error_during_conversion.log"
LogWrite "$inputFile,$StreamSize_new,$StreamSize_old,"
}
} }
} }
#Start-Sleep -Seconds 4
} else } else
{ {
# Alert if video doesn't need conversion: # Alert if video doesn't need conversion:
@ -185,6 +198,49 @@ foreach($video in $videos)
############################################################################################################# #############################################################################################################
# Evaluation part of the conversion script # # Evaluation part of the conversion script #
############################################################################################################# #############################################################################################################
if ($review)
{
Write-Host "There are some files to review.. Starting reviewing first file."
Write-Host
$review_count = 1
foreach($review_pair in Get-Content -LiteralPath "$PSScriptRoot\logs\$logFolderName\review_needed.log")
{
$oldFile,$newFile = $review_pair.split(',')
Write-Host "Playing $review_count converted file: $newFile"
Write-Host
# Starting VLC Player with the file to review
Start-Process $reviewPlayer -ArgumentList `"$newFile`"
Start-Sleep -Seconds 6
# Wait until player is closed.
$processID = (Get-Process "vlc").id
Wait-Process -Id $processID
$msg = 'Do you want to keep the newly converted file and delete the old? (N for deleting NEW-file) [Y/N]'
do {
$response = Read-Host -Prompt $msg
} until (($response -eq 'n') -or ($response -eq 'y'))
if ($response -eq 'y')
{
Write-Host "delete old file, keep newly converted.."
$to_delete = $oldFile
} else
{
Write-Host "delete newly converted, keep old file"
$to_delete = $newFile
$failedVideos = $failedVideos + 1
$convertedVideos = $convertedVideos - 1
}
Write-Host "DELETED: $to_delete" -ForegroundColor Red
#Remove-Item -LiteralPath $to_delete
Write-Host "------------------------------------------------------------------------------------------------"
Start-Sleep -Seconds 2
}
}
Write-Host "Final calculations are in progress.." Write-Host "Final calculations are in progress.."
$folderSizeInGB2 = "{0:N2} GB" -f ((Get-ChildItem $videoPath -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1GB) $folderSizeInGB2 = "{0:N2} GB" -f ((Get-ChildItem $videoPath -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1GB)
if($notConvertedVideos -eq 0) if($notConvertedVideos -eq 0)

Loading…
Cancel
Save