feat: NUI protocol support for video uploads#38
Merged
Conversation
- Add protocol check in client captureStream handler - Register capture_stream_chunk and capture_stream_finalize NUI callbacks - Add stream_bps config reading and NUI callback handlers for video chunks/finalize - Add NUI writable stream in capture-stream.ts (base64 transport) - Extract shared finalizeStream() from koa-router.ts - Add server event handlers for stream-chunk-nui and stream-finalize-nui - Update fxmanifest.lua comment to reflect video NUI support Agent-Logs-Url: https://github.com/itschip/screencapture/sessions/97074cbd-72d9-42d8-b60c-7e38a0a97090 Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Agent-Logs-Url: https://github.com/itschip/screencapture/sessions/97074cbd-72d9-42d8-b60c-7e38a0a97090 Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
itschip
May 8, 2026 10:53
View session
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.
Video streaming only worked via HTTP protocol. When
protocol 'nui'was set in fxmanifest, video chunks still bypassed NUI callbacks and went direct to the Koa HTTP server. This adds the NUI transport path for video, mirroring how images already work.Data flow (NUI mode)
NUI encodes each video chunk as base64 → POSTs to NUI callback → client forwards via
TriggerLatentServerEvent(usingstream_bps) → server decodes and appends to temp file → finalize assembles and uploads.Changes
game/nui/src/capture-stream.ts— Split writable stream creation intocreateHttpWritableStream()andcreateNuiWritableStream(). NUI path base64-encodes binary chunks in batches and POSTs to callback URLs. Used discriminated union type for request to enforce correct parameter combinations per protocol.game/client/bootstrap.ts— Addedprotocol === 'nui'branch incaptureStreamhandler, passingcallbackUrl/finalizeCallbackUrlinstead ofserverEndpoint. Registeredcapture_stream_chunkandcapture_stream_finalizeNUI callback types.game/client/protocols/nui.ts— Addedstream_bpsconfig. Two new NUI callback handlers forward chunk data viaTriggerLatentServerEventand finalization viaemitNet(no large payload).game/server/koa-router.ts— ExtractedfinalizeStream()as shared export to avoid duplicating the read→upload→cleanup logic.game/server/bootstrap.ts— Addedscreencapture:stream-chunk-nui(base64→buffer→appendFile) andscreencapture:stream-finalize-nuievent handlers, reusingfinalizeStream().fxmanifest.lua— Updated comment to remove "nui is not yet supported for videos".