param( [Parameter(Mandatory=$true)][string]$InputVideo, [string]$OutputVideo = "", [switch]$UseNvidia ) $ErrorActionPreference = 'Stop' if (!(Test-Path -LiteralPath $InputVideo)) { throw "Input file not found: $InputVideo" } if (!(Get-Command ffmpeg -ErrorAction SilentlyContinue)) { throw 'FFmpeg not found in PATH.' } if (!$OutputVideo) { $dir = Split-Path -Parent (Resolve-Path -LiteralPath $InputVideo).Path $name = [IO.Path]::GetFileNameWithoutExtension($InputVideo) $OutputVideo = Join-Path $dir ($name + '-CareTV-8K60-120Mbps.mp4') } $vf = 'fps=60,scale=5760:4320:flags=lanczos,pad=7680:4320:960:0:black,format=yuv420p10le' if ($UseNvidia) { $videoArgs = @('-c:v','hevc_nvenc','-preset','p5','-rc','vbr','-b:v','120M','-maxrate','140M','-bufsize','240M','-pix_fmt','p010le') } else { $videoArgs = @('-c:v','libx265','-preset','medium','-b:v','120M','-maxrate','140M','-bufsize','240M','-pix_fmt','yuv420p10le') } $argsList = @('-hide_banner','-y','-i',$InputVideo,'-vf',$vf) + $videoArgs + @('-c:a','aac','-b:a','320k','-movflags','+faststart',$OutputVideo) Write-Host "Output: $OutputVideo" & ffmpeg @argsList if ($LASTEXITCODE -ne 0) { throw "FFmpeg failed with exit code $LASTEXITCODE" } Write-Host 'Completed successfully.'