Как можно считать байт-строчку в cv2.VideoCapture? Я попробовал вот так:
cap = cv2.VideoCapture(io.BytesIO(decoded_vid)) # decoded_vid - bytes
При этом я получаю TypeError:
TypeError: Argument 'index' is required to be an integer
Это, кажется, весьма популярный юзкейс, но я не смог найти примеров подробной работы. Еще не совсем понятно, почему он ожидает аргумент intом - даже в официальной доке есть примеры, где аргументом передается строка с путем к файлу.
Полный трейсбек:
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 390, in run_asgi
ff_videocomp_1 | result = await app(self.scope, self.receive, self.send)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
ff_videocomp_1 | return await self.app(scope, receive, send)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 179, in __call__
ff_videocomp_1 | await super().__call__(scope, receive, send)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/applications.py", line 111, in __call__
ff_videocomp_1 | await self.middleware_stack(scope, receive, send)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
ff_videocomp_1 | raise exc from None
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
ff_videocomp_1 | await self.app(scope, receive, _send)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
ff_videocomp_1 | raise exc from None
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
ff_videocomp_1 | await self.app(scope, receive, sender)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 566, in __call__
ff_videocomp_1 | await route.handle(scope, receive, send)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 227, in handle
ff_videocomp_1 | await self.app(scope, receive, send)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 41, in app
ff_videocomp_1 | response = await func(request)
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 182, in app
ff_videocomp_1 | raw_response = await run_endpoint_function(
ff_videocomp_1 | File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 133, in run_endpoint_function
ff_videocomp_1 | return await dependant.call(**values)
ff_videocomp_1 | File "./main.py", line 26, in process
ff_videocomp_1 | cap = cv2.VideoCapture(io.BytesIO(decoded_vid))
ff_videocomp_1 | TypeError: Argument 'index' is required to be an integer