Mux Raven display and loopback transport
This commit is contained in:
parent
fe101a579a
commit
2028f0f805
8 changed files with 199 additions and 34 deletions
69
scripts/start-raven-av-demux.ps1
Normal file
69
scripts/start-raven-av-demux.ps1
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
param(
|
||||
[int]$InputPort = 5200,
|
||||
[int]$VideoPort = 5210,
|
||||
[int]$AudioPort = 5212,
|
||||
[int]$AudioSampleRate = 48000,
|
||||
[int]$AudioChannels = 2,
|
||||
[string]$FfmpegPath = "ffmpeg",
|
||||
[string]$LogRoot = "E:\Projects\Mimir\artifacts\runtime\stream-proof",
|
||||
[switch]$DryRun
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $LogRoot | Out-Null
|
||||
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
$stdoutLog = Join-Path $LogRoot "raven-av-demux-$timestamp.out.log"
|
||||
$stderrLog = Join-Path $LogRoot "raven-av-demux-$timestamp.err.log"
|
||||
$inputEndpoint = "srt://0.0.0.0:${InputPort}?mode=listener&latency=120000&timeout=5000000"
|
||||
$videoEndpoint = "srt://127.0.0.1:${VideoPort}?mode=caller&latency=20000"
|
||||
$audioEndpoint = "srt://127.0.0.1:${AudioPort}?mode=caller&latency=20000"
|
||||
|
||||
$arguments = @(
|
||||
"-hide_banner",
|
||||
"-nostdin",
|
||||
"-loglevel", "warning",
|
||||
"-fflags", "nobuffer",
|
||||
"-flags", "low_delay",
|
||||
"-i", $inputEndpoint,
|
||||
"-map", "0:v:0",
|
||||
"-an",
|
||||
"-c:v", "copy",
|
||||
"-f", "mpegts",
|
||||
$videoEndpoint,
|
||||
"-map", "0:a:0",
|
||||
"-vn",
|
||||
"-acodec", "pcm_f32le",
|
||||
"-ar", $AudioSampleRate.ToString(),
|
||||
"-ac", $AudioChannels.ToString(),
|
||||
"-f", "f32le",
|
||||
$audioEndpoint
|
||||
)
|
||||
|
||||
Write-Host "Raven muxed A/V demux:"
|
||||
Write-Host " input: $inputEndpoint"
|
||||
Write-Host " video: $videoEndpoint"
|
||||
Write-Host " audio: $audioEndpoint"
|
||||
Write-Host " stdout: $stdoutLog"
|
||||
Write-Host " stderr: $stderrLog"
|
||||
|
||||
if ($DryRun) {
|
||||
Write-Host ($FfmpegPath + " " + ($arguments -join " "))
|
||||
exit 0
|
||||
}
|
||||
|
||||
Get-CimInstance Win32_Process |
|
||||
Where-Object { $_.ProcessName -like "ffmpeg*" -and $_.CommandLine -match [regex]::Escape($inputEndpoint) } |
|
||||
ForEach-Object {
|
||||
try { Stop-Process -Id $_.ProcessId -Force -ErrorAction Stop } catch {}
|
||||
}
|
||||
|
||||
$process = Start-Process `
|
||||
-FilePath $FfmpegPath `
|
||||
-ArgumentList $arguments `
|
||||
-WindowStyle Hidden `
|
||||
-RedirectStandardOutput $stdoutLog `
|
||||
-RedirectStandardError $stderrLog `
|
||||
-PassThru
|
||||
|
||||
Write-Host "Started Raven muxed A/V demux pid=$($process.Id)"
|
||||
81
scripts/start-raven-av-sender.ps1
Normal file
81
scripts/start-raven-av-sender.ps1
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
param(
|
||||
[string]$TargetHost = "192.168.1.66",
|
||||
[int]$Port = 5200,
|
||||
[int]$Width = 1920,
|
||||
[int]$Height = 1080,
|
||||
[int]$Framerate = 30,
|
||||
[int]$AudioSampleRate = 48000,
|
||||
[int]$AudioChannels = 2,
|
||||
[string]$FfmpegPath = "ffmpeg",
|
||||
[string]$Source = "desktop",
|
||||
[string]$VideoBitrate = "12000k",
|
||||
[string]$AudioBitrate = "192k",
|
||||
[string]$LogRoot = "C:\Meta\Mimir\logs",
|
||||
[switch]$DryRun
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $LogRoot | Out-Null
|
||||
$repo = Split-Path -Parent $PSScriptRoot
|
||||
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
$stdoutLog = Join-Path $LogRoot "raven-av-srt-$timestamp.out.log"
|
||||
$stderrLog = Join-Path $LogRoot "raven-av-srt-$timestamp.err.log"
|
||||
$endpoint = "srt://${TargetHost}:${Port}?mode=caller&latency=120000"
|
||||
$videoSize = "${Width}x${Height}"
|
||||
$gop = [Math]::Max(1, $Framerate * 2)
|
||||
$captureScript = Join-Path $repo "scripts\wasapi-loopback-capture.ps1"
|
||||
|
||||
$ffmpegArgs = @(
|
||||
"-hide_banner",
|
||||
"-loglevel", "warning",
|
||||
"-thread_queue_size", "1024",
|
||||
"-f", "gdigrab",
|
||||
"-framerate", $Framerate.ToString(),
|
||||
"-video_size", $videoSize,
|
||||
"-i", $Source,
|
||||
"-thread_queue_size", "1024",
|
||||
"-f", "f32le",
|
||||
"-ar", $AudioSampleRate.ToString(),
|
||||
"-ac", $AudioChannels.ToString(),
|
||||
"-i", "pipe:0",
|
||||
"-map", "0:v:0",
|
||||
"-map", "1:a:0",
|
||||
"-c:v", "h264_nvenc",
|
||||
"-preset", "p4",
|
||||
"-tune", "ll",
|
||||
"-b:v", $VideoBitrate,
|
||||
"-maxrate", $VideoBitrate,
|
||||
"-bufsize", "24000k",
|
||||
"-pix_fmt", "yuv420p",
|
||||
"-g", $gop.ToString(),
|
||||
"-c:a", "aac",
|
||||
"-b:a", $AudioBitrate,
|
||||
"-ar", $AudioSampleRate.ToString(),
|
||||
"-ac", $AudioChannels.ToString(),
|
||||
"-f", "mpegts",
|
||||
$endpoint
|
||||
)
|
||||
$command = "& `"$captureScript`" -Output - -SampleRate $AudioSampleRate -Channels $AudioChannels | & `"$FfmpegPath`" $($ffmpegArgs -join ' ')"
|
||||
|
||||
Write-Host "Raven muxed A/V sender:"
|
||||
Write-Host " ffmpeg: $FfmpegPath"
|
||||
Write-Host " target: $endpoint"
|
||||
Write-Host " video: $Source $videoSize@$Framerate via h264_nvenc"
|
||||
Write-Host " audio: Realtek/default render loopback ${AudioChannels}ch ${AudioSampleRate}Hz -> AAC"
|
||||
Write-Host " stdout: $stdoutLog"
|
||||
Write-Host " stderr: $stderrLog"
|
||||
|
||||
if ($DryRun) {
|
||||
Write-Host $command
|
||||
exit 0
|
||||
}
|
||||
|
||||
Start-Process `
|
||||
-FilePath "powershell" `
|
||||
-ArgumentList @("-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", $command) `
|
||||
-WindowStyle Hidden `
|
||||
-RedirectStandardOutput $stdoutLog `
|
||||
-RedirectStandardError $stderrLog `
|
||||
-PassThru |
|
||||
ForEach-Object { Write-Host "Started Raven muxed A/V sender pid=$($_.Id)" }
|
||||
|
|
@ -17,9 +17,9 @@ New-Item -ItemType Directory -Force -Path $logDir | Out-Null
|
|||
if ($DryRun) {
|
||||
Write-Host "MIMIR_RUNTIME_CONFIG=$ConfigPath"
|
||||
Write-Host "Would stage Nightwing witness tools to $NightwingHost and start --track-eyes publisher at $WitnessUrl"
|
||||
Write-Host "Would start local Raven A/V demux: scripts\start-raven-av-demux.ps1"
|
||||
Write-Host "Would launch: dotnet run --project $repo\src\Mimir.App\Mimir.App.csproj"
|
||||
Write-Host "Raven screen sender: scripts\start-raven-screen-capture-sender.ps1 -TargetHost 192.168.1.66 -Port 5200"
|
||||
Write-Host "Raven Realtek sender: scripts\raven-audio.ps1 -TargetHost 192.168.1.66 -Port 5202"
|
||||
Write-Host "Raven muxed A/V sender: scripts\start-raven-av-sender.ps1 -TargetHost 192.168.1.66 -Port 5200"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +82,8 @@ if ($LASTEXITCODE -ne 0) {
|
|||
throw "Could not start Nightwing typed witness publisher."
|
||||
}
|
||||
|
||||
& (Join-Path $repo "scripts\start-raven-av-demux.ps1")
|
||||
|
||||
$env:MIMIR_RUNTIME_CONFIG = $ConfigPath
|
||||
$args = @("run", "--project", (Join-Path $repo "src\Mimir.App\Mimir.App.csproj"))
|
||||
if ($Headless) {
|
||||
|
|
@ -99,6 +101,5 @@ if ($Headless) {
|
|||
|
||||
Write-Host "MIMIR_RUNTIME_CONFIG=$ConfigPath"
|
||||
Write-Host "Starting stream proof: Leap + Kiyo Pro + Raven screen/audio, Nightwing Eye/Move witness claims"
|
||||
Write-Host "Raven senders expected: scripts\start-raven-screen-capture-sender.ps1 -TargetHost 192.168.1.66 -Port 5200"
|
||||
Write-Host "Raven audio expected: scripts\raven-audio.ps1 -TargetHost 192.168.1.66 -Port 5202"
|
||||
Write-Host "Raven sender expected: scripts\start-raven-av-sender.ps1 -TargetHost 192.168.1.66 -Port 5200"
|
||||
dotnet @args
|
||||
|
|
|
|||
Loading…
Reference in a new issue