Giter Site home page Giter Site logo

aws-samples / aws-media-services-simple-live-workflow Goto Github PK

View Code? Open in Web Editor NEW
170.0 22.0 65.0 10.38 MB

Workshop that covers AWS Elemental MediaLive, MediaPackage, and MediaTailor services

License: Apache License 2.0

JavaScript 5.76% HTML 6.74% Shell 1.66% Python 85.84%

aws-media-services-simple-live-workflow's Introduction

AWS Live Streaming and Live-to-VOD Workshop

This workshop guides the student through creation of a streaming video workflow using an encoder in the cloud to produce adaptive bitrate (ABR) content and a packager to deliver the ABR streams to one or more viewers, including mobile devices and desktop browsers. This workshop includes a browser page configured as a simple client viewer, which the student can customize with their own streaming media and take advantage of live and delayed playback, and restart capabilities of the packager and player to replay portions of the video.

This workshop includes an optional module for configuring AWS CloudWatch Metrics and Alarms to track services usage from a graphical dashboard.

Workshop Modules

  1. AWS IAM - This module guides the participant in configuring permissions for the AWS services used in this workshop. You will learn how to create a policy that permits access to AWS Elemental MediaLive in your account and you will attach the policy to a role that you will use in your AWS Elemental MediaLive channel definitions.

  2. AWS Elemental MediaPackage - This module guides the participant in configuring a video origin service in the cloud using AWS Elemental MediaPackage. You will learn how to create channels for ingesting live video from AWS Elemental MediaLive and create endpoints for viewing video from browsers and mobile devices. In the following module, you will connect AWS Elemental MediaLive to AWS Elemental MediaPackage to create the end-to-end workflow.

  3. AWS Elemental MediaLive - This module guides the participant in configuring a streaming source for live video. You will learn how to create input sources and channels in AWS Elemental MediaLive, and connect channels between AWS Elemental MediaPackage and AWS Elemental MediaLive. At the end of this module, the participant will have created a video service accessible by standalone video players, such as QuickTime, VLC or a hosted player in a web page.

  4. Browser Page - This module guides the participant in customizing a browser page with an embedded player to stream video from AWS Elemental Media Services. The participant will learn aspects of streaming video to a browser and gain a basic understanding of the open source tools for building web sites that can stream live video.

  5. AWS Elemental MediaTailor - This module guides the participant in configuring MediaTailor to insert advertisements into your streaming video. The participant will also learn how to deliver the video content with ads through Amazon CloudFront. This module assumes that MediaLive and MediaPackage channels have been set up by walking through Modules 2 and 3, or having run the CloudFormation templates first.

  6. Extra: AWS CloudWatch - This module guides the participant in customizing a dashboard with metrics to monitor the flow of data through the services. The particpant will learn about CloudWatch metrics, dashboards and alarms in the context of monitoring streaming video status in near real time.

AWS CloudFormation Templates

CloudFormation templates are available if you would like to move faster or see the intended outcome of a single module or the entire lab. Resources created by AWS CloudFormation will have unique naming patterns so that the same template can be used multiple times in teh same account and region without conflicting resource names. Resource names are prefixed with the stack name, template name, a short random string, and followed by the resource name. See the following example for AWS Elemental MediaLive channels created with these templates. The stack names CHAN05 and CHAN07 are specified by the user and prefixed to the channel name. The CloudFormation template name is also included in the naming.

alt

Keep this convention in mind when locating resources created with these templates.

Following are links to CloudFormation templates for each module of the workshop. Copy the link address and use that with CloudFormation to create the module contents in your account. You may need to enter information into the CloudFormation template about resources created in previous modules. If you are not familiar with AWS CloudFormation, review the online User Guide.

These templates are supported in regions: ap-northeast-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 eu-central-1 eu-west-1 eu-west-3 sa-east-1 us-east-1 us-west-2.

However, enabling MediaTailor will only work in the regions that the service is available.

Start the Workshop

Download a copy of this workshop to your computer if you want to complete the final module called Browser Page. Otherwise, you can follow this workshop online to complete the modules.

Move forward to the first module for AWS IAM.

aws-media-services-simple-live-workflow's People

Contributors

cfehring avatar dboekee avatar dependabot[bot] avatar hyandell avatar jimtharioamazon avatar morjoan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-media-services-simple-live-workflow's Issues

Update templates for MediaPackage dual-ingest

MediaPackage supports dual ingest URLs to match dual pipelines coming from MediaLive. We need to update template to:

Create one MediaPackage channel
Connect each MediaLive pipeline to each ingest URL from MediaPackage

Use MediaLive templates

Add support to include steps for MediaLive templates. This can be an extra module, or a separate path from the MediaLive module.

Using type RTMP instead of HLS when creating MediaLive Inputs

def create_input(medialive, event, context, auto_id=True):
"""
Create a MediaLive input
"""

if auto_id:
    input_id = "%s-%s" % (resource_tools.stack_name(event),
                          event["LogicalResourceId"])
else:
    input_id = event["PhysicalResourceId"]

try:
    response = medialive.create_input(
        Name=input_id,
        Type='URL_PULL',
        Sources=[
            {'Url': event["ResourceProperties"]["HLSPrimarySource"]},
            {'Url': event["ResourceProperties"]["HLSSecondarySource"]}
        ]
    )

    print(json.dumps(response))

    # wait for the new input to reach detached state
    resource_tools.wait_for_input_states(medialive, response['Input']['Id'], ['DETACHED'])

    result = {
        'Status': 'SUCCESS',
        'Data': response,
        'ResourceId': response['Input']['Id']
    }

except Exception as ex:
    print(ex)
    result = {
        'Status': 'FAILED',
        'Data': {"Exception": str(ex)},
        'ResourceId': response['Input']['Id']
    }

return result

Do I change the following from

    try:
        response = medialive.create_input(
            Name=input_id,
            Type='URL_PULL',
            Sources=[
                {'Url': event["ResourceProperties"]["HLSPrimarySource"]},
                {'Url': event["ResourceProperties"]["HLSSecondarySource"]}
            ]
        )

to something like this:

        response = medialive.create_input(
            Name=input_id,
            Type='RTMP_PUSH',
            InputSecurityGroups=[
                '3525785',
            ]
            Destination=[
                {'"StreamName": "live/stream"}
            ]
        )

CFN : Could not connect to the endpoint URL: \"https://api.mediatailor.eu-west-3.amazonaws.com/playbackConfiguration\

Deployment of this cloudformation template Entire Workshop: https://s3-us-west-2.amazonaws.com/rodeolabz-us-west-2/cloudformation/LiveStreamingWorkshopResources.json

Region : eu-west-3

Error Cloudformation

| MediaTailorConfigResource | CREATE_FAILED | Failed to create resource. See the details in CloudWatch Log Stream: 2020/06/30/[$LATEST]0db51831fbf846238c8c15009f5f6c2a

Full logs from the Cloudwatch log group : /aws/lambda/LiveToVodWorkshop-MediaTailorModul-EMTConfigLambda-xxx

{
    "Status": "FAILED",
    "Reason": "See the details in CloudWatch Log Stream: 2020/06/30/[$LATEST]0db51831fbf846238c8c15009f5f6c2a",
    "PhysicalResourceId": "LiveToVodWorkshop-MediaTailorModuleStack-3NVPPYKBN9Z2-MediaTailorConfigResource",
    "StackId": "arn:aws:cloudformation:eu-west-3:xxx:stack/LiveToVodWorkshop-MediaTailorModuleStack-xxx/xx-bab8-11ea-8b98-0e1f48a18a9e",
    "RequestId": "xx-e628-483c-9667-xx",
    "LogicalResourceId": "MediaTailorConfigResource",
    "Data": {
        "Exception": "Could not connect to the endpoint URL: \"https://api.mediatailor.eu-west-3.amazonaws.com/playbackConfiguration\""
    }
}

Iam role issues

Error
UnprocessableEntityException
Please check your IAM User permissions the following permissions are needed for this call
"medialive:CreateChannel","iam:PassRole"

But i have attached the policy in iam

Update IAM instructions for role creation

Instead of creating the MediaLive Access role separately through IAM, update the instructions to just use the "one button click" from MediaLive console to create this role instead.

Make bucket name a parameter to the CF templates

Today we have rodeolabz hardcoded as the bucket name for the hosted templates and Lambda code. We would like to turn that into a parameter, so that user's creating their own custom distribution can host from their buckets without modifying the template code.

Pricing: AWS Transfer Family ($.30 per hour - SFTP Endpoint fee)

I have created POC for Live Streaming (Europe Ireland region):

  • AWS MediaLive
  • AWS MediaPackage

I have used live streaming for max 30-40 minutes. After my testing of live streaming, I had deleted MediaPackage Endpoint and Stopped the MediaLive Channel.

After 24 hours I charged:

  • MediaLive: $0.89
  • MediaPackage: $0.04
  • Transfer Family (AWS Transfer Family EU-ENDPOINT - $.30 per hour - SFTP Endpoint fee: 432.000 Hourly) - $129.60 (?????)

No used:
AWS CloudFront

Why below charges?
Transfer Family (AWS Transfer Family EU-ENDPOINT - $.30 per hour - SFTP Endpoint fee: 432.000 Hourly) - $129.60

Any alternate solution?

BufferSegment in EML

Buffer Segment by default in set to 5 but because this is an HLS file as source it should be removed, otherwise the complete file is not played only the number of segments specified on the EML input configuration

Audio during streaming is laggy

Hi! I am Android Developer and trying to make rtmp stream from android device using AWS MediaLive. But during implementation in my project I faced next issue : audio is flickering when streaming by rtmp. I am using this this library as rtmp publisher in my project. By the way I tried lots of another libs and solution from google play and each one's sound was flickering more or less.

My configurations for rtmp are

AUDIO_BITRATE: Int = 2500 * 1024
SAMPLE_RATE: Int = 44100

I would also like to notice that video during streaming is good, with no lags

Maybe you can help to figure out? Thanks!

AWS MediaLive Cloudformation Fn::GetAtt get array value

I am building a Cloudformation template for Media Live I have everything working with the AWS PHP SDK. I create a MediaPackage channel and return the data to be used in the next call.

Return example.

(
    [Arn] => arn:aws:mediapackage:us-east-1:000000000000:channels/000000000000
    [Description] => Tests
    [HlsIngest] => Array
        (
            [IngestEndpoints] => Array
                (
                    [0] => Array
                        (
                            [Id] => 000000000000
                            [Password] => 000000000000
                            [Url] => https://000000000000.mediapackage.us-east-1.amazonaws.com/in/v2/1e803c424d2947f58c07d9a6a5ff3d31/000000000000/channel
                            [Username] => 000000000000
                        )

                    [1] => Array
                        (
                            [Id] => 000000000000
                            [Password] => 000000000000
                            [Url] => https://2bcff136c2fbf1e5.mediapackage.us-east-1.amazonaws.com/in/v2/000000000000/10392b8387fd442eae56f29ac2656837/channel
                            [Username] => 000000000000
                        )

                )

        )

    [Id] => sdv
    [Tags] => Array
        (
        )
)

I can then use these values in PHP like this.

$destinationOneUrl      = $createChannel['HlsIngest']['IngestEndpoints'][0]['Url'];
$destinationOnePassword = $createChannel['HlsIngest']['IngestEndpoints'][0]['Password'];
$destinationOneUsername = $createChannel['HlsIngest']['IngestEndpoints'][0]['Username'];

And use these when creating the media live channel.

"Destinations": [
		    {
		      "Id": "destination1",
		      "Settings": [
		        {
		          	"Url": "' . $destinationOneUrl . '",
		          	"Username": "' . $destinationOneUsername . '",
          			"PasswordParam": "' . $streamName . '"
		        },
		      ]
		    }
		  ],

Which works but with Cloudformation you have to use the Fn::GetAtt like this.

"Destinations": [{
                    "Id": "destination1",
                    "Settings": [{
                            "Url": {
                                "Fn::GetAtt": ["MediaPackageChannel", "HlsIngest"]
                            },
                            "Username": {
                                "Fn::GetAtt": ["MediaPackageChannel", "HlsIngest"]
                            },
                            "PasswordParam": {
                                "Fn::GetAtt": ["MediaPackageChannel", "HlsIngest"]
                            },
                        },
                        {
                            "Url": {
                                "Fn::GetAtt": ["MediaPackageChannel", "HlsIngest"]
                            },
                            "Username": {
                                "Fn::GetAtt": ["MediaPackageChannel", "HlsIngest"]
                            },
                            "PasswordParam": {
                                "Fn::GetAtt": ["MediaPackageChannel", "HlsIngest"]
                            },
                        }
                    ]
                }],

You cannot go into the array with Fn::GetAtt is there another function that can be used in combination with the Fn::GetAtt to get the inner values.

Something along these lines

"Fn::GetAtt": ["MediaPackageChannel", "HlsIngest['IngestEndpoints'][0]['Url']"]

Here is my full template its hard to explain but basically I need to attach my medialive channel to the mediapackage channel as I mention I have done with the php code above Cloudformation doesn't make this easy.

You will see the Destinations section line 39 I need to populate the Url, Username, PasswordParam with the returned values from the mediapackage channel creation.

https://gist.github.com/samueleastdev/03b050f937855a81f36bb1e3260aa5d3

I started with this template https://docs.aws.amazon.com/solutions/latest/live-streaming/template.html and I am trying to do it myself they use custom lambda functions within the template so maybe it is not possible without lambda.

Any suggestions or help.

"Entire Workshop" Does Not build MediaTailor

Ahoy! Deployed the 'entire workshop' template today, but it did not launch anything MediaTailor related as the documentation implies. Two solutions:

  • update doc to specify that lab 5 is not included
  • update template to include mediatailor

Previewing Stream in MediaPackage console. get error 'Sorry, something went wrong'

Following along with this lab and got to the 4-BroswerPage module.

  1. Navigate to the AWS Elemental MediaPackage console.
    2 ) Select the channel you created previously.
    3 )Find the origin endpoint on the channel page.
    4 ) Click the Play link under the Preview column to test with the embedded player
    Afer clicking Play on the first/second endpoint.
    tried in both safari and chrome. same error on both.

Screen Shot 2019-09-05 at 10 00 08 AM
Screen Shot 2019-09-05 at 10 01 03 AM

BufferSegments change in MediaLive

default value for BufferSegments to 5 in the console (HLS input attachments) so now when the customer loops the input they only get the last 5 segments in the manifest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.