aws-samples / rekognition-streaming-video-events

This repository provides a step-by-step setup of Amazon Rekognition’s Streaming Video Events for connected home use cases.
MIT No Attribution
17 stars 5 forks source link

Stream processor not reaching RUNNING state #1

Open jorgejgnz opened 2 years ago

jorgejgnz commented 2 years ago

I'm trying to detect labels in a streaming video but the stream processor goes from STARTING state to STOPPED state. It seems not to reach RUNNING state at any moment.

If MaxDurationInSeconds is set, it finishes before reaching that duration. If it's not set, it finishes after a couple of seconds.

Sometimes it detects a label that appeared in the stream a long time ago. Sometimes, if the processor is restarted after having stopped, it detects events that have already been detected before, returning exactly the same image.

I have tried with an external webcam, built-in webcam and sample videos, but I get the same behavior in all cases.

I have checked that the producer timestamp is correct. Just after starting the processor, I capture a video of a few seconds of the stream using get_data_endpoint and get_media functions for the same timestamp used in stream processor start request. The video extracted from the stream for that timestamp shows the expected content.

Responses from stream processors's creation and start requests don't show any error.

Stream processor creation request:

response = rekognition_client.create_stream_processor(
    Input={
        'KinesisVideoStream': {
            'Arn': ...
        }
    },
    Output={
        'S3Destination': {
            'Bucket': ...
        }
    },
    Name= ...,
    Settings = {'ConnectedHome': {
        'Labels': ["PERSON", "PET", "PACKAGE","ALL"],
        'MinConfidence': 90.0
    }
    },
    RoleArn=...,
    NotificationChannel={
        'SNSTopicArn': ...
    }
)

Stream processor start request:

response = rekognition.start_stream_processor(
        Name=...,
        StartSelector={
            'KVSStreamStartSelector': {
                'ProducerTimestamp': int(time.time())
            }
        }
        #,StopSelector={'MaxDurationInSeconds': 120}
    )
mikames commented 2 years ago

I think the ProducerTimestamp needs to be in milliseconds not seconds can you try 'ProducerTimestamp': int(time.time())*1000 and see if you get the same result?

jorgejgnz commented 2 years ago

I tried providing timestamp in milliseconds in the start processor request but I'm getting the same result. If StopSelector is not provided in start request, the stream processor tries to start but it stops almost immediately after receiving the start request.

I assume timestamps are given in seconds as they are given in seconds in Kinesis Video Streams API. I couldn't find any documentation that specifies what format the producer timestamp should have in the start stream processor request.

Docs: API, CLI

mikames commented 2 years ago

@jorgejgnz can you email me directly (mikames@amazon.com) with your contact details so i can follow up. thanks

bartlomiejgadzicki-digica commented 2 years ago

@mikames hi, any updates regarding this issue?

mikames commented 2 years ago

@bartlomiejgadzicki-digica , hey yes looks like it's my instructions setting up SNS were wrong i'm going to fix. here's the instructions on setting up SNS https://docs.aws.amazon.com/rekognition/latest/dg/streaming-labels-setting-up.html

bartlomiejgadzicki-digica commented 2 years ago

It doesn't work either with Producer or real time timestamp :C

mikames commented 2 years ago

@bartlomiejgadzicki-digica please drop me an email mikames@amazon.com and i can help debug.