Forum

Introducing Image I...
 
Notifications
Clear all
1 Posts
1 Users
0 Likes
8,668 Views
Posts: 108
Topic starter
(@taichi)
Member
Joined: 4 years ago

Image Insertion and Input Switching with AWS Elemental MediaLive

In this lab, you will insert static images (also referred to as graphic or video overlay) over a video stream, create multiple inputs and attach those inputs to a MediaLive channel, and switch between multiple inputs.

 

 

SPL-234 - Version 1.0.0

 

Lab Overview

When streaming live video events, it is common to switch between different inputs. For example:

  • Switching from a live stream to a pre-recorded file, then back to the live stream.
  • Switching between different video feeds, in the case of a multi-venue live event.

It may also be useful (or required) to overlay an image or text over the live stream to:

  • Identify the owner or source of content that is being streamed, by overlaying a logo, watermark or some other image onto the video.
  • Denote live or pre-recorded content by overlaying text onto the stream.
  • Promote upcoming events, or some other call to action.
  • Provide a phone number or web address.

In this lab, you will:

  • Insert static images (also referred to as graphic or video overlay) over a video stream
  • Create multiple inputs and attach those inputs to a MediaLive channel
  • Switch between multiple inputs

During the lab setup, an AWS CloudFormation template will create a live streaming workflow.

basic-flow

1 Source content is fed into an AWS Elemental MediaLive channel which takes that input

2 and compresses that it into multiple lower-resolution versions that are suitable for streaming over the internet.

3 MediaLive feeds the compressed streams into AWS Elemental MediaPackage

4 which will temporarily cache the video and then package it and serve it up to viewers upon request.

In actual practice, to serve hundreds, thousands, or millions of simultaneous viewers, the packaged video streams need to be fanned out through large distribution networks. This is called a content delivery network (CDN). Amazon CloudFront is a CDN. To save time in this lab you will not create a CloudFront distribution. Instead you will play the video directly from MediaPackage.

5 In this lab, the sources will be files in an Amazon S3 bucket, playing in a loop to simulate a live feed. You will use the Schedule function in MediaLive to insert static images over the video (also called video overlay), and to switch between multiple inputs.

image-input-2

Topics Covered

By the end of this lab, you will be able to:

  • Insert static images over a video stream
  • Create multiple inputs
  • Attach multiple inputs to a MediaLive channel
  • Switch between multiple inputs during playback of the live stream

Technical Knowledge Prerequisites

This lab is built upon a live streaming workflow that was created in the Building a Live Video Channel with MediaLive, MediaPackage and Amazon CloudFront self-paced lab (SPL-207).

To successfully complete this lab, you should be familiar with the basic procedures of building a live streaming workflow using AWS Elemental Media Services, including:

  • Connecting a MediaLive input to a MediaLive channel
  • Configuring a MediaLive channel
  • Configuring a MediaPackage channel
  • Playing video from a MediaPackage channel

You should also be familiar with the basic navigation of the AWS Management Console.

  •  

Task 1: View the live streaming workflow

In this task you will start the MediaLive channel that was automatically created by the CloudFormation template, and validate playout from MediaPackage.

  1. In the AWS Management Console, click on the Services menu, then click MediaLive.

This will take you to the MediaLive page.

  1. Click Services again, then right-click MediaPackage and choose Open link in new tab.

A new tab will appear for MediaPackage, but you will still be in the Services dropdown.

  1. Click close near the bottom of the Services menu.

  2. In the AWS Elemental MediaLive navigation panel, click Inputs.

 If Inputs is not visible, click the Navigation icon  and then select Inputs from the list.

Note that the State of the input is  Attached. This means that the input is feeding into the MediaLive channel, where it will be transcoded according to the instructions in the channel.

  1. From the navigation pane on the left, select Channels.

    Note that the State of the channel is Idle.

  2. Click the Name of the channel to view the channel details.

     The name will look like this: qls-129148-215039265242e4b2-livestream.

    In the Status section, you can see that an input is attached and that there are zero pipelines running.

    By default, MediaLive works in a redundant mode, outputting two identical streams. The pipelines represent the two redundant outputs. They are not in a primary/backup relationship--both pipelines are active outputs.

  3. Click Start

    The Channel state is now starting. After approximately two minutes, the Channel state will change to  Running, at which point MediaLive will be ingesting the input source and encoding it.

    Note that there are now two pipelines running (the dual outputs), indicating that the channel is running normally.

  4. Click the Destinations tab.

    In the Destinations section, note that there are two pipeline destinations (MediaLive channels are redundant by default) which point to MediaPackage.

    mp-destinations

  5. Navigate to the MediaPackage console you opened earlier.

  6. In the Channels section, under ID, click the link of the MediaPackage channel.

    This takes you to the details page of the MediaPackage channel.

    Note the Endpoints section.

     A MediaPackage endpoint is the location where the video segments coming from the encoder (MediaLive) are cached. When a player device requests video, it originates from this location.

    This channel has an Apple HLS endpoint. Apple HLS is an adaptive bitrate (ABR) packaging format.

    When ABR packaging is used, the compressed video streams are packaged into segments, usually 2-10 seconds each. This allows video players to adapt to fluctuating network conditions by requesting successive segments from the list of available resolutions/bitrates.

There are two ways to check playback of the stream from MediaPackage:

  1. Click the Play link in the Endpoints section, then click the  Play icon.

    After a few seconds of playback, close the built-in player.

  2. In the Endpoints section, under URL, highlight and copy the URL and paste into an internet browser.

    To use:

  • Safari: Paste the URL into a Safari browser and play.

  • Microsoft Edge: Paste the URL into the Address bar and select Enter.

  • Chrome or another browser: Use JW Player Stream Tester

    Leave the playback window open for later use.

You have now validated that the live streaming workflow is running. In the following tasks, you will configure MediaLive to insert static video overlays and switch between multiple inputs.

Task 2: Insert static images into the live stream (video overlay)

video-frame

 The terms static image and graphic are sometimes used interchangeably in the context of image insertion. In this lab we will use the term static image.

Static images are overlaid on the video stream using the Schedule function in MediaLive.

Schedules can be created ahead of time (before the channel is started) or created while the channel is playing.

 If created while the channel is running, the start times have to be at least 15 seconds in the future.

In this task you will create image insertion actions while the channel is playing.
Several attributes can be specified:

  • The path to the static image file itself (required)
  • The time when the static image should appear (required)
  • Its position in the video frame, the X and Y dimensions (distance from left and top of the video frame)
  • The dimensions of the image
  • Its duration on screen (i.e. when should it disappear)
  • Fade on/off or cut on/off

You can resize the static image and to set its position relative to the video frame by entering values in the appropriate fields in the console.

However, the best practice is to use a graphics editing application to build the static image the full size of the video frame, placing the static image to be superimposed in the correct position relative to the frame, and making background transparent. In this case, the image does not need to be resized and can be overlaid directly on the video frame, with no X-Y offset.

The image files provided for this lab have been built this way.

To see an example of a static image built into the lower right corner of a 1280x720 frame, click here:

Image example

xy-offset

This static image is in the correct aspect ratio (16:9) but it still might need to be resized to match the size of the input.

Therefore you also need to know the frame size (resolution) of your input, e.g., 1920 x 1080, 1280 x 720, 960 x 540, etc.

In this task, the resolution of your input is . You will need this information later.

  1. Navigate to the MediaLive console that you opened earlier.

  2. Click Schedule.

  3. Click Create then configure:

  • Action name: 
  • Start type: Fixed - The Follow start type is used with input switching and will be explained later in this lab.
  • Action type: Static Image Activate
  • URL:
 https://s3-us-west-2.amazonaws.com/aws-tc-largeobjects/SPLs/234/graphics/aws-1280x720.png 

 The static images provided in this lab are built to a frame size of 1280x720.

  1. Configure the rest of the static image fields as follows:
  • Layer: Leave blank.

    Up to eight layers can be superimposed--for example, a colored banner across the bottoon of the frame (Layer 0) and some text (Layer 1) overlaid on of that. In this lab you are using only one layer.

  • Image X and Image Y: Leave blank.

    These are the distances (in pixels) the image is offset from the left top corner. Since the static image you are using is full frame size, there is no offset.

  • Opacity: Leave blank. Default is 100% opaque.

  • Width: 

  • Height: 

    The static image itself is at the correct aspect ratio (16x9) but its actual size is 1280x720 thus it needs to be scaled up to match the size of the input.

  • Duration: Leave blank.

    The static image will appear for the full duration of the stream.

  • Fade-in: 

    The value is in milliseconds so you will be creating a one-second fade in.

  • Fade-out: Leave blank. This value will be used in a later task.

  1. Scroll back up to the Time (UTC) field.

The static image will be inserted at a UTC time that you specify.

  1. To get the correct UTC time, search the internet for a UTC time display e.g.,  https://time.is/UTC .

Resize the window so that you can read the time and still see the MediaLive console.

You are creating this scheduled event while the channel is running. Therefore, the time for image insertion has to be at least 15 seconds ahead of the current UTC time.

  1. Click in the Time (UTC) field and use the scroll bars to select a time that is at least 15 seconds in the future.

insert-time

  1. Scroll to the bottom and click Create

MediaLive will insert the static image at the specified UTC time. You will see the result in the playback window 45-120 seconds later. This is the standard latency inherent in live streams due to factors such as encoding settings, output type and network speeds.

Next you will make the static image fade out.

  1. Click Create then configure:
  • Action name: 
  • Start type: Fixed
  • Action type: Static Image Deactivate
  • Layer: Leave blank. If you had superimposed multiple layers, you could specify which to fade out.
  • Fade out:  - The Fade out value is in milliseconds so you will be creating a one-second fade out.
  • Time (UTC): Use the scroll bars to select a time that is at least 15 seconds in the future
  • Click Create

MediaLive will fade out the static image at the specified UTC time. You will see the result in the playback window 45-120 seconds later.

 Scheduled actions cannot be edited or modified after you create them. If you need to change something in the settings, for example the start time, delete the action and re-create it.

  1. Select  the box by the action you want to delete.

  2. In the Secheduled actions section, click the Actions button.

  3. Under Modify, select Delete (n) action(s).

delete-action

Another way to view the list of scheduled actions is the Timeline view.

  1. Click Switch to timeline view and explore that view.

Task 3: Switch between multiple inputs

Typical use cases for input switching are:

  • Switching between live action and pre-recorded content
  • Switching among live streams from different venues
  • Running a playlist of pre-recorded files

There are three steps for input switching in MediaLive:

  • Creating multiple inputs
  • Attaching those inputs to a channel
  • Scheduling the input switches

Input switching actions can be scheduled before the channel has started, or during the stream.

 The start time for actions scheduled while the channel is running have to be at least 15 seconds in the future.

In this task you will initiate switches while the channel is running.

Create multiple inputs

You will create three additional inputs using short (1 minute duration) MP4 files that will be played in a loop, to simulate live feeds.

  1. In the navigation panel at left, click Inputs.

 If Inputs is not visible, click the Navigation icon  and then select Inputs from the list.

  1. Click Create input

  2. Under Input name, enter 

 It is a good practice to put the resolution (Width x Height in pixels) of the input into the Input name so that if a static image is going to be overlaid you know what size it needs to be scaled to.

  1. Select  MP4.

  2. Under Input source A URL and Input source B URL, enter

 https://s3-us-west-2.amazonaws.com/aws-tc-largeobjects/SPLs/234/video/1-min-timbers-1920x1080.mp4 

 For the purposes of this lab you are using same source for both of the redundant inputs. In actual practice you would use two identical, but distinct sources.

  1. Click Create

  2. In the navigation pane, click Inputs.

  3. Click Create input then configure:

  • Input name: 
  • Input type:  MP4
  • Input source A URL and Input source B URL:
 https://s3-us-west-2.amazonaws.com/aws-tc-largeobjects/SPLs/234/video/1-min-bunny-1920x1080.mp4 
  1. Click Create

  2. In the navigation pane, click Inputs.

  3. Click Create input then configure:

  • Input name: 
  • Input type:  MP4
  • Input source A URL and Input source B URL:
 https://s3-us-west-2.amazonaws.com/aws-tc-largeobjects/SPLs/234/video/1-min-moto-1920x1080.mp4 
  1. Click Create

  2. In the navigation panel, click Inputs.

There are now four inputs. Only one is attached to the channel. In the next step you will attach the other inputs to the channel.

Attach multiple inputs to the channel

  1. In the navigation panel at left, click Channels.

  2. Select the channel  and click Stop

Wait for the channel to go to the Idle state (approximately 60 seconds).

  1. Click Actions and then click Edit.

  2. In the Channel section, next to Input attachments, click Add then configure:

  • Input: Select one of the additional inputs you created:
    • motocross_1920x1080
    • bunny_1920x1080
    • timbers_1920x1080
  • Click Confirm
  • Under General input settings, set Source End Behavior to LOOP

The inputs for this lab are short MP4 files (~1 minute duration). In order to simulate a continuous input, the files will now play in a loop.

  1. Repeat the previous step to attach the remaining inputs to the channel.

  2. Scroll to the bottom of the page and click Update channel

  3. Select the channel  and click Start

Wait for the channel state to show  Running

Schedule input switch actions

  1. On the Channels page, click the name of your channel to view the channel details.

  2. Click the Schedule tab.

  3. Click Create then configure:

  • Action name: 
  • Start type: Fixed
  • Action type: Input Switch
  • Input switch: timbers_1920x1080
  • Time (UTC): use the scroll bars to select a time that is at least 15 seconds in the future
  • Click Create

MediaLive will switch to the new input at the specified UTC time. You will see the result in the playback window 45-120 seconds later.

  1. Repeat the above series of steps starting with Create to schedule switches between the various inputs.
  • ...

It isn't necessary to create switch actions for all the inputs. If you feel you understand the concept and procedure after doing a couple of switches, you can move on to the next task.

Task 4: Create and run a playlist using multiple inputs

In this use case, a series of input files are going to be played back-to-back with no gap between and without requiring manual switching. This is sometimes called running a playlist. The schedule will be created while the channel is idle, then the channel will be started and the files will play in sequence.

For this lab, the input files are short (1 minute duration) so that the switching is more timely.

Modify the end behavior of the inputs

In the previous task, you set the Source end behavior to Loop. This was done to simulate a continuous input. However, in this task the behavior will be changed so that when the file is finished, it will not go back to the beginning.

  1. In MediaLive, click Stop

Wait for the Channel state to show Idle.

  1. Click Actions and select Edit.

  2. In the Channel section, under Input attachments select the first input.

  3. Under General input settings, Source End Behavior, select CONTINUE.

Under the CONTINUE setting, the file will stop playing when the end is reached. This is necessary for the Follow function in the schedule, which you will create in this task.

  1. Click on the next input and change Source End Behavior from LOOP to CONTINUE.

Do this for each input.

  1. Scroll to the bottom of the page and click Update channel

Schedule input switches between the various inputs

  1. Click the Schedule tab.

  2. Clear the list of old actions by checking the box at top of the list, then click Actions and select Delete (n) action(s).

  3. In the Delete schedule action dialog , click Delete

  4. Click Create then configure:

  • Action name: 
  • Start type: Fixed - The first input action in the list needs to be a fixed start because nothing precedes it, thus there is nothing for it to follow.
  • Action type: Input Switch
  • Input switch: select the input with the word livestream in it
  • Time (UTC) use the scroll bars to set a time several minutes in the future

This is to give you lead time to configure the rest of switches and to allow for the channel startup, which can take up to 4 minutes.

  1. Click Create

  2. Click Create then configure:

  • Action name: 
  • Start type: Follow - With this setting, when the first input file reaches its end, the channel will automatically switch to the next configured input.
  • Reference action name: Select the input that this new one will follow, i.e. the input right before it. In this case, the only selection available is start playlist.
  • Action type: Input Switch
  • Input switch: 
  • Click Create
  1. Repeat the process above to add additionals additional switches to the list.
  • ...
  1. After scheduling a few follow-type input switches, click Start near the upper right of the page.

  2. Refresh the link in the video player.

Approximately 45-120 seconds after the first UTC switch time that you specified, you will clean switches from one input to the next in your playlist. These are the Follow type switches being executed.

It is also common to combine input switches and image insertion actions. For example the live action could have a text banner reading Live. When the input is switched to another input, like a pre-recorded interview, the first static image could fade out, and a new static image could fade in.

Refer to the online documentation for AWS MediaLive for further details.

Conclusion

 Congratulations! You now have successfully:

  • Inserted a static image onto a live video stream
  • Created multiple inputs in MediaLive
  • Attached multiple inputs to a MediaLive channel
  • Switched between multiple inputs during playback

Thank you.

End Lab

Follow these steps to close the console, end your lab, and evaluate the experience.

  1. Return to the AWS Management Console.

  2. On the navigation bar, click awsstudent@<AccountNumber>, and then click Sign Out.

  3. Click End Lab

  4. Click OK

  5. (Optional):

  • Select the applicable number of stars 
  • Type a comment
  • Click Submit

    • 1 star = Very dissatisfied
    • 2 stars = Dissatisfied
    • 3 stars = Neutral
    • 4 stars = Satisfied
    • 5 stars = Very satisfied

You may close the dialog if you don't want to provide feedback.

Additional Resources

For feedback, suggestions, or corrections, please email us at [email protected].

 

 

Share: