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
269 stars 56 forks source link

Thumbnail generation for VOD assets #31

Open wizage opened 5 years ago

wizage commented 5 years ago

Is your feature request related to a problem? Please describe. Add a VOD MediaConvert template to VOD solution. This involves creating a custom template.

Describe the solution you'd like Provide a custom template in ./provider-utils/awscloudformation/mc-templates/

Relates to #4

wizage commented 5 years ago

Relates to #18

wizage commented 4 years ago

Where to put thumbnails when you put them? Source bucket, output bucket, a new bucket for thumbnails.

Should this template have special build steps to populate the output bucket variable?

vitalbone commented 3 years ago

How'd you end up going with this, @wizage? I've noticed a few issues referencing the ability to add thumbnails as an output but haven't yet come across a definite guide/example on what a custom template could look like and/or what steps to take.

Would be great for this functionality to be configurable within amplify video. If that's too chunky a task then a guide in the Wiki would be great as well.

I did find this blog post from 2018, and was hoping to reverse engineer a custom template JSON by creating a template via the console. However it's a little too outdated to be useful.

vitalbone commented 3 years ago

How did I miss this page on the Wiki?!

kylekirkby commented 3 years ago

Where to put thumbnails when you put them? Source bucket, output bucket, a new bucket for thumbnails.

Should this template have special build steps to populate the output bucket variable?

Hi @wizage ,

I've added some basic poster image generations settings to my template but I'm now realising that the output bucket name being hard coded in the template is an issue. Is there a way that we can inject the output bucket name into this template?

      {
        "CustomName": "Poster Images",
        "Name": "File Group",
        "Outputs": [
          {
            "ContainerSettings": {
              "Container": "RAW"
            },
            "VideoDescription": {
              "CodecSettings": {
                "Codec": "FRAME_CAPTURE",
                "FrameCaptureSettings": {
                  "FramerateNumerator": 30,
                  "FramerateDenominator": 88,
                  "MaxCaptures": 3,
                  "Quality": 80
                }
              }
            },
            "Extension": ".jpg",
            "NameModifier": "poster-image"
          }
        ],
        "OutputGroupSettings": {
          "Type": "FILE_GROUP_SETTINGS",
          "FileGroupSettings": {
            "Destination": "s3://xxxxxxxxxxxxx-develop-output-xxxxxxx/posters/"
          }
        }
      }
shamikatamazon commented 3 years ago

Hi kylekirby - You can omit the "FileGroupSettings" in the template JSON and add it dynamically using the lambda /provider-utils/awscloudformation/cloudformation-templates/vod-helpers/LambdaFunctions/InputLambda/index.js using code similar to the blurb below.

if (outputTypeList.length === 1) {
    if (outputTypeList[0] === 'HLS') {
      hlsJobSettings.OutputGroups[0].OutputGroupSettings.HlsGroupSettings.Destination = `s3://${outputBucketName}/${FileName}/`;
      hlsJobSettings.Inputs[0].FileInput = `s3://${Bucket}/${decodeURIComponent(AddedKey.replace(/\+/g, ' '))}`;
      jobSettings = hlsJobSettings;
    } else if (outputTypeList[0] === 'DASH') {
      dashJobSettings.OutputGroups[0].OutputGroupSettings.DashIsoGroupSettings.Destination = `s3://${outputBucketName}/${FileName}/`;
      dashJobSettings.Inputs[0].FileInput = `s3://${Bucket}/${decodeURIComponent(AddedKey.replace(/\+/g, ' '))}`;
      jobSettings = dashJobSettings;
    }
  } 

Let me know if that helps !

kylekirkby commented 3 years ago

@shamikatamazon arh! Perfect I'll try this out and report back. Looks ideal :)