I need help with a script. These are the variables already included in the start of the coming script:

# Included file types. Add more extensions that you want included with the media scan
$include = ".mp4", ".avi", ".mkv", ".m4v", ".ogg", ".mpeg", ".wmv", ".flv", ".mov", ".ogv", ".mpg", ".m4a", ".asf", ".ts", ".divx"

# Script Variables
[float]$ScriptVersion = 3.6
$fullName = ""
$fileName = ""
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$scanHistory = Join-Path -path $scriptPath -childpath "ScanHistory.txt"
$Date = "$((Get-Date).ToString('yyyy-MM-dd'))"
$LogDir = Join-Path -path $scriptPath -childpath "log"
$LogPath = Join-Path -path $LogDir -childpath "log_$Date"
$ffmpegLog = Join-Path -path $LogPath -childpath "ffmpegerror.log"
$Logfile = Join-Path -path $LogPath -childpath "results.log"
$CSVfile = Join-Path -path $LogPath -childpath "results.csv"
$env:PATH = $env:PATH + ";."
$global:OrigLength = $null
$global:RepairLength = $null
$global:RepairedFile = $null
$global:OriginalFile = $null
$global:OriginalRemoved = $false
$global:CPULimt = 1
$global:VideoLibrary = "h264_qsv"

# Convert all Supplied Parameters to Global variables for use in all functions
$global:Path = $Path
$global:ConfigFile = $ConfigFile
$global:AutoRepair = $AutoRepair
$global:Rescan = $Rescan
$global:CRF = $CRF
$global:LimitCPU = $LimitCPU
$global:RemoveAll = $RemoveAll
$global:RemoveRepaired = $RemoveRepaired
$global:RemoveOriginal = $RemoveOriginal
$global:IAcceptResponsibility = $IAcceptResponsibility
$global:IdleScan = $IdleScan
$global:GPUEncoding = $GPUEncoding
$global:RepairVFileExtension = $Extension
$global:ContinuousScan = $ContinuousScan
$global:TrashEnabled = $TrashEnabled



"$global:VideoLibrary" used to look like this "$global:VideoLibrary = "libx264" but I changed that last part from "x264" to "h264_qsv" so that I could use Intel QSV hardware acceleration. This is a small exempt of the part where I have a problem:


    # Scan the file with FFMPEG
    If ($global:LimitCPU) {
        ffmpeg.exe -v error -hwaccel qsv -hwaccel_device auto -i $fullName -max_muxing_queue_size 1024 -f null -threads $global:CPULimt - >$ffmpegLog 2>&1
    }
    Else {
        ffmpeg.exe -v error -hwaccel qsv -hwaccel_device auto -i $fullName -max_muxing_queue_size 1024 -f null - >$ffmpegLog 2>&1
    }

It didn't have anything between "error" and "-i", but in order to utilize hardware acceleration I added "-hwaccel qsv -hwaccel_device auto ". Now it is much faster than before, but while it works great on files with codec "h264" it gives me errors on files with codec "vc-1". That is because while "x264" is fully supported by Intel QSV, "vc-1" is not.

I want to use ffprobe on the files and figure out if their codec is "h264" or "vc-1" and if it's "h264" I want it to run just like now, using "$global:VideoLibrary = "h264_qsv"" as it is already mentioned in the script, but if it is a "vc-1" file, I want it to use "libx264" and when done go back to using "h264_qsv" for everything else. I already know that "-hwaccel qsv -hwaccel_device auto" will have to go away and it will have to be replaced by "$hwaccelOptions" where it will look like this for x264 files "$hwaccelOptions = "-hwaccel qsv -hwaccel_device auto"" and this for "vc-1" files "$hwaccelOptions = """, but other than that, I'm not sure how to proceed.