Video and Image Overlays

Video Overlay

Use the overlay operator to combine multiple video input streams.

The opacity operator determines the opacity (or transparency) of an input stream relative to the background. opacity is set as a decimal value between 0.0 and 1.0 where 1.0 is 100% opaque and 0.0 is fully transparent.

The scale operator determines the size of the an input stream relative to the output image dimensions. Like opacity, scale.horizontal and scale.vertical are also set as decimal values between 0.0 and 1.0.

The translate operator determines the position of an input stream relative to the output image dimensions. translate.horizontal and translate.vertical are set as a decimals between -1.0 and 1.0. For example, (-1.0, 0.0) centers the frame on the left border and (0.0, 1.0) centers the frame on the top border.

For example the following composition combines the background and foreground inputs with a 75% opacity:

---
input:
  container:
  - name: background
    video:
    - name: v1
  - name: foreground
    video:
    - name: v2
      opacity: 0.75
output:
  container:
  - name: output1
    type: 'mp4 '
    video:
    - overlay:
      - name: v1
      - name: v2
{
  "input": {
    "container": [
      {
        "name": "background",
        "video": [
          {
            "name": "v1"
          }
        ]
      },
      {
        "name": "foreground",
        "video": [
          {
            "name": "v2",
            "opacity": 0.75
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "name": "output1",
        "type": "mp4 ",
        "video": [
          {
            "overlay": [
              {
                "name": "v1"
              },
              {
                "name": "v2"
              }
            ]
          }
        ]
      }
    ]
  }
}

Image Overlay

An image container displays a still image (e.g. PNG, JPEG).

Specify the start time for the image relative to the background stream. By default an image starts at the beginning of the composition (or segment).

Specify the duration that the image is displayed. By default an image spans the entire duration of the composition or segment.

For example the following composition overlays the logo image for 30 seconds starting at 10 seconds into the composition:

---
input:
  segment:
  - name: default
    container:
    - name: program
      video:
      - name: v1
    - name: logo
      start: '00:00:10:00'
      duration: '00:00:30:00'
      video:
      - name: v2
output:
  container:
  - name: output1
    type: 'mp4 '
    video:
    - overlay:
      - name: v1
      - name: v2
{
  "input": {
    "segment": [
      {
        "name": "default",
        "container": [
          {
            "name": "program",
            "video": [
              {
                "name": "v1"
              }
            ]
          },
          {
            "name": "logo",
            "start": "00:00:10:00",
            "duration": "00:00:30:00",
            "video": [
              {
                "name": "v2"
              }
            ]
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "name": "output1",
        "type": "mp4 ",
        "video": [
          {
            "overlay": [
              {
                "name": "v1"
              },
              {
                "name": "v2"
              }
            ]
          }
        ]
      }
    ]
  }
}

The following composition applies an image overlay that begins at 1 second, ends after 4 seconds, is 50% transparent and is scaled and positioned on top of the foreground video.

---
input:
  container:
    name: VideoInput
    video:
    - name: Background
      select:
        track: 1
  reference: VideoInput
  segment:
  - container:
      name: ImageInput
      start: '00:00:01.000'
      end: '00:00:04.000'
      video:
      - name: Foreground
        opacity: 0.5
        scale:
          horizontal: 0.6
          interpolator: lanczos
          mode: fill
          vertical: 0.4
        translate:
          horizontal: 0.2
          vertical: 0.5
output:
  container:
  - type: 'mp4 '
    name: Output
    video:
    - name: VideoOutput
      properties:
        Format: h264
      overlay:
      - name: Background
      - name: Foreground
{
   "input": {
      "container": {
         "name": "VideoInput",
         "video": [
            {
               "name": "Background",
               "select": {
                  "track": 1
               }
            }
         ]
      },
      "reference": "VideoInput",
      "segment": [
         {
            "container": {
               "name": "ImageInput",
               "start": "00:00:01.000",
               "end": "00:00:04.000",
               "video": [
                  {
                     "name": "Foreground",
                     "opacity": 0.5,
                     "scale": {
                        "horizontal": 0.6,
                        "interpolator": "lanczos",
                        "mode": "fill",
                        "vertical": 0.4
                     },
                     "translate": {
                        "horizontal": 0.2,
                        "vertical": 0.5
                     }
                  }
               ]
            }
         }
      ]
   },
   "output": {
      "container": [
         {
            "type": "mp4 ",
            "name": "Output",
            "video": [
               {
                  "name": "VideoOutput",
                  "properties": {
                     "Format": "h264"
                  },
                  "overlay": [
                     {
                        "name": "Background"
                     },
                     {
                        "name": "Foreground"
                     }
                  ]
               }
            ]
         }
      ]
   }
}

Fade-in / Fade-out

Many of the operators for overlays can be used with either video inputs or image inputs. Both video overlays and image overlays can be set to fade-in and / or fade-out.

The following composition applies a 5 second image overlay to the video output. The image overlay fades-in for 2 seconds, and then fades out during the last second.

---
input:
  reference: VideoInput
  segment:
  - container:
    - name: VideoInput
      video:
      - name: v1
    - name: ImageInput
      video:
      - name: v2
        duration: 5
        head:
          duration: 2
          opacity: 0
        body:
          opacity: 1
        tail:
          duration: 1
          opacity: 0
output:
  container:
  - type: 'mp4 '
    name: Output
    video:
    - name: v2
      encode:
        type: appr
        properties:
          OutputFormat: apcn
      overlay:
      - name: v1
      - name: v2
{
   "input":{
      "reference":"VideoInput",
      "segment":[
         {
            "container":[
               {
                  "name":"VideoInput",
                  "video":[
                     {
                        "name":"v1"
                     }
                  ]
               },
               {
                  "name":"ImageInput",
                  "video":[
                     {
                        "name":"v2",
                        "duration":5,
                        "head":{
                           "duration":2,
                           "opacity":0
                        },
                        "body":{
                           "opacity":1
                        },
                        "tail":{
                           "duration":1,
                           "opacity":0
                        }
                     }
                  ]
               }
            ]
         }
      ]
   },
   "output":{
      "container":[
         {
            "type":"mp4 ",
            "name":"Output",
            "video":[
               {
                  "name":"v2",
                  "encode":{
                     "type":"appr",
                     "properties":{
                        "OutputFormat":"apcn"
                     }
                  },
                  "overlay":[
                     {
                        "name":"v1"
                     },
                     {
                        "name":"v2"
                     }
                  ]
               }
            ]
         }
      ]
   }
}

Overlay Start Time

The start time property for video overlays and image overlays has different behavior. For image inputs, the start time specifies when the image overlay will begin to appear in the output. For video inputs, the start time can be used to trim the beginning of the video input before it is overlayed on top of the output.

Video overlays always begin at the beginning of the segment.

Overlay End Time

When set, the end time determines how long the overlay will be displayed. If not set, then the overlay will be displayed for the entire segment duration, or if it’s a video input and the video input is shorter than the segment, then the video overlay will end when the video overlay input’s duration ends.

The end time gets converted to a duration value for the input. If start time is also specified, then the duration value is the end time minus the start time.