

# About multiple-input channels and input switching
About input switching

You set up input switching in a MediaLive channel in order to ingest the inputs in a multiple-input channel. 

**Topics**
+ [

# Multiple-input channels and the schedule
](schedule-and-switching.md)
+ [

# Typical use cases
](typical-use-cases.md)
+ [

# Fixed, immediate, and follow switches
](ips-switch-types.md)
+ [

# Static inputs and dynamic inputs
](how-dynamic-inputs-work.md)
+ [

# Input Prepare
](ips-input-prepare.md)

# Multiple-input channels and the schedule


Input switching in a MediaLive channel works as follows: You create a channel that contains more than one input attachment. After the channel is created, you go into the schedule for that channel and add input switches, to create rules for moving from one input attachment to another. When you start the channel, the channel will automatically switch inputs according to the schedule.

To work successfully with multiple-input channels, remember the following.

**The schedule exists inside the channel**

The schedule does not exist separately from the channel. On the console, you find the schedule in the details page for an existing channel.

**There is no implicit switching**

With a multiple-input channel, you must add input switches to the schedule to instruct the channel to switch. A channel that contains more than one input attachment won't switch to the next input attachment in the list of input attachments unless the schedule specifies to do so.

**There is no "main" input**

With a multiple-input channel, you must think of the input attachments as a *pool* of inputs all with equal status. There isn't one input that is the main input, that the channel returns to when it has nothing else to ingest.

# Typical use cases


Scheduled input switching in a MediaLive channel supports the following use cases.

## Use case 1: One live feed and one file input alternating


You have a channel to process a live (streaming) feed from a specific source, perhaps for a sports tournament. Periodically (perhaps between individual sports events), the live feed should be replaced by file content (perhaps a filler such as a video of ocean waves). After a few minutes, the same live feed should be resumed. 

You set up the channel with one live input and one file input. The first input is the live input. 

Before you start the channel, you create a schedule that consists of actions to switch to the live input at the top of each hour—at 10:00 AM, 11:00 AM, and so on. 

You then start the channel. As soon as each sports event has finished, you modify the schedule "on the spot" to switch to the video filler. The live feed continues for a few moments (perhaps showing the sports crowd or the players leaving the stadium), and then the channel switches to the filler video. At the top of each hour, the channel switches to the live feed.

## Use case 2: One live feed and file inputs, and the channel starts with a file input


You have the same requirements as for use case 1, except that you want to start the channel with a file clip, perhaps from the opening of the sports event. At the top of the first hour, you want to show the video filler. But at the top of the second and succeeding hours, you want to show highlights from earlier in the day.

You set up the channel with one live event (a live input) and several file inputs: one for the opening, one for the video filler, and several for the highlights. The first input is the file input for the opening event. 

Before you start the channel, you create a schedule that contains one action to switch to the live input as soon as the file input has finished. 

You then start the channel. As time goes on, you modify the schedule to add more actions, as for use case 1, to switch back and forth between the live input and the file inputs.

## Use case 3: Two live feeds


You have a channel to process live feed from two different sources. You want to insert ad content into the channel, as required. You want to insert this ad content using MediaLive. (You don't want to insert SCTE-35 messages that a downstream system will read in order to replace the avails with ad content.)

The live feeds might be the venue feed and the in-studio feed for the same sports event. You want to switch from one live feed to the other. You want to time the switches "on the spot" instead of according to a strict clock schedule. Occasionally, you want to switch from one live feed to an ad. When the ad is finished, you might want to return to one of the live feeds.

You set up the channel with two live inputs and several file inputs (one file for each ad). 

Before you start the channel, you create a schedule that contains the first action in the schedule. That action is to switch to the first input, input A, that you want to the channel to ingest. You set the start time for input A to a time that is at least one minute earlier than the time that you start the schedule. You then start the channel. MediaLive immediately reads the schedule and switches to the input that is supposed to be the current action, which is input A. When appropriate, you modify the schedule on the spot to add actions to queue up one or more switches.

## Use case 4: VOD-to-live


You have a channel to process only MP4 file inputs, or mostly MP4 file inputs, on a 24/7 basis. 

You set up the channel with a series of file inputs to run one after another. Each file is encoded from start to finish, and then the next file starts. Sometimes, you want to clip a file and play only part of that file.

You want this channel to run without stopping, until the next scheduled maintenance period, which might be in several weeks. 

To overcome the limit of 20 inputs per channel, you take advantage of the *dynamic input* feature. You create some file inputs with a variable in the place of all or part of the path and file name. You set up the schedule to use this dynamic input over and over again, each time with a different file name slotted into the variable. You can set up several dynamic inputs. 

# Fixed, immediate, and follow switches


In MediaLive, you can categorize input switches according to the start types for the switch. 
+ Fixed – A fixed input switch starts at a specific time.

  Fixed switches use UTC time. They don't use the timecode of the input. 
+ Immediate – An immediate input switch starts as soon as possible. This type of switch is more like a fixed switch than a follow switch because it interrupts the current input. The advantage of this switch over a fixed switch is that you don't have to calculate any buffer in the start time.
+ Follow – A follow input switch starts when the previous input has ended (when MediaLive has reached the end of the file).

This start type is a property of the switch, not a property of the input itself. Therefore, in the schedule you can switch to a specific input with a fixed switch, and then later switch to the same input with a follow switch.

## Types of switches and types of inputs


The combination of types of switches and types of inputs (file and live) means that there are these types of switches:
+ A file input with a fixed start. The previous input can be a file or live input. At the specified start time, MediaLive stops ingesting the previous input and switches to the new input.
+ A file input with an immediate start. The previous input can be a file or a live input. As soon as possible after you enter this switch in the schedule, MediaLive stops ingesting the previous input and switches to the new input. 
+ A file input that follows the previous input. The previous input must be a file input. It can't be a live input because a live input doesn't have an end, so the switch would never occur. 
+ A live input with a fixed start. The previous input can be a file or live input. At the specified start time, MediaLive stops ingesting the previous input and switches to the new input.
+ A live input with an immediate start. The previous input can be a file or a live input. As soon as possible after you enter this switch in the schedule, MediaLive stops ingesting the previous input and switches to the new input. 
+ A live input that follows the previous input. The previous input must be a file input. It can't be a live input because a live input doesn't have an end, so the switch would never occur. 

The following table summarizes the inputs and start types.


| Current Input | Next Input | Possible Start Type | 
| --- | --- | --- | 
| File | File | Fixed or Immediate | 
| File | File | Follow | 
| File | Live | Fixed or Immediate | 
| File | Live | Follow | 
| Live | File | Fixed or Immediate | 
| Live | Live | Fixed or Immediate | 

## Follow chains


A series of follow input switches is called a *follow chain*. When each input ends, MediaLive automatically starts ingesting the next input. Here is a diagram of a follow chain:

```
   Input A    Fixed or Immediate   File
     Input B  Follow               File
     Input C  Follow               File
     Input D  Follow               File or Live
   Input E    Fixed or Immediate   File or Live
```

The follow chain starts with the *reference action*—the input above the first follow. It ends with the last follow input. In the preceding example, the chain starts with the reference action input A and ends with input D. Inputs A, B, and C must be files because they must have a defined ending so that the next input can successfully follow. Input E breaks the chain because it is fixed or immediate.

# Static inputs and dynamic inputs
Dynamic inputs

If your MediaLive channel includes files inputs, you should decide if you want to set up each input as a *static input* or as a *dynamic input*. Using dynamic inputs lets you increase the number of video sources that you can use in the channel, while still observing the limit on the number of inputs that you can attach to the channel. 

You can set up file inputs as static or dynamic inputs. (Live inputs are always static inputs.)

To set up a static input, you specify a standard file URL. For example, `s3ssl://amzn-s3-demo-bucket/my-movie.mp4`.

To set up a dynamic input, you set up the all or part of the file URL with a variable. For example, `s3ssl://amzn-s3-demo-bucket/movies/$urlPath$`. Each time you set up in the schedule to switch to this input, you specify the value for the `$urlPath$`. For example, `s3ssl://amzn-s3-demo-bucket/movies/my-movie.mp4` in one input switch and `s3ssl://amzn-s3-demo-bucket/movies/mlaw.mp4` in another input switch.

You can set up for dynamic content in MP4 file inputs and transport stream (TS) file inputs.

The [procedure for setting up](ips-step-design-inputs.md) for input switching, later in this section, provides detailed information about deciding whether you should set up some inputs as dynamic inputs.

# Input Prepare


The MediaLive schedule includes an input prepare action that is a helper action for input switches. 

For more information about input prepare, see [Preparing inputs in AWS Elemental MediaLive](feature-prepare-input.md).