I have a Python lib that I made to estimate pose data from a video file. This uses opencv
to read the video from the specified path. When I try to open a video I get the following error. I have tested it with multiple videos.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x39f2180] moov atom not found
[ERROR] ValueError: Error opening video stream or file
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 35, in handler
video_processing_strategy.process_task()
File "/var/task/src/strategy/video_processing.py", line 13, in process_task
counter, output_file_path = pose_estimator.estimate_pose(
File "/var/task/pose_estimation_lib/estimator.py", line 30, in estimate_pose
raise ValueError("Error opening video stream or file")
I have the following code
import pathlib
import typing
import cv2
class PoseEstimator:
def __new__(cls, *args, **kwargs):
if not hasattr(cls, "instance"):
cls.instance = super(PoseEstimator, cls).__new__(cls)
return cls.instance
def estimate_pose(
self,
exercise: str,
video_name: str,
min_detection_confidence: typing.Optional[float] = 0.5,
min_tracking_confidence: typing.Optional[float] = 0.5,
fps: typing.Optional[int] = 30,
):
counter, status = 0, True
absolute_file_path = pathlib.Path(video_name)
input_stream = cv2.VideoCapture(str(absolute_file_path))
if not input_stream.isOpened():
raise ValueError("Error opening video stream or file")
frame_dimensions = (int(input_stream.get(3)), int(input_stream.get(4)))
...
I am running this code on AWS Lambda as Docker image built from the below Dockerfile on a x86_64
arch
FROM public.ecr.aws/lambda/python:3.11
ARG CODEARTIFACT_AUTH_TOKEN
WORKDIR ${LAMBDA_TASK_ROOT}
RUN yum update -y \
&& yum install -y libglvnd-glx mesa-libGL
# RUN yum install -y gcc openssl-devel wget tar
COPY requirements.txt /tmp/requirements.txt
RUN pip config set global.extra-index-url https://aws:$CODEARTIFACT_AUTH_TOKEN@wecoach-976750617193.d.codeartifact.ap-south-1.amazonaws.com/pypi/python-packages/simple/
RUN pip install --no-cache-dir --requirement /tmp/requirements.txt --target .
COPY . .
CMD [ "lambda_function.handler" ]
I am using opencv-contrib-python==4.8.1.78