Stored Video Analysis takes too long - amazon-rekognition

I am using the amazon rekognition API to analyse my video to find and Search faces.
A one minute video has been on processing for nearly an hour now. But have not received any result .
Is this normal ?

SNS needed to be connected With SQN
https://docs.aws.amazon.com/sns/latest/dg/sns-sqs-as-subscriber.html#SendMessageToSQS.sqs.permissions

Related

Media conversion on AWS

I have an API written in nodeJS (/api/uploadS3) which is a PUT request and accepts a video file and a URL (AWS s3 URL in this case). Once called its task is to upload the file on the s3 URL.
Now, users are uploading files to this node API in different formats (thanks to the different browsers recording videos in different formats) and I want to convert all these videos to mp4 and then store them in s3.
I wanted to know what is the best approach to do this?
I have 2 solutions till now
1. Convert on node server using ffmpeg -
The issue with this is that ffmpeg can only execute a single operation at a time. And since I have only one server I will have to implement a queue for multiple requests which can lead to longer waiting times for users who are at the end of the queue. Apart from that, I am worried that during any ongoing video conversion if my node's traffic handling capability will be affected.
Can someone help me understand what will be the effect of other requests coming to my server while video conversion is going on? How will it impact the RAM, CPU usage and speed of processing other requests?
2. Using AWS lambda function -
To avoid load on my node server I was thinking of using an AWS lambda server where my node API will upload the file to S3 in the format provided by the user. Once, done s3 will trigger a lambda function which can then take that s3 file and convert it into .mp4 using ffmpeg or AWS MediaConvert and once done it uploads the mp4 file to a new s3 path. Now I don't want the output path to be any s3 path but the path that was received by the node API in the first place.
Moreover, I want the user to wait while all this happens as I have to enable other UI features based on the success or error of this upload.
The query here is that, is it possible to do this using just a single API like /api/uploadS3 which --> uploads to s3 --> triggers lambda --> converts file --> uploads the mp4 version --> returns success or error.
Currently, if I upload to s3 the request ends then and there. So is there a way to defer the API response until and unless all the operations have been completed?
Also, how will the lambda function access the path of the output s3 bucket which was passed to the node API?
Any other better approach will be welcomed.
PS - the s3 path received by the node API is different for each user.
Thanks for your post. The output S3 bucket generates File Events when a new file arrives (i.e., is delivered from AWS MediaConvert).
This file event can trigger a second Lambda Function which can move the file elsewhere using any of the supported transfer protocols, re-try if necessary; log a status to AWS CloudWatch and/or AWS SNS; and then send a final API response based on success/completion of them move.
AWS has a Step Functions feature which can maintain state across successive lambda functions, for automating simple workflows. This should work for what you want to accomplish. see https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-creating-lambda-state-machine.html
Note, any one lambda function has a 15 minute maximum runtime, so any one transcoding or file copy operation must complete within 15min. The alternative is to run on EC2.
I hope this helps you out!

Designing an back-end and front-end architecture for biomedical application

I have a biomedical application where I am continuously monitoring a patient'a ECG data. In real time, I am logging all raw values and processed values (heartrate, BP etc.). Since the patient is wearing the sensor 24x7, s/he is going to send a lot of these data every second.
Let say I am logging JSON values with timestamps like this in my application -
data = {
"raw":"293.110", // these are generated every mill second
"heartrate":"79", // every 1 second
"bpH":"123", // every 5 minutes
"bpL":"80", // every 5 mins
"artifacts":"1" // if body moves 1, otherwise 0
"time":"14:16:51 GMT+0530"
}
Then how should I architect my application in such a way that it should take care of scale-ability in term of supporting thousands of user logging huge amount of data every mill second.
Now, What I am going to do with these data -
Plot/Visualize data in real time, obviously, for health tracking for patient and doctor.
Store data in database for future use
Retrieve data from database -
To plot historical vitals
To plot raw data for analysis
To apply ML for generating further insights.
What I am planning to use for
Frontend : NodeJS + electronJS + Web Technologies
Backend : Google Cloud Platform
Where I need help
As you can understand from above, it is going to send a lot of data to backend hence how should I design my backedn with GCP
How to choose correct offering from GCP
If GCP is overkill for my application, then what would be other options.
You might like to start by reviewing some solutions/reference architectures other people have used:
Patient Monitoring Reference Architecture
Sensor stream ingest and processing reference architecture
stream analytics solution

Microsoft Azure cognition services - Speaker Recognition - Rate Limit

I use Microsoft Azure and the cognition service to be able to use the Speaker Recognition API.
I have a subscription "Pay as you go" with the Standard Pricing Tier (5 calls per second) . I use Unity to make the voice recording and to send the audio to the server.
Every 5 seconds, I send the audio to the server inside the update function of the C# script.
But around 30 seconds of speech, I got the error 429 : code: RateLimitExceeded, message : Rate limit is exceeded. Try again later.
If anyone use it, do you know why I got this response from the server, while I have a subscription to avoid this limit.
I joined the Microsoft assistant, and they told me that the subscription is active, but I don't see any direct debit.
If you look at the note in the readme section here https://github.com/Microsoft/Cognitive-SpeakerRecognition-Windows,
Note: Make sure that the number of requests per minute resulting from tunning the step size won't exceed your subscription's rate limit.
For example, applying a step size of 1 on an audio file of size 1 minute will result in 60 requests. Applying a step size of 2 on the same audio file will result in 30 requests. For your convenience, we have provided sample audios to enroll 2 speakers and a sample audio for streaming. These audios are found under SpeakerRecognition\Windows\Streaming\SPIDStreamingAPI-WPF-Samples\SampleAudios.
Also, according to the API link on https://azure.microsoft.com/en-us/services/cognitive-services/speaker-recognition/
The audio file format must meet the following requirements:
Container - WAV
Encoding - PCM
Rate - 16K
Sample Format - 16 bit
Channels - Mono

Stream - Suspiciously large amount of feed updates

We are in the process of integrating Stream to power our notifications module.
When looking at the usage metrics in the dashboard, we see suspiciously large amount of feed updates:
As you can see we have around 9K feed updates per day.
Those daily 9K feed updates don't make sense since right now our backend code does not create any activities.
The only Stream API calls that happen, is when a new user registers we create a new stream for it, of type 'notification', and make this new stream follow a single admin stream which is of type 'flat':
const notifications = client.feed('notifications', userId);
await notifications.follow('user', 'admin');
So for example, if we had today 200 new users who registered, the admin's flat stream will have additional +200 followers.
As of today, we have:
4722 streams of type 'notification'
1 stream of type 'flat'
These are the only interactions we do with Stream's API, and we don't understand what is the source of all those feed updates in the dashboard.
(Maybe these follow commands counts as a feed update?)
We have something happening very similar. We have a dev app for testing, and suddenly 1K "read feed" operation on notification feed group showed up in the log 1 day ago. Its impossible since we haven't rolled the feature out and in case this is the dev app where we did read the feed at most 10 times manually via postman to our backend to getstream.
The correct ops in the log show client as stream-python-client-2.11.0 which makes sense.
The incorrect ops in the log show client as stream-javascript-client-browser-unknown, which does not make sense.
Further the incorrect ops timestamps are all clustered within a short time.
This has not happened since, and has not happened in the production app yet.

AWS Step/Lambda - storing variable between runs

In my first foray into any computing in the cloud, I was able to follow Mark West's instructions on how to use AWS Rekognition to process images from a security camera that are dumped into an S3 bucket and provide a notification if a person was detected. His code was setup for the Raspberry Pi camera but I was able to adapt it to my IP camera by having it FTP the triggered images to my Synology NAS and use CloudSync to mirror it to the S3 bucket. A step function calls Lambda functions per the below figure and I get an email within 15 seconds with a list of labels detected and the image attached.
The problem is the camera will upload one image per second as long the condition is triggered and if there is a lot of activity in front of the camera, I can quickly rack up a few hundred emails.
I'd like to insert a function between make-alert-decision and nodemailer-send-notification that would check to see if an email notification was sent within the last minute and if not, proceed to nodemailer-send-notification right away and if so, store the list of labels, and path to the attachment in an array and then send a single email with all of the attachments once 60 seconds had passed.
I know I have to store the data externally and came across this article explaining the benefits of different methods of caching data and I also thought that I could examine the timestamps of the files uploaded to S3 to compare the time elapsed between the two most recent uploaded files to decide whether to proceed or batch the file for later.
Being completely new to AWS, I am looking for advice on which method makes the most sense from a complexity and cost perspective. I can live with the lag involved in any of methods discussed in the article, just don't know how to proceed as I've never used or even heard of any of the services.
Thanks!
You can use a SQS queue to which the lambda make-alert-decision sends message with each label and path to attachment.
The lambda nodemailer-send-notification would be a consumer of that queue, but being executed on a regular schedule.
You can specify that lambda to be executed every 1 minute, reading all the messages from the queue - and deleting them from the queue right away or setting a visibility time suitable and deleting afterwards - to get the list of attachments and send a single email. We would have a single email with all the attachments every 60 seconds.

Resources