Drop the frame copy in the video reader

read_video_reader_frame copied every decoded frame out of the pipe buffer.
The frames are only read downstream (face detection, coordinate scaling), so
the read-only numpy view over the pipe bytes is safe to return directly.
Saves one full-frame (~25 MB at 4K) memcpy per decoded frame.

AV1 ~21 -> ~22 fps, H.264 ~19 -> ~20 fps, output unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
henryruhs
2026-07-22 10:20:18 +02:00
parent 1ed1c39269
commit 7df613985d
+1 -1
View File
@@ -84,7 +84,7 @@ def read_video_reader_frame(video_reader : VideoReader) -> Tuple[bool, Optional[
if len(frame_buffer) == frame_size:
video_reader['position'] = video_reader.get('position') + 1
return True, numpy.frombuffer(frame_buffer, numpy.uint8).reshape(video_reader.get('height'), video_reader.get('width'), 3).copy()
return True, numpy.frombuffer(frame_buffer, numpy.uint8).reshape(video_reader.get('height'), video_reader.get('width'), 3)
return False, None