whitphx/streamlit-webrtc

Incompatibility between the av==10.0.0 library and streamlit-webrtc==0.47.1

gugaucb opened this issue · 1 comments

Code:

class OpenRecognitionVideoTransformer(VideoTransformerBase):        
        def __init__(self) -> None:
            self.type = "noop"
        def transform(self, frame: av.VideoFrame) -> av.VideoFrame:
            img = frame.to_image()
            return av.VideoFrame.from_image(img)
webrtc_ctx = webrtc_streamer(
        key="opencv-filter",
        mode=WebRtcMode.SENDRECV,
        client_settings=WEBRTC_CLIENT_SETTINGS,
        video_transformer_factory=OpenRecognitionVideoTransformer,
        async_processing=True,
    )

Error

2023-10-13 01:28:10,497 - streamlit_webrtc.process - ERROR - Error occurred in the WebRTC thread: - None 2023-10-13 01:28:10,514 - streamlit_webrtc.process - ERROR - Traceback (most recent call last): - None 2023-10-13 01:28:10,519 - streamlit_webrtc.process - ERROR - File "/usr/local/lib/python3.10/site-packages/streamlit_webrtc/process.py", line 108, in _run_worker_thread - None 2023-10-13 01:28:10,523 - streamlit_webrtc.process - ERROR - self._worker_thread() - None 2023-10-13 01:28:10,530 - streamlit_webrtc.process - ERROR - File "/usr/local/lib/python3.10/site-packages/streamlit_webrtc/process.py", line 196, in _worker_thread - None 2023-10-13 01:28:10,534 - streamlit_webrtc.process - ERROR - new_frames = finished.result() - None 2023-10-13 01:28:10,539 - streamlit_webrtc.process - ERROR - File "/usr/local/lib/python3.10/site-packages/streamlit_webrtc/models.py", line 115, in recv_queued - None 2023-10-13 01:28:10,544 - streamlit_webrtc.process - ERROR - return [self.recv(frames[-1])] - None 2023-10-13 01:28:10,551 - streamlit_webrtc.process - ERROR - File "/usr/local/lib/python3.10/site-packages/streamlit_webrtc/models.py", line 107, in recv - None 2023-10-13 01:28:10,556 - **streamlit_webrtc.process - ERROR - return av.VideoFrame.from_ndarray(new_image, format="bgr24") - None** 2023-10-13 01:28:10,560 - streamlit_webrtc.process - ERROR - File "av/video/frame.pyx", line 408, in av.video.frame.VideoFrame.from_ndarray - None 2023-10-13 01:28:10,566 - streamlit_webrtc.process - ERROR - File "av/utils.pyx", line 69, in av.utils.check_ndarray - None 2023-10-13 01:28:10,570 - streamlit_webrtc.process - ERROR - AttributeError: 'av.video.frame.VideoFrame' object has no attribute 'dtype' - None

python 3.10

requirements.txt

aioice==0.9.0
aiortc==1.5.0
altair==5.1.2
attrs==23.1.0
av==10.0.0
blinker==1.6.3
cachetools==5.3.1
certifi==2023.7.22
cffi==1.16.0
charset-normalizer==3.3.0
click==8.1.7
cryptography==41.0.4
dlib==19.24.2
dnspython==2.4.2
face-recognition==1.3.0
face-recognition-models==0.3.0
gitdb==4.0.10
GitPython==3.1.37
google-crc32c==1.5.0
idna==3.4
ifaddr==0.2.0
importlib-metadata==6.8.0
Jinja2==3.1.2
jsonschema==4.19.1
jsonschema-specifications==2023.7.1
markdown-it-py==3.0.0
MarkupSafe==2.1.3
mdurl==0.1.2
numpy==1.26.0
packaging==23.2
pandas==2.1.1
Pillow==10.0.1
protobuf==4.24.4
pyarrow==13.0.0
pycparser==2.21
pydeck==0.8.1b0
pyee==11.0.0
Pygments==2.16.1
pylibsrtp==0.8.0
pymongo==4.5.0
pyOpenSSL==23.2.0
python-dateutil==2.8.2
pytz==2023.3.post1
referencing==0.30.2
requests==2.31.0
rich==13.6.0
rpds-py==0.10.6
six==1.16.0
smmap==5.0.1
streamlit==1.27.2
streamlit-webrtc==0.47.1
tenacity==8.2.3
toml==0.10.2
toolz==0.12.0
tornado==6.3.3
typing_extensions==4.8.0
tzdata==2023.3
tzlocal==5.1
urllib3==2.0.6
validators==0.22.0
watchdog==3.0.0
zipp==3.17.0

pip install ha-av is ok for streamlit-webrtc==0.47.1