• AnyStream is having some DRM issues currently, Netflix is not available in HD for the time being.
    Situations like this will always happen with AnyStream: streaming providers are continuously improving their countermeasures while we try to catch up, it's an ongoing cat-and-mouse game. Please be patient and don't flood our support or forum with requests, we are working on it 24/7 to get it resolved. Thank you.

Guide Proof of Concept: Exploring "Fast and Furious" Video Upscaling with FFmpeg & The False Claim of 1080p with 5.1 Sound by Some Tools

tectpro

Translator (ms_MY)
Thread Starter
Joined
Feb 27, 2011
Messages
1,418
Likes
951
Introduction:

I have been conducting extensive research on video encoding, particularly focusing on hardware-accelerated processes.
One of my most interesting findings challenges the misconception that rapid upscaling is impossible.
I've also done this proof of concept as some tools falsely claim to offer 1080p quality and 5.1 sound when they don't deliver these results.
This research aims to expose these misleading claims and demonstrate how this upscaling and audio upsampling can be achieved quickly.

During my research, I experimented with the rapid upscaling of SD (standard definition) MP4 videos to 1080p resolution using various GPU types.

I want to mention that the script was initially written for FFmpeg 6.
However, users of FFmpeg 7 may notice differences, particularly with Intel acceleration, where the CRF option seems no longer included.
Intel and Nvidia produce better quality outputs than AMD, which performs somewhat lower in quality.


Script Execution:

Please note that the script for upscaling will be provided further down in this post.
To use it, copy the provided script into a new text file, rename it (e.g., upscale.ps1), and save it in the folder containing your MP4 files.
Run the script from that folder to begin the upscaling process.

Important Note:

This script is a proof of concept with no further updates or improvements. As such, any feedback or observations you have are greatly appreciated.


Here's the script itself:

Code:
# Set ffmpeg executable path
$ffmpegPath =  "X:\FFmpeg\ffmpeg.exe"

# Get all MP4 files in the current directory
$videoFiles = Get-ChildItem -Path . -Filter *.mp4

# Prompt user for hardware acceleration type
Write-Host "Select the type of GPU for hardware acceleration:"
Write-Host "1. AMD (uses hevc_amf)"
Write-Host "2. Intel (uses hevc_qsv)"
Write-Host "3. NVIDIA (uses hevc_nvenc)"

$gpuSelection = Read-Host "Enter the number corresponding to your GPU type"

# Encoding based on GPU selection
switch ($gpuSelection) {
    "1" {
        # AMD Encoding with HEVC and CRF 21
        foreach ($video in $videoFiles) {
            $inputPath = $video.FullName
            $outputPath = $video.DirectoryName + "\" + $video.BaseName + "_resized.mp4"

            try {
                $ffmpegCommand = "$ffmpegPath -i `"$inputPath`" -vf scale=-1:1080 -c:v hevc_amf -crf 21 -c:a copy -c:s copy `"$outputPath`""
                Invoke-Expression $ffmpegCommand
                Write-Host "AMD Encoding completed: $outputPath"
            } catch {
                Write-Host "Error during AMD encoding."
                Write-Host "Error message: $($_.Exception.Message)"
            }
        }
    }
    "2" {
        # Intel Encoding with HEVC and CRF 21
        foreach ($video in $videoFiles) {
            $inputPath = $video.FullName
            $outputPath = $video.DirectoryName + "\" + $video.BaseName + "_resized.mp4"

            try {
                $ffmpegCommand = "$ffmpegPath -i `"$inputPath`" -vf scale=-1:1080 -c:v hevc_qsv -crf 21 -c:a copy -c:s copy `"$outputPath`""
                Invoke-Expression $ffmpegCommand
                Write-Host "Intel Encoding completed: $outputPath"
            } catch {
                Write-Host "Error during Intel encoding."
                Write-Host "Error message: $($_.Exception.Message)"
            }
        }
    }
    "3" {
        # NVIDIA Encoding with HEVC and CRF 21
        foreach ($video in $videoFiles) {
            $inputPath = $video.FullName
            $outputPath = $video.DirectoryName + "\" + $video.BaseName + "_resized.mp4"

            try {
                $ffmpegCommand = "$ffmpegPath -i `"$inputPath`" -vf scale=-1:1080 -c:v hevc_nvenc -crf 21 -c:a copy -c:s copy `"$outputPath`""
                Invoke-Expression $ffmpegCommand
                Write-Host "NVIDIA Encoding completed: $outputPath"
            } catch {
                Write-Host "Error during NVIDIA encoding."
                Write-Host "Error message: $($_.Exception.Message)"
            }
        }
    }
    default {
        Write-Host "Invalid selection."
    }
}

# Indicate completion and wait for user input to exit
Write-Host "All encoding processes are completed."
Write-Host "Press 'Enter' to exit."
Read-Host ""

Before Using the Script:

Before running the provided script, ensure that the FFmpeg executable path is correctly set.
Locate the line that begins with $ffmpegPath and update the path to reflect the location of your FFmpeg executable file on your system.

For example:
Code:
# Set ffmpeg executable path
$ffmpegPath = "X:\FFmpeg\ffmpeg.exe"


Script Overview:

The provided script is designed to facilitate the rapid upscaling of SD (standard definition) MP4 videos to 1080p resolution using hardware-accelerated encoding via FFmpeg.
It prompts the user to select the type of GPU for hardware acceleration (AMD, Intel, or NVIDIA) and performs the encoding accordingly.

Here's a brief overview of what each GPU option entails:

  1. AMD: Utilizes the hevc_amf codec for encoding with a constant rate factor (CRF) of 21.
  2. Intel: Utilizes the hevc_qsv codec for encoding with a CRF of 21. Note that the AC CRF option may not be included in FFmpeg 7 for Intel.
  3. NVIDIA: Utilizes the hevc_nvenc codec for encoding with a CRF of 21.
After selecting the GPU type, the script processes all MP4 files in the current directory, upscaling them to 1080p resolution and saving the resized versions with "_resized" appended to the filenames.

Feel free to further adjust or expand upon this as needed!
 
How does the quality compare to your other guide?

 
How does the quality compare to your other guide?

It's really only fast upscaling.
If the input is ok the output is ok as well.

It is not as sophisticated as the other guide as this only serves as a proof of concept. You won't get the same quality/compression as with the other guide.

Use a Netflix or Disney episode for example to test the script.
 

Introduction:​

In my ongoing research into video encoding and hardware-accelerated processes, I've uncovered significant insights into audio upsampling.
This challenges the assumption that expanding stereo (2-channel) audio to 5.1 surround sound is complicated and time-consuming.
Some tools claim to provide 5.1 surround sound but fail to meet expectations, leading to false advertising.

My proof of concept demonstrates that audio upsampling from stereo to 5.1 surround sound can be done quickly with the right approach.
This research aims to expose these misleading claims.

Script Execution:​

The following script is designed to upsample stereo audio in MP4 files to 5.1 surround sound with EAC3 encoding, using a constant bit rate of 640 kbps.
To use it, copy the script into a text file, rename it (e.g., audio-upsample.ps1), and save it in the folder containing your MP4 files.
Execute the script to begin the audio upsampling process.

Important Note:

This script is proof of concept; no further updates or improvements are planned. I welcome any feedback or observations.

Here's the script itself:

Code:
# Path to ffmpeg executable
$ffmpegPath = 'X:\FFmpeg\ffmpeg.exe'

# Get all MP4 files in the current directory
$mp4Files = Get-ChildItem -Path . -Filter *.mp4

# Color output for visibility
$host.UI.RawUI.ForegroundColor = 'Yellow'
Write-Host "Checking for MP4 files in the current directory..."

# Convert each MP4 file's audio to EAC3 with a constant bit rate of 640 kbps and 6 channels
foreach ($mp4File in $mp4Files) {
    $outputFile = "converted_$($mp4File.BaseName).mp4"
 
    Write-Host "Processing file: $($mp4File.Name)" -ForegroundColor 'Green'
 
    # Command to convert the audio to EAC3 with 640 kbps and 6 channels
    & $ffmpegPath -y -hide_banner -i $mp4File.FullName -c:v copy -c:a eac3 -b:a 640k -ac 6 $outputFile
}

# End script with a visible prompt for exit
Write-Host "Processing complete. Press Enter to exit..." -ForegroundColor 'Cyan'
Read-Host | Out-Null


Before Using the Script:

Before running the provided script, ensure that the FFmpeg executable path is correctly set.
Locate the line that begins with $ffmpegPath and update the path to reflect the location of your FFmpeg executable file on your system.

For example:
Code:
# Set ffmpeg executable path
$ffmpegPath = "X:\FFmpeg\ffmpeg.exe"


What This Script Does:​

This PowerShell script is designed to upsample stereo (2-channel) audio in MP4 files to 5.1 surround sound using EAC3 encoding with a constant bit rate of 640 kbps. It identifies all MP4 files in the directory where they are executed and processes each one to ensure the audio is converted to 6 channels.

How It Works:​

  • Identify MP4 Files: The script checks for all MP4 files in the current directory.
  • Audio Conversion: For each MP4 file, FFmpeg converts the audio to EAC3 with a constant bit rate of 640 kbps and 6 channels. If the input audio is stereo, it upscales to 6 channels; if it's already 6, it keeps the same layout.
  • Output Naming: The script creates a new MP4 file with the same video content but with the converted audio. The output files are named based on the original filename, prefixed with "converted_".
  • User-Friendly Display: To improve readability, the script includes colour-coded messages to indicate its progress and avoids showing FFmpeg's header information for a cleaner output.

Important Notes:​

  • Execution Policy: You may need to adjust your PowerShell execution policy to run scripts. Use Set-ExecutionPolicy Bypass -Scope Process to allow script execution during your PowerShell session.
  • Proof of Concept: This script is a proof of concept and might not cover all scenarios or edge cases. It's intended to demonstrate that audio upsampling can be done quickly.

How to Use the Script:​

  • Copy the script's code into a new text file and save it with a .ps1 extension.
  • Place the script in the same folder as your MP4 files.
  • Open PowerShell, navigate the folder and run the script using .\<script_name>.ps1.
  • Follow the on-screen instructions and wait for the processing to complete.
  • The output files will be in the same folder, prefixed with "converted_".
 
Introduction:

I have been conducting extensive research on video encoding, particularly focusing on hardware-accelerated processes.
One of my most interesting findings challenges the misconception that rapid upscaling is impossible.
I've also done this proof of concept as some tools falsely claim to offer 1080p quality and 5.1 sound when they don't deliver these results.
This research aims to expose these misleading claims and demonstrate how this upscaling and audio upsampling can be achieved quickly.

During my research, I experimented with the rapid upscaling of SD (standard definition) MP4 videos to 1080p resolution using various GPU types.

I want to mention that the script was initially written for FFmpeg 6.
However, users of FFmpeg 7 may notice differences, particularly with Intel acceleration, where the CRF option seems no longer included.
Intel and Nvidia produce better quality outputs than AMD, which performs somewhat lower in quality.


Script Execution:

Please note that the script for upscaling will be provided further down in this post.
To use it, copy the provided script into a new text file, rename it (e.g., upscale.ps1), and save it in the folder containing your MP4 files.
Run the script from that folder to begin the upscaling process.

Important Note:

This script is a proof of concept with no further updates or improvements. As such, any feedback or observations you have are greatly appreciated.


Here's the script itself:

Code:
# Set ffmpeg executable path
$ffmpegPath =  "X:\FFmpeg\ffmpeg.exe"

# Get all MP4 files in the current directory
$videoFiles = Get-ChildItem -Path . -Filter *.mp4

# Prompt user for hardware acceleration type
Write-Host "Select the type of GPU for hardware acceleration:"
Write-Host "1. AMD (uses hevc_amf)"
Write-Host "2. Intel (uses hevc_qsv)"
Write-Host "3. NVIDIA (uses hevc_nvenc)"

$gpuSelection = Read-Host "Enter the number corresponding to your GPU type"

# Encoding based on GPU selection
switch ($gpuSelection) {
    "1" {
        # AMD Encoding with HEVC and CRF 21
        foreach ($video in $videoFiles) {
            $inputPath = $video.FullName
            $outputPath = $video.DirectoryName + "\" + $video.BaseName + "_resized.mp4"

            try {
                $ffmpegCommand = "$ffmpegPath -i `"$inputPath`" -vf scale=-1:1080 -c:v hevc_amf -crf 21 -c:a copy -c:s copy `"$outputPath`""
                Invoke-Expression $ffmpegCommand
                Write-Host "AMD Encoding completed: $outputPath"
            } catch {
                Write-Host "Error during AMD encoding."
                Write-Host "Error message: $($_.Exception.Message)"
            }
        }
    }
    "2" {
        # Intel Encoding with HEVC and CRF 21
        foreach ($video in $videoFiles) {
            $inputPath = $video.FullName
            $outputPath = $video.DirectoryName + "\" + $video.BaseName + "_resized.mp4"

            try {
                $ffmpegCommand = "$ffmpegPath -i `"$inputPath`" -vf scale=-1:1080 -c:v hevc_qsv -crf 21 -c:a copy -c:s copy `"$outputPath`""
                Invoke-Expression $ffmpegCommand
                Write-Host "Intel Encoding completed: $outputPath"
            } catch {
                Write-Host "Error during Intel encoding."
                Write-Host "Error message: $($_.Exception.Message)"
            }
        }
    }
    "3" {
        # NVIDIA Encoding with HEVC and CRF 21
        foreach ($video in $videoFiles) {
            $inputPath = $video.FullName
            $outputPath = $video.DirectoryName + "\" + $video.BaseName + "_resized.mp4"

            try {
                $ffmpegCommand = "$ffmpegPath -i `"$inputPath`" -vf scale=-1:1080 -c:v hevc_nvenc -crf 21 -c:a copy -c:s copy `"$outputPath`""
                Invoke-Expression $ffmpegCommand
                Write-Host "NVIDIA Encoding completed: $outputPath"
            } catch {
                Write-Host "Error during NVIDIA encoding."
                Write-Host "Error message: $($_.Exception.Message)"
            }
        }
    }
    default {
        Write-Host "Invalid selection."
    }
}

# Indicate completion and wait for user input to exit
Write-Host "All encoding processes are completed."
Write-Host "Press 'Enter' to exit."
Read-Host ""

Before Using the Script:

Before running the provided script, ensure that the FFmpeg executable path is correctly set.
Locate the line that begins with $ffmpegPath and update the path to reflect the location of your FFmpeg executable file on your system.

For example:
Code:
# Set ffmpeg executable path
$ffmpegPath = "X:\FFmpeg\ffmpeg.exe"


Script Overview:

The provided script is designed to facilitate the rapid upscaling of SD (standard definition) MP4 videos to 1080p resolution using hardware-accelerated encoding via FFmpeg.
It prompts the user to select the type of GPU for hardware acceleration (AMD, Intel, or NVIDIA) and performs the encoding accordingly.

Here's a brief overview of what each GPU option entails:

  1. AMD: Utilizes the hevc_amf codec for encoding with a constant rate factor (CRF) of 21.
  2. Intel: Utilizes the hevc_qsv codec for encoding with a CRF of 21. Note that the AC CRF option may not be included in FFmpeg 7 for Intel.
  3. NVIDIA: Utilizes the hevc_nvenc codec for encoding with a CRF of 21.
After selecting the GPU type, the script processes all MP4 files in the current directory, upscaling them to 1080p resolution and saving the resized versions with "_resized" appended to the filenames.

Feel free to further adjust or expand upon this as needed!
I had to use the path
$ffmpegPath = "X:\FFmpeg\bin\ffmpeg.exe" for the script to work. The original audio sounded louder then the 5.1 audio.
 
Last edited:
I had to use the path
$ffmpegPath = "X:\FFmpeg\bin\ffmpeg.exe" for the script to work. The original audio sounded louder then the 5.1 audio.
Yes, the path depends on where your FFmpeg is located.

This is a Proof Of Concept to showcase that it is possible to upsample audio that never was 5.1 in the first place.

I didn't include any adjustment/correction for loudness as it was intented to showcase the "false claims" made by some "tools".
 
Yes, the path depends on where your FFmpeg is located.

This is a Proof Of Concept to showcase that it is possible to upsample audio that never was 5.1 in the first place.

I didn't include any adjustment/correction for loudness as it was intented to showcase the "false claims" made by some "tools".
The method that you showcased using Rigaya/NVEnc works much better for video and audio. Thanks for the information @tectpro.
 
Back
Top