awslabs / amplify-video

An open source Category Plugin for the AWS Amplify-CLI that makes it easy to deploy live and file based streaming video services and integrate them into your Amplify applications.
https://www.npmjs.com/package/amplify-category-video
Apache License 2.0
267 stars 56 forks source link

Correct Way of Uploading/Processing Media? #258

Open git-goblin opened 3 years ago

git-goblin commented 3 years ago

Note: If your question is regarding the AWS Amplify Console service, please log it in the official AWS Amplify Console forum

Which Category is your question related to?

amplify-video

What AWS Services are you utilizing?

AppSync, DynamoDB, Lambda, MediaConvert, EventBridge

Provide additional details e.g. code snippets

Hi!

Firstly, thank you for supporting this awesome project! Amplify is awesome!

Forgive me if this is in the wrong area or marked incorrectly - this is a question with a potential feature requests.

Issue #160, is this something that will be implemented soon or is it a non-issue?

Let me explain, from my understanding in the documentation and UnicornFlix demo, we handle the upload in the browser but we also set the Video Object and the VOD Asset in the client browser - is this good practice?

I often ask if it's good practice or not, I'm not a full-time dev but some things strike me as non-ideal ways of implementing things so I would greatly appreciate the feedback from those who are more experienced 😊.

Tried having a go at setting up a Lambda function to trigger when EventBridge detected a "SUCCESS" result from MediaConvert but none of the events (input, processing, failure, etc) return any details about the filename.

My goal was to have the Lambda function run the GraphQL mutation to create the VOD Asset once the upload and processing were successful.

One hack-y solution was to extract the filename from the file path in the event - is that good practise?

On the client end, there would be a subscription to retrieve the VOD Assets and only the successful ones or the ones processed so far would show.

The alternative was to set the Video Object and the VOD Asset in the client browser and set some sort of field for "processed" to get updated once the processing is complete.

Following on from this, would it be possible to add a feature request to automatically delete files from the input bucket when they've been successfully uploaded?

For now, with the events from MediaConvert, it returns the source bucket and file path, it should be possible to do.

Last question, is there a best practice for handling failed or partial uploads?

Following the documentation, we'll have a Video Object and VOD Asset created by GraphQL/AppSync in the client browser but a failed upload will still persist in S3 and the user will not be able to view their clips.

Thank you in advance and stay awesome!

wizage commented 3 years ago

Hey @git-goblin

This is something we want to add. I can take a stab at this week to see what I can add in.

But in the meantime I still think that EventBridge is overkill for this solution.

It is better to use the built in SNS functionality of MediaConvert to trigger a Lambda. (The SNS contains a lot of info laid out in the docs here

For this flow, do you expect to have a function if you only choose add an API? Or should we build this function even if without a API and let users modify the function? @smp thoughts on this part?

git-goblin commented 3 years ago

Hi @wizage,

Wasn't expecting a reply so soon, thank you!

Thank you for the suggestion of using SNS, that seems like a better approach, really appreciate that feedback!

That's a good question. Would it be possible to add that as an option when setting up amplify-video?

It would be nice if there was an option for example: "Do you want Amplify to create Video Objects/VOD Assets remotely?".

The wording could be tweaked but the end goal being that a Lambda function will create the Video Objects/VOD Assets without us needing to do so.

From my understanding (please correct me if I'm wrong), when setting up amplify-video a new API is created for us if we don't have one already, makes sense to include the function if the user selects to have the details created remotely by Amplify.

Keep up the good work!

kervonryan commented 3 years ago

Hey @wizage whats the latest on this?

shamikatamazon commented 3 years ago

Hi @kervonryan - I'm currently working on this and am hoping to have an initial version ready by the end of this week. I'll keep you updated as I make progress

kervonryan commented 3 years ago

@shamikatamazon Thanks for this!