Implement fragmented m4s support for Windows #1469
Merged
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.
Switches from fragmented MP4 on Windows to fragmented M4S
Greptile Summary
Replaces Windows fragmented MP4 recording with M4S (MPEG-DASH) segments by introducing
WindowsFragmentedM4SMuxerandWindowsFragmentedM4SCameraMuxer. The new implementation leverages the existingSegmentedVideoEncoderwhich uses FFmpeg's DASH muxer to produce aninit.mp4initialization segment plus timestampedsegment_NNN.m4smedia segments.Key changes:
crates/recording/src/output_pipeline/win_fragmented_m4s.rswith ~700 lines implementing both screen and camera muxerscapture_pipeline.rsto useWindowsFragmentedM4SMuxerinstead ofWindowsSegmentedMuxerfor fragmented Windows recordingssegmented_stream.rsby converting backslashes to forward slashes for FFmpeg compatibilityH264Preset::Ultrafastwith 3-second segment duration by defaultConfidence Score: 4/5
win_fragmented_m4s.rsduring testing - verify frame drop behavior and encoder thread cleanup work correctly under various recording scenariosImportant Files Changed
Sequence Diagram
sequenceDiagram participant App as Desktop App participant Pipeline as Capture Pipeline participant Muxer as WindowsFragmentedM4SMuxer participant Encoder as SegmentedVideoEncoder participant FFmpeg as FFmpeg DASH Muxer participant Disk as File System App->>Pipeline: Start recording (fragmented=true) Pipeline->>Muxer: Setup muxer with config Muxer->>Disk: Create segments directory loop Video frames App->>Pipeline: Send video frame Pipeline->>Muxer: send_video_frame() alt First frame Muxer->>Encoder: start_encoder() Encoder->>FFmpeg: Initialize DASH muxer Note over Encoder,FFmpeg: Set init_seg_name="init.mp4"<br/>Set media_seg_name with forward slashes FFmpeg->>Disk: Create init.mp4 Encoder->>Encoder: Spawn encoder thread end Muxer->>Encoder: Queue frame via channel Encoder->>Encoder: Convert D3D11 frame to FFmpeg Encoder->>FFmpeg: queue_frame() alt Segment boundary detected FFmpeg->>Disk: Write segment_NNN.m4s Encoder->>Encoder: Update manifest.json end end App->>Pipeline: Stop recording Pipeline->>Muxer: finish() Muxer->>Encoder: Send None (stop signal) Encoder->>Encoder: Join encoder thread Encoder->>FFmpeg: flush() and write_trailer() FFmpeg->>Disk: Finalize segments Encoder->>Disk: Write final manifest.json Muxer-->>Pipeline: Done