

# Using variables in your job settings
<a name="using-variables-in-your-job-settings"></a>

You can use variables, also called *format identifiers*, in your job settings. Format identifiers are values that you can put in your job settings that resolve differently in your outputs depending on the characteristics of the input files or the job. They are particularly useful in output presets, job templates, and jobs that you intend to duplicate and re-use. Note that variables are case sensitive.

For example, you might use the date format identifier `$d$` for your **Destination** setting. If you want your outputs organized by the date and time that the job starts, for **Destination** you might enter **s3://amzn-s3-demo-bucket1/\$1d\$1/**. For a job that starts June 4, 2020, the service will create your outputs in `s3://amzn-s3-demo-bucket1/20200604/`.

For a list of the available format identifiers and examples of how to use them, see [List of settings variables with examples](#list-of-settings-variables-with-examples).

For information about format identifiers that function differently in streaming outputs, see [Using settings variables with streaming outputs](#using-settings-variables-with-streaming-outputs).

**Topics**
+ [List of settings variables with examples](#list-of-settings-variables-with-examples)
+ [Using settings variables with streaming outputs](#using-settings-variables-with-streaming-outputs)
+ [Specifying a minimum number of digits](#specifying-a-minimum-number-of-digits)

## List of settings variables with examples
<a name="list-of-settings-variables-with-examples"></a>

The following table provides information about each of the format identifiers that you can use in your AWS Elemental MediaConvert job. For information about format identifiers that function differently in streaming outputs, see [Using settings variables with streaming outputs](#using-settings-variables-with-streaming-outputs).


| Format identifier | Value to put in the job setting | Compatible job settings | Description and example | 
| --- |--- |--- |--- |
| Date and time |  `$dt$`  |  Destination Name modifier Segment modifier  |  UTC date and time of the start time of the job. Format: YYYYMMDDTHHMMSS Example: For a job that starts at 3:05:28 PM on June 4, 2020, **\$1dt\$1** resolves to `20200604T150528`.   | 
| Date |  `$d$`  |  Destination Name modifier Segment modifier  |  UTC date of the start time of the job.  Format: YYYYMMDD Example: For a job that starts on June 4, 2020, **\$1d\$1** resolves to `20200604`.   | 
| Time |  `$t$`  |  Destination Name modifier Segment modifier  |  UTC start time of the job.  Format: HHMMSS Example: For a job that starts at 3:05:28 PM, **\$1t\$1** resolves to `150528`.   | 
| Video bitrate |  `$rv$`  |  Name modifier Segment modifier  |  The video bitrate of the output, in kilobits. For QVBR outputs, the service uses video max bitrate, in kilobits. Example: If you set **Encoding settings**, **Video**, **Bitrate (bits/s)** to **50000000**, **\$1rv\$1** resolves to `50000`.  | 
| Audio bitrate |  `$ra$`  |  Name modifier Segment modifier  |  Total of all the audio bitrates in the output, in kilobits. Example: If you have an output with a single audio tab and you set **Encoding settings**, **Audio 1**, **Bitrate (kbit/s)** to **256000**, **\$1ra\$1** resolves to `256000`.  | 
| Container bitrate |  `$rc$`  |  Name modifier Segment modifier  |  Combined audio and video bitrate for the output, in kilobits. Example: You have an output with a **Video** settings tab and **Audio 1** settings tab. If you set **Encoding settings**, **Video**, **Bitrate (bits/s)** to **5000000** and you set **Encoding settings**, **Audio**, **Bitrate (bits/s)** to **96000** (96 kilobits), **\$1rc\$1** resolves to `5096`.  | 
| Video frame width |  `$w$`  |  Name modifier Segment modifier  |  The frame width, or horizontal resolution, in pixels. Example: If you set **Encoding settings**, **Video**, **Resolution (w x h)** to **1280** x **720** , **\$1w\$1** resolves to `1280`.  | 
| Video frame height |  `$h$`  |  Name modifier Segment modifier  |  The frame height, or vertical resolution, in pixels. Example: If you set **Encoding settings**, **Video**, **Resolution (w x h)** to **1280** x **720** , **\$1h\$1** resolves to `720`.  | 
| Framerate |  `$f$`  |  Name modifier Segment modifier  |  Framerate, in frames per second, truncated to the nearest whole number.  Example: If your framerate is **59.940**, **\$1f\$1** resolves to `59`.   | 
| Input file name |  `$fn$`  |  Destination Name modifier Segment modifier  |  Name of the input file, without the file extension. For jobs that have multiple inputs, this is the first file specified in the job. Example: If **Input 1** for your job is **s3://amzn-s3-demo-bucket/my-video.mov**, **\$1fn\$1** resolves to `my-video`.  | 
| Output container file extension |  `$ex$`  |  Name modifier Segment modifier  |  Varies depending on the output group. For **File group** outputs, this is the extension of the output container file. For other output groups, this is the extension of the manifest. Example for file group: If you choose **MPEG2-TS** for **Output settings**, **Container**, **\$1ex\$1** resolves to `m2ts`. Example for HLS group: If your output group is HLS, **\$1ex\$1** resolves to `m3u8`.  | 
| \$1 |  `$$`  |  Name modifier Segment modifier  |  Escaped `$`. Example:  Suppose that you provide the following values:    Input file name: **file1.mp4**   Destination: **s3://amzn-s3-demo-bucket/**   Name modifier: **my-video\$1\$1hi-res-**   Your output file name and path resolves to `s3://amzn-s3-demo-bucket/my-video$hi-res-file1.mp4`.  | 

## Using settings variables with streaming outputs
<a name="using-settings-variables-with-streaming-outputs"></a>

Variables in your job settings, also called *format identifiers*, function differently for outputs in Apple HLS and DASH ISO output groups. Here are the differences:

**For Apple HLS Outputs**  
When you use the date and time format identifiers (`$dt$`, `$t$`, `$d$`) in the **Segment modifier** setting, these format identifiers resolve to the completion time of each segment, rather than to the start time of the job.

**Note**  
For jobs that use accelerated transcoding, segments might complete at the same time. This means that date and time format identifiers don't always resolve to unique values.

**For DASH ISO Outputs**  
You can use two additional format identifiers in the **Name modifier** setting. These affect the DASH manifest in addition to the output file name. Here are the identifiers:

\$1Number\$1  
In your output file names, `$Number$` resolves to a series of numbers that increment from 1. This replaces the default, nine-digit segment numbering in the segment file names. For example:   
+ If you specify **video\$1\$1Number\$1** for **Name modifier**, the service creates segment files named `video_1.mp4`, `video_2.mp4`, and so on.
+ If you specify only **video\$1** for **Name modifier**, the service creates segment files named `video_000000001.mp4`, `video_000000002.mp4`, and so on.
In your DASH manifest, AWS Elemental MediaConvert includes `duration` and `startNumber` inside the `SegmentTemplate` element, like this: `<SegmentTemplate timescale="90000" media="main_video_$Number$.mp4" initialization="main_video_$Number$init.mp4" duration="3375000"/>`  
If you use the `$Number$` format identifier in an output, you must also use it in every other output of the output group.

\$1Bandwidth\$1   
In your output file names, `$Bandwidth$` resolves to the value of **Video**, **Bitrate** plus the value of **Audio**, **Bitrate** in the output. Regardless of whether you include this format identifier, the service uses nine-digit segment numbering in the segment file names.  
For example, suppose you specify these values:  
+ **Video**, **Bitrate (bits/s)**: **50000000** 
+  **Audio**, **Bitrate (kbits/s)**: **96.0** (96,000 bits/s)
+ **Name modifier**: **video\$1\$1Bandwidth\$1**
The value for \$1Bandwidth\$1 resolves to 50,096,000. The service creates segment files named `video_50096000_000000001.mp4`, `video_50096000_000000002.mp4`, and so on.  
In the manifest, AWS Elemental MediaConvert includes `duration` and `startNumber` inside the `SegmentTemplate` element, like this: `<SegmentTemplate timescale="90000" media="main_video_$Bandwidth$.mp4" initialization="main_video_$Bandwidth$init.mp4" duration="3375000"/>`.

\$1Time\$1  
In your output file names, `$Time$` resolves to the duration, in milliseconds, of the segment. When you include this format identifier, the service doesn't use the default nine-digit segment numbering in the segment file names.  
For example, if you specify **video180\$1\$1\$1Time\$1** for **Name modifier**, the service creates segment files named `video180__345600.mp4`, `video180__331680.mp4`, and so on. In these examples, the segment durations are 345,600 ms and 331,680 ms.  
In the manifest, AWS Elemental MediaConvert includes `SegmentTimeline` inside the `SegmentTemplate` element, like this:   

```
<Representation id="5" width="320" height="180" bandwidth="200000" codecs="avc1.4d400c">
        <SegmentTemplate media="video180_$Time$.mp4" initialization="videovideo180_init.mp4">
          <SegmentTimeline>
            <S t="0" d="345600" r="2"/>
            <S t="1036800" d="316800"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
```
If you use the `$Time$` format identifier in an output, you must also use it in every other output of the output group.

\$1RepresentationID\$1  
In your output file names, `$RepresentationID$` resolves to an output's numerical order in your job settings .  
In the manifest, AWS Elemental MediaConvert uses this identifier in the `SegmentTemplate` element to reference the correct paths for each representation.  
This format identifier is particularly useful when you need to organize your DASH outputs by representation ID.

## Specifying a minimum number of digits
<a name="specifying-a-minimum-number-of-digits"></a>

For format identifiers that return a number, you can specify a minimum number of digits that the format identifier will resolve to. When you do, the service adds padding zeros before any value that would return fewer digits.

Use the following syntax to specify the number of digits: **%0[number of digits]**. Put this value just before the final `$` of the format identifier.

For example, suppose that your video frame height is 720 and you want to specify a minimum of four digits, so that it appears in your file name as `0720`. To do that, use the following format identifier: **\$1h%04\$1**.

**Note**  
Values that are too large to be expressed in the number of digits you specify resolve with more digits.