

# Working with timecodes and timestamps
Timecodes and timestampsTimecode burnin

The user guide now includes information about burning the timecode into output video.Timecode configuration

The section about timecode has been renamed to timecodes and timestamps. The section has also been revised to clarify how timecode works in MediaLive.

MediaLive has timecodes for the input pipeline and the output pipeline. The two timecodes are separate from each other. You can't configure the input timecode. You can configure the behavior of the output timecode. You can also configure output to include the output timecode as metadata and/or to burn the output timecode into the video frame.

**Topics**
+ [

# About timecodes and timestamps
](timecodes-about.md)
+ [

# Configuring the start time for the output timecode
](timecode-configure-source.md)
+ [

# Including timecode metadata in the output
](timecode-configure-metadata.md)
+ [

# Burning the timecode into output
](timecode-configure-burnin.md)

# About timecodes and timestamps


MediaLive has timecodes for the input pipeline and the output pipeline. The two timecodes are separate from each other.

**Input timecode**

MediaLive has features that work only if incoming frames include embedded timecodes. These features include pipeline locking and watermarking. If an input doesn't have an embedded timecode, MediaLive won't implement the feature. For example, with pipeline locking, the pipelines won't get locked in a frame accurate way. (For more information about how the timecode affects pipeline locking, see [Implementing pipeline locking](pipeline-lock.md).

The input timecode source is not configurable. 

**Output timecode**

MediaLive implements SMPTE timecode, which means that MediaLive assigns a timecode of the format `HH:MM:SS:FF` to each outgoing frame. The timecode rolls over at midnight.

There are three ways to initialize the output timecode in a channel: 
+ Embedded (the default): Use the embedded timecode to initialize the output timecode. MediaLive uses the timecode in the first frame that it ingests in the input. If the input does not contain a timecode, MediaLive uses UTC. 
+ UTC: Initialize the output timecode to the UTC time at the moment that the first frame enters the output side of the pipeline.
+ Zero-based: Initialize the output timecode to 00:00:00:00.

The output timecode is used in features such as the PDT for an HLS output, and for the timecode for ID3 metadata that you might choose to include. You can also configure output to include the output timecode as metadata and/or to burn the output timecode into the video frame.

You can also configure output video to include the [output timecode as metadata](timecode-configure-metadata.md), and/or to [burn the output timecode](timecode-configure-burnin.md) into the video frame.

**Timestamps**

MediaLive attaches a timestamp to all output content. Downstream systems use the timestamp for synchronization. The timestamp is a value such as the number of 90 KHz clock cycles.

Don't conflate timestamps and timecodes. They are different.

# Configuring the start time for the output timecode
Configuring output timecode

You can configure the start time for the output timecode that MediaLive includes in output encodes.

**Note**  
This procedure assumes that you are familiar with creating or editing a channel, as described in [Creating a channel from scratch](creating-channel-scratch.md).

1. On the **Create Channel** page, in the **General settings** section, choose **Timecode configuration**.

1. In **Source**, choose the option for initializing the timecode in the output: 
   + **EMBEDDED** – Use the timecode embedded in the source video. 

     MediaLive looks for the timecode in the source video, as follows:
     + AV1 – A timecode inserted in a metadata OBU of type timecode (METADATA\$1TYPE\$1TIMECODE), in accordance with section 5.8.3 of the AOM AV1 specification (https://aomediacodec.github.io/av1-spec/)
     + H.264 – A timecode inserted in an SEI message of type pic\$1timing, in accordance with section D.1.2 of ISO/IEC 14496-10-2005
     + H.265 – A timecode inserted in an SEI message of type timecode, in accordance with section D.2.26 of ITU-T H.265
     + MPEG-2 – A timecode inserted in each GOP header, in accordance with section 6.2.2.6 of ISO/IEC 13818-2-2000 (R2006)
   + **SYSTEMCLOCK**– Use the UTC time. 
   + **ZEROBASED** – Use 00:00:00:00. 

1. (Optional) In **Sync threshold**, enter a threshold (in frames) for synchronizing the output timecode to the input timecode. For information about this field, see [About the synchronization threshold](#timecode-sync).

## How the output timecode works at runtime


**Initial channel start or restart**

When you start the channel, the channel establishes the start timecode for the output pipeline:
+ The channel samples the input timecode, if you set up the start time to reference the embedded timecode. If MediaLive doesn't find an embedded timecode in the source, it falls back to UTC. 
+ Or it sets the timecode to the current UTC time.
+ Or it sets the timecode to 00:00:00:00.

The channel generates a new timecode for each output frame that it produces. 

**Input switches**

When the channel switches to a different input, MediaLive doesn't reinitialize the timecode. Therefore, the output timecode isn't disrupted by an [input switch](scheduled-input-switching.md).

**Pausing and unpausing**

If you pause the channel, MediaLive continues to encode frames, which it immediately discards. But because MediaLive continues to encode, the timecodes continue to increment. Therefore, when you unpause, there will be a timecode discontinuity in the output.

## About the synchronization threshold


The timecode **Sync threshold** field synchronizes the output timecode with the input timecode. Drift can occur in several ways. For example, processing issues can occur that cause MediaLive to drop or repeat frames to compensate. Or there might be discontinuities in the input timecode stream.

**Purpose of synchronization**

Synchronization is useful if it is important for your workflow that the output timecode (that MediaLive generates) match the original input timecode. 
+ Matching might be important if you know that the downstream system must identify specific frames. 

  Typically, the downstream system has already identified these frames based on the original input timecode. Therefore, the output timecode must match the original input timecode, in order for the downstream system to find the desired frame.
+ Matching isn't important if the main purpose of the output timecode is simply to uniquely identify each output frame.

**How synchronization works**

After the input timecode and the output timecode have drifted apart by the specified number of frames, MediaLive inserts a discontinuity in the output timecode sequence, and sets the output timecode to match the current input timecode.

The main drawbacks of synchronizing are that it introduces timecode discontinuities into the metadata, and that it can't guarantee that each output timecode is unique. 

# Including timecode metadata in the output
Timecode metadata

You can set up a MediaLive channel to include timecode metadata in the individual output encode. Timecode metadata is supported in any type of output group except Frame Capture. 

The timecode is inserted according to the standard for the output encode: 
+ AV1 – The timecode is inserted in a metadata OBU of type timecode (METADATA\$1TYPE\$1TIMECODE), in accordance with section 5.8.3 of the AOM AV1 specification (https://aomediacodec.github.io/av1-spec/)
+ H.264 – The timecode is inserted in an SEI message of type pic\$1timing, in accordance with section D.1.2 of ISO/IEC 14496-10-2005
+ H.265 – The timecode is inserted in an SEI message of type timecode, in accordance with section D.2.26 of ITU-T H.265
+ MPEG – The timecode is inserted in each GOP header, in accordance with section 6.2.2.6 of ISO/IEC 13818-2-2000 (R2006)

**To include timecode metadata in the output**

On the output side, in each video encode, you specify whether to include the timecode. By default, the timecode is not included in the video encode.

1. On the **Create Channel **page, in the **Output groups **section, choose an output group, then choose an output.

1. Display the **Stream settings **section, and then choose the **Video **section. In **Codec settings**, choose the codec for this video encode. More fields appear.

1. Choose **Timecode**, then in **Timecode insertion**, choose an option:
   + **DISABLED** – This encode won't include timecode metadata.
   + **METADATA\$1OBU** (for AV1) or **PIC\$1TIMING\$1SEI** (for H.264 or H.265) or **GOP\$1timecode** (MPEG) – This encode will include timecode metadata.

# Burning the timecode into output
Timecode burnin

You can set up any video encode in a MediaLive channel to burn in the output timecode. The time code will become part of the video.

Note that the timecode burnin feature is independent of the timecode metadata feature. You don't have to enable timecode metadata in order to burn in the timecode.

**To burn the timecode into the video output**

1. On the **Create Channel **page, in the **Output groups **section, choose an output group, then choose an output.

1. Display the **Stream settings **section, and then choose the **Video **section. In **Codec settings**, choose the codec for this video encode. More fields appear.

1. Choose **Timecode**, then in **Timecode burn-in settings**, choose **Timecode burnin**. More fields appear.

1. Set the style and position of the timecode in the video frame. In the optional **Prefix** field, enter any descriptor. For example, **UTC-1**.