Self-hosted multi-platform broadcast newsroom for activist collectives: publishing pipeline with group approval and DST-proof scheduling, TweetDeck-style column wall with hostile-content-safe rendering, live control room with Auto Director, bridged chat governance with polls and quorum, distributed sandboxed transcode workers, encrypted content-addressed archive, monthly analytics. MIT licensed. See README.md and docs/.
42 lines
2.7 KiB
PowerShell
42 lines
2.7 KiB
PowerShell
param([string]$Root='C:\pt-worker', [int]$Device=0)
|
|
$ErrorActionPreference='Stop'
|
|
$ProgressPreference='SilentlyContinue'
|
|
$ffmpeg=Join-Path $Root 'bin\ffmpeg.exe'
|
|
$state=Join-Path $Root 'state'
|
|
New-Item -ItemType Directory -Force $state,(Join-Path $Root 'tmp') | Out-Null
|
|
$gpu=& nvidia-smi.exe -i $Device --query-gpu=name,uuid,driver_version --format=csv,noheader,nounits
|
|
if($LASTEXITCODE){throw 'nvidia-smi identity failed'}
|
|
$identity=$gpu -split ',\s*'
|
|
$boot=(Get-CimInstance Win32_OperatingSystem).LastBootUpTime.ToUniversalTime().ToString('o')
|
|
$proof=[ordered]@{tested_at=[DateTimeOffset]::UtcNow.ToUnixTimeSeconds();boot_id=$boot;driver_version=$identity[2];gpu_model=$identity[0];gpu_uuid=$identity[1];device=$Device;nvenc_h264_ok=$false;nvenc_hevc_ok=$false;av1_encode_ok=$false;av1_decode_ok=$null;tests=@()}
|
|
foreach($codec in @('h264','hevc')){
|
|
$out=Join-Path $Root "tmp\selftest-$codec.mp4"
|
|
$err=Join-Path $state "selftest-$codec.stderr"
|
|
$stdout=Join-Path $state "selftest-$codec.stdout"
|
|
$argv=@('-hide_banner','-nostdin','-y','-re','-f','lavfi','-i','testsrc2=size=1920x1080:rate=30','-t','5','-an','-c:v',"${codec}_nvenc",'-gpu',"$Device",'-preset','p4','-pix_fmt','yuv420p',$out)
|
|
$start=Get-Date
|
|
$p=Start-Process $ffmpeg -ArgumentList $argv -PassThru -NoNewWindow -RedirectStandardError $err -RedirectStandardOutput $stdout
|
|
$null=$p.Handle
|
|
$samples=@(); $sessions=@()
|
|
while(!( $p.HasExited ) -and ((Get-Date)-$start).TotalSeconds -lt 30){
|
|
$value=& nvidia-smi.exe -i $Device --query-gpu=utilization.encoder,encoder.stats.sessionCount,encoder.stats.averageFps --format=csv,noheader,nounits
|
|
if($LASTEXITCODE -eq 0){
|
|
$cells=$value -split ',\s*'
|
|
$n=0.0
|
|
if([double]::TryParse($cells[0],[ref]$n)){$samples+=$n}
|
|
if($cells.Count -ge 3){$sessions+=@{count=$cells[1];fps=$cells[2]}}
|
|
}
|
|
Start-Sleep -Milliseconds 200
|
|
$p.Refresh()
|
|
}
|
|
if(!$p.HasExited){$p.Kill();throw 'NVENC self-test exceeded 30 second deadline'}
|
|
$p.WaitForExit()
|
|
$max=if($samples.Count){($samples | Measure-Object -Maximum).Maximum}else{$null}
|
|
$ok=$p.ExitCode -eq 0 -and $null -ne $max -and $max -gt 0
|
|
$proof["nvenc_${codec}_ok"]=$ok
|
|
$proof.tests+=@{codec=$codec;encoder="${codec}_nvenc";width=1920;height=1080;duration=5;exit_code=$p.ExitCode;seconds=((Get-Date)-$start).TotalSeconds;encoder_util_max=$max;encoder_util_samples=$samples;encoder_stats=$sessions;stderr_file=$err}
|
|
if(!$ok){$proof.failure=if($p.ExitCode -ne 0){Get-Content $err -Raw}else{'No positive NVIDIA encoder utilization: hardware proof refused'};break}
|
|
}
|
|
$proof | ConvertTo-Json -Depth 8 | Set-Content (Join-Path $state 'nvenc.json') -Encoding UTF8
|
|
$proof | ConvertTo-Json -Depth 8
|
|
if(!$proof.nvenc_h264_ok -or !$proof.nvenc_hevc_ok){exit 78}
|