Video takes infinite time to analyze
zebpaypeswani opened this issue · 2 comments
zebpaypeswani commented
EDIT it started working now. I want to know is there any limit on how many video we can process. if yes how can i increase this limit?
Hi some time before it was working fine and I was able to analyze videos with in minute or so but suddenly my video is not getting analyze. It just goes on forever. I am trying so search faces in a videos. faces are indexed. they are about 300 face indexed
I am analyzing 3553477.mp4
(only 10 second video)
here is the output
Faces indexed:
Face ID: a1c8847f-7e80-4dd7-8b51-63c0d22ab765
Location: {'Width': 0.7492865920066833, 'Height': 0.8562403321266174, 'Left': 0.1664663851261139, 'Top': 0.032046884298324585}
started video analyzing
Start Job Id: 952741e2adaf526ca8fd270912d2cf578d24b69039edcac05dcc507b7b2193fb
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
It goes on and does not stop
here is the code
import boto3
import json
import sys
class VideoDetect:
rek = boto3.client('rekognition')
queueUrl = 'https://sqs.us-west-2.amazonaws.com/655136467581/Rekoginition'
roleArn = 'arn:aws:iam::655136467581:role/face_matching'
topicArn = 'arn:aws:sns:us-west-2:655136467581:image-rekoginition-sns'
bucket = 'face-reckognition-video-1'
video = ''
def __init__(self, video):
self.video = video
def main(self):
jobFound = False
sqs = boto3.client('sqs')
# =====================================
response = self.rek.start_face_search(Video={'S3Object': {'Bucket': self.bucket, 'Name': self.video}},
CollectionId='FaceCollection',
NotificationChannel={'RoleArn': self.roleArn,
'SNSTopicArn': self.topicArn})
# =====================================
print('Start Job Id: ' + response['JobId'])
dotLine = 0
faces = set()
while not jobFound:
sqsResponse = sqs.receive_message(QueueUrl=self.queueUrl, MessageAttributeNames=['ALL'],
MaxNumberOfMessages=10)
if sqsResponse:
if 'Messages' not in sqsResponse:
if dotLine < 20:
print('.', end='')
dotLine = dotLine + 1
else:
print()
dotLine = 0
sys.stdout.flush()
continue
for message in sqsResponse['Messages']:
notification = json.loads(message['Body'])
rekMessage = json.loads(notification['Message'])
print(rekMessage['JobId'])
print(rekMessage['Status'])
if str(rekMessage['JobId']) == response['JobId']:
print('Matching Job Found:' + rekMessage['JobId'])
jobFound = True
# =============================================
f = self.GetResultsFaceSearchCollection(rekMessage['JobId'])
faces.update(f)
# =============================================
sqs.delete_message(QueueUrl=self.queueUrl,
ReceiptHandle=message['ReceiptHandle'])
else:
print("Job didn't match:" +
str(rekMessage['JobId']) + ' : ' + str(response['JobId']))
# Delete the unknown message. Consider sending to dead letter queue
sqs.delete_message(QueueUrl=self.queueUrl,
ReceiptHandle=message['ReceiptHandle'])
print('done')
return faces
def GetResultsFaceSearchCollection(self, jobId):
maxResults = 10
paginationToken = ''
faces = []
finished = False
while not finished:
response = self.rek.get_face_search(JobId=jobId,
MaxResults=maxResults,
NextToken=paginationToken)
print(response)
print(response['VideoMetadata']['Codec'])
print(str(response['VideoMetadata']['DurationMillis']))
print(response['VideoMetadata']['Format'])
print(response['VideoMetadata']['FrameRate'])
for personMatch in response['Persons']:
print('Person Index: ' + str(personMatch['Person']['Index']))
print('Timestamp: ' + str(personMatch['Timestamp']))
if 'FaceMatches' in personMatch:
for faceMatch in personMatch['FaceMatches']:
print('Face ID: ' + faceMatch['Face']['FaceId'])
faces.append(faceMatch['Face']['FaceId'])
print('Similarity: ' + str(faceMatch['Similarity']))
print()
if 'NextToken' in response:
paginationToken = response['NextToken']
else:
finished = True
print()
return faces
shezgone commented
I have the same problem.
kyle861861 commented
i have too