✨ Add iKAT automated FFmpeg session recording#87
Merged
Conversation
Adds Start-AppRecording.ps1 and Remove-ExpiredRecordings.ps1 to capture intermittent errors dynamically in RemoteApp sessions while managing necessary storage retention. Also includes their respective Pester testing suites. Closes tracking items.
Moves registry scripts and their respective Pester tests into the iCat project structure.
Adds WriteFolsom.ps1 and dns_check_temp.ps1 test scripts to the working directory.
Adds a pre-configured runner script to execute the FFmpeg capture targeting Dina's iKAT application. Wraps the parameters using splatting for easy Task Scheduler deployment.
Renames start scripts to better reflect their roles. Start-AppRecording becomes Invoke-iKATRecording (the core logic). The wrapper becomes Start-DinaRecording (the user-specific process runner). Updates Pester tests and plan.md to reflect this terminology restructure.
Changes the TargetUser parameter from 'dina' to the actual username 'dpurner' to ensure the session matches correctly.
Adds test.md outlining local console simulations and Task Scheduler dry-runs necessary to validate the FFmpeg capturing script before launching to production.
Changes the termination logic to send a 'q' command to standard input rather than hard-killing the process via Stop-Process to prevent MKV file closure corruption.
Adds the '-pix_fmt yuv420p' argument to the FFmpeg recording string. Without this, gdigrab defaults to yuv444p which is not supported by default Windows 10/11 media players (Movies & TV, WMP) natively, causing playback failures without VLC.
Wraps the process monitoring loop in a try-finally block. Ensures that if the script is hard-stopped via Ctrl+C or a task scheduler kill signal, the 'q' command is still sent to FFmpeg's stream to perfectly flush and save the current MKV.
Adds Test-Recording.ps1 to facilitate local sandbox testing and updates test.md with the latest behavior around UWP background apps (like Notepad) and Ctrl+C interrupt testing.
Updates documentation to match final script names, standard input closing logic, specific UWP background limitations, and Task Scheduler logic.
Removes the app-process trigger loop in favor of recording immediately on logon. The TargetProcess parameter has been dropped entirely. Virtual desktop dimensions are now auto-detected at runtime via System.Windows.Forms.SystemInformation.VirtualScreen to capture all connected monitors. The try/finally graceful shutdown structure is retained and continues to fire correctly on logoff or Task Scheduler termination.
Owner
Author
|
Did some tests on the server during debugging, everything is working as expected now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a complete automated screen recording solution for the iKAT RDS server (
KFWS6IKAT01.kikkoman.com). When a target user (e.g.,dpuerner) logs on, a Task Scheduler task silently launches FFmpeg via a VBScript launcher, captures their entire desktop session, and saves it as an MPEG-TS file. Recording continues until the user logs off, even if FFmpeg is force-killed by Windows at session end.New files:
Scripts/iKAT/Invoke-FFmpegCapture/Invoke-iKATRecording.ps1— Core recording script: validates user, checks disk space, auto-detects screen dimensions, launches FFmpeg with zero-latency encodingScripts/iKAT/Invoke-FFmpegCapture/Start-DinaRecording.ps1— Runner forKFI\dpuerner, targetsC:\Recordings, requires 10 GB freeScripts/iKAT/Invoke-FFmpegCapture/Start-DinaRecording.vbs— VBScript launcher (invoked by Task Scheduler to suppress console window flash)Scripts/iKAT/Invoke-FFmpegCapture/Start-JoeyRecording.ps1— Test runner forKFI\admin-jmaffiola, requires 1 GB freeScripts/iKAT/Invoke-FFmpegCapture/Start-JoeyRecording.vbs— VBScript launcher for Joey's test taskScripts/iKAT/Invoke-FFmpegCapture/Remove-ExpiredRecordings.ps1— Daily cleanup: deletes.tsrecordings older than a configurable retention periodScripts/iKAT/Invoke-FFmpegCapture/Test-Recording.ps1— Local test harnessScripts/iKAT/Invoke-FFmpegCapture/plan.md— Architecture and design notesScripts/iKAT/Invoke-FFmpegCapture/test.md— Testing guideScripts/iKAT/Invoke-FFmpegCapture/log.md— Implementation diaryScheduled tasks deployed on server (not in repo):
iKAT-Record-Dina— triggers onKFI\dpuernerlogon,LogonType Interactive,RunLevel LimitediKAT-Record-Joey-Test— triggers onKFI\admin-jmaffiolalogon, same settingsiKAT-Cleanup-Recordings— runs daily at 2 AM as SYSTEMWhy are we doing this?
Dina (
dpuerner) is experiencing intermittent errors in the iKAT application that have been difficult to reproduce and diagnose. This recording system captures her full desktop session so that the exact sequence of actions leading to an error can be reviewed after the fact. Requested by Nate.How should this be tested?
KFWS6IKAT01.kikkoman.comasKFI\admin-jmaffiolaiKAT-Record-Joey-Testis running)C:\Recordings— a.tsfile should be present with a size proportional to session length.tsfile locally and open in VLC — confirm full session is captured with no truncation at the endKey things to verify:
Any deployment notes?
Prerequisites on target server:
C:\ffmpeg\bin\ffmpeg.exeand on system PATH for all usersC:\Recordingsdirectory (will be auto-created by the script if absent)pwsh.exe)Task registration: Tasks must be registered with:
LogonType Interactive— required to run in the user's actual desktop session (not Session 0)RunLevel Limited— elevation (RunLevel Highest) blocksgdigrabfrom accessing the RDS desktopOutput format: MPEG-TS (
.ts) — chosen because it writes self-contained 188-byte packets with no trailer required. Files are fully playable even if FFmpeg is force-killed at logoff. VLC opens.tsfiles natively.FFmpeg encoding flags:
-tune zerolatency— disables libx264 lookahead buffer so each frame is flushed immediately (prevents 5-10s data loss at session end)-g 5— 1-second keyframe interval at 5fps-flush_packets 1— OS-level flush after every TS packet-vf scale=trunc(iw/2)*2:trunc(ih/2)*2— enforces even dimensions without resizing (libx264 requirement)