Skip to content

Conversation

@amangupta20
Copy link

Hi there!

I'm working on a project that needs high-performance screen capture, and the callback feature from PR #151 is perfect for it.

I noticed the original PR was failing to build with the latest dependencies, so I dug in and patched the compilation errors. I'm opening this new PR so everyone can get it working without any issues.

This combines all the work from #151 with the necessary fixes. Hopefully, this helps anyone else who stumbles upon the same issue!

Changes:

@NiiightmareXD
Copy link
Owner

Thank you for the pull request. However, I noticed a few issues:

  1. There are two binary files in the commit that may not be necessary.
  2. I believe we should consider an abstraction that allows users to implement their own solutions, such as their specific WebRTC implementation or TCP frame ordering, instead of relying on our defaults.

I would love to hear your thoughts on this.

@codex, review this PR.

@chatgpt-codex-connector
Copy link

Codex Review: Here are some suggestions.

windows-capture/src/encoder.rs

Lines 1463 to 1468 in 9a76168

// Extract encoded video data and send to callback
let video_data = sample.Buffer()?;
let mut video_array: Array<u8> = Array::new();
CryptographicBuffer::CopyToByteArray(&video_data, &mut video_array)?;
let encoded_frame = EncodedFrame {

[P1] Stop treating raw sample buffers as encoded video

The callback sends whatever MediaStreamSample::Buffer returns as an EncodedFrame. When the sample was created from Direct3D11 surfaces this property is typically empty or fails, so the handler will error out before the transcoder runs. Even when it succeeds, the bytes are the uncompressed BGRA frame, not the H264/AAC output generated by the MediaTranscoder, so the network layer sends multi‑megabyte raw frames and downstream decoders never receive keyframes. To stream encoded data you need to consume the transcoder’s output stream (or another post‑encode hook) instead of the pre‑encode sample.


https://github.com/NiiightmareXD/windows-capture/blob/9a76168ea80061519c7eb8c52111be9b147456cf/test_implementation#L1
[P2] Drop committed test binaries

The commit adds test_implementation and test_windows_integration binaries (~3.6 MB each). These compiled artifacts bloat the repository and will quickly become stale; they should be generated as part of CI or downloaded on demand instead of being versioned.


Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

https://github.com/NiiightmareXD/windows-capture/blob/9a76168ea80061519c7eb8c52111be9b147456cf/test_implementation#L1
[P2] Drop committed test binaries

The commit adds test_implementation and test_windows_integration binaries (~3.6 MB each). These compiled artifacts bloat the repository and will quickly become stale; they should be generated as part of CI or downloaded on demand instead of being versioned.


Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +1463 to +1468
// Extract encoded video data and send to callback
let video_data = sample.Buffer()?;
let mut video_array: Array<u8> = Array::new();
CryptographicBuffer::CopyToByteArray(&video_data, &mut video_array)?;

let encoded_frame = EncodedFrame {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Stop treating raw sample buffers as encoded video

The callback sends whatever MediaStreamSample::Buffer returns as an EncodedFrame. When the sample was created from Direct3D11 surfaces this property is typically empty or fails, so the handler will error out before the transcoder runs. Even when it succeeds, the bytes are the uncompressed BGRA frame, not the H264/AAC output generated by the MediaTranscoder, so the network layer sends multi‑megabyte raw frames and downstream decoders never receive keyframes. To stream encoded data you need to consume the transcoder’s output stream (or another post‑encode hook) instead of the pre‑encode sample.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants