Update README.md and fix some stuff

This commit is contained in:
Michael Reber 2020-03-23 16:45:28 +01:00
parent 9ad464f618
commit 3a33e96bb7
2 changed files with 26 additions and 23 deletions

View File

@ -1,10 +1,12 @@
# FFmpeg-HEVC-Video-Converter 1.0 # Automated HEVC-Video-Converter 1.0
A PowerShell script to convert videos to the HEVC video format utilizing GPU hardware acceleration using FFmpeg for Windows. A PowerShell script to convert videos to the HEVC video format utilizing GPU hardware acceleration using NVEnc for Windows.
The main benefit being that you can save disk space significantly (most of the time). The main benefit being that you can save disk space significantly (most of the time).
![image](/attachments/985e0fa6-ec4a-4ad0-a1c7-d70f59e7a23d)
## Space Saving Examples ## Space Saving Examples
- 2.5GB MP4 to 500MB HEVC MP4 - 2.5GB MP4 to 500MB HEVC MP4
@ -15,26 +17,24 @@ _Results vary and depend on the input video's format, bitrate etc._
## Minimum System Requirements ## Minimum System Requirements
- PC with at least 2 cores - PC with at least 2 cores
- Recent NVidia or AMD graphics card - Recent Nvidia graphics card
- Enough free disk space for resulting video files - Enough free disk space for resulting video files
**VITAL: ALWAYS check the resulting video files, ending with "(HEVC)" for expected length and try them out in a video player checking for quality and smooth playback.**
## Encoding ## Encoding
During encoding (conversion) it is normal for high **CPU** and **GPU** usage. Be sure to only run the script when the PC has no other processes hogging up resources. During encoding (conversion) it is normal for high **CPU** and **GPU** usage. Be sure to only run the script when the PC has no other processes hogging up resources.
The script encodes the files alongside the original with (HEVC) at the end of the filename. The script encodes the files alongside the original with '-HEVC' at the end or inplace x265 replacement of the string in the filename.
After the conversion, a test is performed on the new video file to ensure its integrity.
If this test is successful, the old file will be deleted.
If not, the failed conversion-file is deleted and registered.
## Decoding
The resulting HEVC videos require a more powerful PC to decode and playback, than the original would.
## Script Usage ## Script Usage
1. Download FFmpeg for Windows: https://ffmpeg.zeranoe.com/builds/ (see screenshots below) 1. Clone this Repository to your computer
2. Extract ffmpeg.exe to a known path/folder 2. Download latest NVEnc for Windows: https://github.com/rigaya/NVEnc/releases
3. Download **convert_Videos.ps1** and create **video_file_list.txt** alongside it 3. Extract the files to "video-in-place-hevc-converter\encoder\" and replace the old ones
4. Make 4 edits in **convert_Videos.ps1** using PowerShell ISE 4. Edit the $videoPath variable in the PowerShell file to point to your video-files folder
5. Copy+paste full paths into **video_file_list.txt** and save 5. Run **convert_Videos.ps1** to convert all video Files on the provided path to HEVC.
6. Run **convert_Videos.ps1** to convert to HEVC

View File

@ -1,12 +1,14 @@
# Converts videos to HEVC for given path: # Converts videos to HEVC for given path:
# Ref: https://trac.ffmpeg.org/wiki/Encode/H.265
# https://github.com/rigaya/NVEnc/releases # https://github.com/rigaya/NVEnc/releases
#-----------------------------------------------------------------------
# Edit the $videoPath variable to point to your video-files folder:
$videoPath = 'M:\2_serien\_main.series\Luther\' $videoPath = 'M:\2_serien\_main.series\Luther\'
# HEVC : main, main10, main444 #-----------------------------------------------------------------------
# HEVC profiles: main, main10, main444
$profile = 'main10' $profile = 'main10'
$NVEncoder = "$PSScriptRoot\encoder\NVEncC64.exe" $NVEncoder = "$PSScriptRoot\encoder\NVEncC64.exe"
@ -38,7 +40,7 @@ foreach($video in $videos)
$video = $video.Replace("`"", "") $video = $video.Replace("`"", "")
$inputFile = $videoPath + $video $inputFile = $videoPath + $video
# Get and check File info for codec, if it is already HEVC: - JSON link: (['media']['track'][1]['Format']) # Get and check File info for codec, if it's already HEVC: - JSON query: (['media']['track'][1]['Format'])
$fileDetails = cmd /c $fileTester $inputFile --Output=JSON | ConvertFrom-Json $fileDetails = cmd /c $fileTester $inputFile --Output=JSON | ConvertFrom-Json
$codec = $fileDetails.media.track[1].Format $codec = $fileDetails.media.track[1].Format
#echo $codec #echo $codec
@ -60,7 +62,7 @@ foreach($video in $videos)
$arguments = "--input `"$inputFile`" --codec hevc --audio-copy 1,2 --profile $profile --output `"$outputFile`"" $arguments = "--input `"$inputFile`" --codec hevc --audio-copy 1,2 --profile $profile --output `"$outputFile`""
Start-Process $NVEncoder -ArgumentList $arguments #-WindowStyle Minimized Start-Process $NVEncoder -ArgumentList $arguments -WindowStyle Minimized
$processName = 'NVEncC64' $processName = 'NVEncC64'
Start-Sleep -Seconds 8 Start-Sleep -Seconds 8
@ -88,11 +90,12 @@ foreach($video in $videos)
Write-Host "CONVERSION DONE! FILE: `"$outputFile`" FOUND" -ForegroundColor Yellow Write-Host "CONVERSION DONE! FILE: `"$outputFile`" FOUND" -ForegroundColor Yellow
Start-Sleep -Seconds 4 Start-Sleep -Seconds 4
# Check if File is valid, with Duration of Video - it must be same! (['media']['track'][0]['Duration']): # Check if File is valid; the duration of video must be the same! (['media']['track'][0]['Duration']):
$fileDetails_new = cmd /c $fileTester $outputFile --Output=JSON | ConvertFrom-Json $fileDetails_new = cmd /c $fileTester $outputFile --Output=JSON | ConvertFrom-Json
$StreamSize_old = $fileDetails.media.track[0].Duration # This code gets the duration and splits it in two parts, only the part before the "." is needed:
$StreamSize_new = $fileDetails_new.media.track[0].Duration $StreamSize_old,$notused = $($fileDetails.media.track[0].Duration).split('.')
$StreamSize_new,$notused = $($fileDetails_new.media.track[0].Duration).split('.')
Write-Host Write-Host
Write-Host "Old Duration was: $StreamSize_old `nnew Duration is: $StreamSize_new" -ForegroundColor White Write-Host "Old Duration was: $StreamSize_old `nnew Duration is: $StreamSize_new" -ForegroundColor White
@ -101,7 +104,7 @@ foreach($video in $videos)
if ($StreamSize_new -eq $StreamSize_old) if ($StreamSize_new -eq $StreamSize_old)
{ {
# Delete old video File! # Delete old video File!
Write-Host "Conversion Succesful! - Deleting old file.." Write-Host "Conversion Successful! - Deleting old file.."
Remove-Item -Path $inputFile Remove-Item -Path $inputFile
} else } else
{ {