Skip to content

Fix ffmpeg recorder crash from comparing NumPy array to tuple#1123

Open
eduard-aenoaei wants to merge 1 commit into
boltgolt:masterfrom
eduard-aenoaei:fix/ffmpeg-reader-empty-check
Open

Fix ffmpeg recorder crash from comparing NumPy array to tuple#1123
eduard-aenoaei wants to merge 1 commit into
boltgolt:masterfrom
eduard-aenoaei:fix/ffmpeg-reader-empty-check

Conversation

@eduard-aenoaei

Copy link
Copy Markdown

Problem

With recording_plugin = ffmpeg, authentication crashes with a ValueError
in ffmpeg_reader.py:

ValueError: operands could not be broadcast together with shapes (N,640,360,3) (0,)

Root cause

self.video starts as an empty tuple () and is replaced by a NumPy array
in record(). The emptiness check if self.video == (): works while it's a
tuple, but once it holds an array, array == () triggers NumPy elementwise
broadcasting and raises instead of reporting emptiness.

Fix

Check the sentinel type directly with isinstance(self.video, tuple). This
matches the intended "empty until recorded" semantics and never invokes NumPy
comparison.

Testing

Reproduced on openSUSE Tumbleweed, howdy 3.0.0, Chicony IR camera, ffmpeg
backend at 640x360. With the patch the backend reads frames and authentication
proceeds normally.

The ffmpeg backend stores frames in self.video, which starts as an empty
tuple and is replaced by a NumPy array in record(). The emptiness check
used `self.video == ()`, which works while it is a tuple but triggers
NumPy elementwise broadcasting once it holds an array, raising:

    ValueError: operands could not be broadcast together with shapes
    (N,640,360,3) (0,)

during authentication. Check the type with isinstance(self.video, tuple)
instead, which matches the intended sentinel semantics and never invokes
NumPy comparison.
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.

1 participant