Transcoding

Routing a stream directly from an input container to an output container preserves the format of the stream. This is commonly referred to as a pass-through, rewrap or direct convert conversion.

For example the following composition rewraps the input audio stream in an MP4 output container:

---
input:
  container:
  - name: input1
    audio:
    - name: a1
output:
  container:
  - name: output1
    type: 'mp4 '
    audio:
    - name: a1

Stream formats are split into two categories: compressed and uncompressed. Stream operators convert the format between categories or require a format in a specific category.

See Video Formats and Audio Formats for a complete list of compressed and uncompressed format codes.

Stream Decoding

Use the decode operator to explicitly decompress an input stream (i.e. convert from a compressed format to an uncompressed format).

For example the following composition converts the stream to an uncompressed PCM audio format (the specific format will depend on the input stream properties):

---
input:
  container:
  - name: input1
    audio:
    - name: a1
      decode:
output:
  container:
  - name: output1
    type: 'wav '
    audio:
    - name: a1

Transform will automatically decompress the stream when an operator requires an uncompressed format.

For example the following composition uses the mix operator which requires uncompressed audio. In this case a decode operator is implicitly added to input streams a1 and a2.

---
input:
  container:
  - name: input1
    audio:
    - name: a1
    - name: a2
output:
  container:
  - name: output1
    type: 'wav '
    audio:
    - mix:
      - name: a1
      - name: a2

Format Conversion

Use the format property to explicitly change the format of an uncompressed stream. For example the following composition converts the output to 24-bit big-endian PCM in24 format:

---
input:
  container:
  - name: input1
    audio:
    - name: a1
      decode:
output:
  container:
  - name: output1
    type: 'wav '
    audio:
    - name: a1
      format: in24

Transform will automatically convert the format of an uncompressed stream when necessary. For example a conversion is implicitly added when an operator requires a specific uncompressed format.

An uncompressed format may infer other properties (e.g. chroma_subsampling, bit_depth, bits_per_sample, etc.) that determine the fidelity of the stream.

Transform will preserve the fidelity of the stream where possible (i.e. a lossless conversion). When an operator supports multiple formats the highest fidelity conversion is selected.

Stream Encoding

Use the encode operator to explicitly compress an output stream (i.e. convert from an uncompressed format to a compressed format).

The type property identifies a specific compressor implementation. The configuration properties are implementation specific and provide compressor settings such as bit rate, GOP structure, etc.

For example the following composition creates an MP4 output with AVC (using the h264 compressor) and AAC (using the mcac compressor):

---
input:
  container:
  - name: input1
    video:
    - name: v1
    audio:
    - name: a1
output:
  container:
  - name: output1
    type: 'mp4 '
    video:
    - name: v1
      encode:
        type: 'h264'
        properties:
          Profile: main
          BitRate: 3000000
          ClosedGOP: false
    audio:
    - name: a1
      encode:
        type: 'mcac'
        properties:
          Profile: lc
          BitRate: 128000
          MpegVersion: 1
{
  "input": {
    "container": [
      {
        "name": "input1",
        "video": [
          {
            "name": "v1"
          }
        ],
        "audio": [
          {
            "name": "a1"
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "name": "output1",
        "type": "mp4 ",
        "video": [
          {
            "name": "v1",
            "encode": {
              "type": "h264",
              "properties": {
                "Profile": "main",
                "BitRate": 3000000,
                "ClosedGOP": false
              }
            }
          }
        ],
        "audio": [
          {
            "name": "a1",
            "encode": {
              "type": "mcac",
              "properties": {
                "Profile": "lc",
                "BitRate": 128000,
                "MpegVersion": 1
              }
            }
          }
        ]
      }
    ]
  }
}

Note that since the encode operator requires an uncompressed stream a decode operator is implicitly added to input streams v1 and a1.

See the Video Encoders and Audio Encoders reference for the supported compressor types and configuration properties.