feat(webrtc): process video files by URL with optional max_fps cap - #2896
Closed
digaobarbosa wants to merge 1 commit into
Closed
feat(webrtc): process video files by URL with optional max_fps cap#2896digaobarbosa wants to merge 1 commit into
digaobarbosa wants to merge 1 commit into
Conversation
Allow creating a WebRTC session that processes a video file directly from an HTTP(S) URL - ffmpeg streams it, so no data-channel upload is needed. With webrtc_realtime_processing=false every frame is processed as fast as possible; max_fps optionally caps the rate via ffmpeg's fps filter, and workflows see the effective (capped) fps so temporal analytics stay correct. The upload path and the new URL path share the same processing logic (_begin_video_file_processing). URL processing is deferred until the peer connection and data channel are ready, since a finite file processed at full speed would otherwise finish before outputs can reach the client. URL destinations are validated with the existing SSRF guard used for image URL inputs.
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.
Description
The objective here is to be able to process a video file that was already uploaded to GCS in asset library without a new download and upload through datachannel approach.
Adds two fields to
WebRTCWorkerRequest(POST /initialise_webrtc_worker):video_file_url— HTTP(S) URL of a video file (mp4/webm/ogv/...). The server streams it directly with ffmpeg, so no data-channel chunk upload is needed. The URL passes the same SSRF guard used for image URL inputs (_validate_url_destination).max_fps— optional cap on the processed frame rate for video files. Frames are decimated with ffmpeg'sfpsfilter (via PyAV's filter graph) insideThreadedVideoFileTrack. Unset = all frames. The name reuses the establishedmax_fpscontract fromInferencePipeline/VideoConfiguration.With
webrtc_realtime_processing: falsethe file is processed as fast as possible (existingThreadedVideoFileTrackmachinery, no pacing).Implementation notes
_begin_video_file_processing, shared by the upload path and the new URL branch — no duplicated logic.max_fpsalso applies to chunk-uploaded files.max_fpscaps a file,_declared_fps(→VideoFrame.fps/WebRTCVideoMetadata.declared_fps) reports the capped rate, so fps-sensitive workflow blocks (trackers, time-in-zone, velocity) see the real processed rate.max_fps< detected fps. In realtime modemax_fpsis ignored (realtime has its own frame-drop logic) with a warning.video_sourcelabelvideo_file_url; request-summary logging. The modal image needs a redeploy before clients send the new fields.Testing
tests/.../webrtc_worker/test_video_file_source.py); fullwebrtc_workersuite passes (20/20).max_fps: 5→ exactly 240 outputs,declared_fps=5.0, done in 0.9smax_fps→ all 1152 frames,declared_fps=24.0, done in 3.4sprocessing_completedelivered in both runsReviewer notes
stream_output: []is required for data-only sessions (Nonemeans "send video back"), same as before — the SDK already does this.docs/webrtc-streaming.md(request example +max_fpssemantics).