- Hello, everyone.
My name Smita, and I'm a cloud architect
working in AWS Professional Services team.
And today, I'm gonna talk about
how you can automate video editing using Amazon Rekognition.
So without further ado, let's get started.
So let's understand the use case first.
Here, we have a full video
which has many actors/speakers.
We have Lia, we have Rob, and we have Hubert
talking about different things in the same video.
Now, Lia wants to have just her bits extracted
from the video so that she can share that
on her Facebook page or maybe even on her personal website.
This can be achieved by using a video editor
and then manually scraping all the unwanted bits.
But again, this can get quite time consuming
and quite cumbersome.
So with Amazon Rekognition, which is a cloud-based software
as a service, this will be just few API calls
and very, very simple to achieve.
So let's see how this is done.
First of all,
let's understand the architecture here as well.
The blue color text and the diagram
are the actual API calls.
So I, being the user, I have uploaded the video
and Lia's image in the S3 bucket as the first step.
Now, I will first create a collection
and then request Amazon Rekognition to index Lia's face
with index-face API.
These are the steps here, the second and the third.
I'll be explaining what these APIs do
when we are in the demo section.
But basically, what I'm doing
is I'm just creating a search criteria
for Amazon Rekognition.
After that in the fourth step,
Amazon Rekognition access layer image from the S3 bucket
and then adds the image to the collection we created.
Now in the first face step, I call the StartFaceSearch API
asking Amazon Rekognition to search Lia's bits in the video.
Amazon Rekognition the search in the sixth step.
This is an async search by the way.
And once the search is finished or completed,
Amazon Rekognition posts the completion status
to an SNS topic at step seven.
Which then triggers a lambda function.
A lambda function uses the GetFaceSearch API
of Amazon Rekognition and then gets all the search data
where Lia's face was recognized in the video.
Lambda function then calls CreateJob API
of Amazon Elastic Transcoder
to stitch all these scenes together
so that one video is made containing only Lia's snippets.
And then that video is placed in the same S3 bucket.
So I hope the architecture is clear.
Now what we are gonna do is we are gonna jump
to AWS command line to see all of this in action.
Just before jumping, I'm gonna show you
that we have just taken this video here
which is publicly available in YouTube.
And our different solutions architects
are talking about their life being solution architect.
So I'm just gonna use this video.
So what I've done is I have kept Lia's image
and the video here in my S3 bucket.
So let me jump to the AWS command line.
So the first step is that I'm gonna create a collection.
And I'm giving it a name, just calling my collection.
So what a collection is, it contains information
about faces you want to recognize or search
in pictures and in videos.
But at the moment, this collection is empty.
So what I'm gonna add is I'm gonna add Lia's image
to this collection.
So I have this endpoint, which is index-faces
and I'm gonna specify Lia's image
which is kept in the S3 bucket.
And I'm just gonna give this a friendly name called Lia.
So what index-faces does is it detects face
in the input image, ask them to the specified collection
which we specified here, and in turn, returns some metadata.
So this is returning some metadata.
So once that is done,
now our collection contains Lia's image
and now, we can use our collection to search the video
which is just a very simple API call
called as start-face-search.
So what I'm doing here is I am specifying the video
that I want to search, and I'm giving my collection
which has Lia's image inside it.
And I'm also giving a notification channel
which is my SNS topic.
Topic arm.
And the role arm which I have created
so that I give permission to Rekognition
to post notification to SNS.
And that's it.
Again, this is a asynchronous call
or asynchronous search.
And it search faces in that collection asynchronously
and matches the faces of persons
detected in that store video.
So let me do that now.
So what it does is, is just generates a job ID.
So if you just copy this job ID
and do a GetFaceSearch call, it'll show me
that the search is still being processed
and it's still in progress.
The time depends upon the length of the video.
But again, if you just move back to our architecture diagram
just here, all of this is automated.
We have a lambda function again
and I'm gonna show the lambda code in a minute.
But once Amazon Rekognition pushes the notification
that its job is done to the SNS,
SNS will automatically trigger the lambda function
to just do the further processing.
So nothing is needed from our end
but I'll show what lambda code is there
in the lambda function.
So moving to the console.
So here is my lambda function that's being called
once the Rekognition sends the completion status.
So what it does is it just picks the job ID
that we have there
and then it calls the get-face-search endpoint
which gives all the results of the face search.
And then what it does, it just combines them together here
by using elastictranscoder.
And then specifying what's the name
of the output file that you want.
And the inputs are just the scene where Lia exists.
So just these things here.
And that's it.
So let me go and see if we have a output video created.
I'll just refresh my S3 bucket
because it's just gonna push in the same S3 bucket.
Yeah, we have it, cool.
So I'm just gonna download this.
I'm gonna play it.
So you cannot hear what Lia's saying
but I am able to hear what all of things
that Lia is saying in the video, and we have only her bits
in the video and all the other parts are just scraped off.
Quite cool, isn't it?
So that's it for this session.
Hope you liked it and hope you can utilize the power
of Amazon Rekognition to automate your video editing.
Thank you so much.