You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VideoFrame and AudioFrame built from a read-only NumPy buffer fail in capture_frame with TypeError #884
rtc.VideoFrame and rtc.AudioFrame accept a memoryview. If the memoryview is read-only and covers the whole buffer, and the underlying object is not bytes or bytearray (for example a NumPy array from np.frombuffer), the constructor accepts it. Capturing the frame then fails in get_address:
TypeError: expected bytes, bytearray, or memoryview, got <class 'numpy.ndarray'>
The frame is captured, as it is when you pass pixels.tobytes() or a writable array.
Cause
_ensure_compatible_buffer only copies memoryviews whose nbytes differs from len(data.obj). For a read-only memoryview, get_address then reads the address from data.obj, which only works for bytes and bytearray.
Hi, I'm Himanshu, looking for a scoped contribution. I saw #885. Would a buffer matrix covering read-only and writable NumPy views, slices, and both AudioFrame and VideoFrame be useful? I'd check accepted inputs and capture behavior, with the existing tests as the starting point.
I haven't run this reproduction or the candidate PR's tests yet; this is an offer to investigate, not a claim that the gap is confirmed.
AudioFrame and VideoFrame now copy read-only memoryviews when their backing object cannot be addressed by get_address, including read-only NumPy buffers. Regression tests cover both frame types.
The fix is merged but not yet released. It will be included in the next RTC package release; the current livekit 1.3.0 release does not contain it. Until then, passing pixels.tobytes() (or the equivalent bytes conversion for audio data) avoids this error.
Activity
himanshumehta commentedon Oct 25, 2026
Hi, I'm Himanshu, looking for a scoped contribution. I saw #885. Would a buffer matrix covering read-only and writable NumPy views, slices, and both AudioFrame and VideoFrame be useful? I'd check accepted inputs and capture behavior, with the existing tests as the starting point.
I haven't run this reproduction or the candidate PR's tests yet; this is an offer to investigate, not a claim that the gap is confirmed.
cloudwebrtc commentedon Nov 24, 2026
The fix has been merged in #885 (f168a28).
AudioFrame and VideoFrame now copy read-only memoryviews when their backing object cannot be addressed by get_address, including read-only NumPy buffers. Regression tests cover both frame types.
The fix is merged but not yet released. It will be included in the next RTC package release; the current livekit 1.3.0 release does not contain it. Until then, passing pixels.tobytes() (or the equivalent bytes conversion for audio data) avoids this error.
fix(rtc): copy read-only frame buffers that get_address cannot take (l…