Combining Multiple Inputs
Multiple Containers
Multiple input containers are rendered concurrently. For example the following composition combines the picture
and sound
from two separate containers:
---
input:
container:
- name: picture
- name: sound
output:
container:
- name: output1
type: 'mp4 '
{
"input": {
"container": [
{
"name": "picture"
},
{
"name": "sound"
}
]
},
"output": {
"container": [
{
"name": "output1",
"type": "mp4 "
}
]
}
}
Optional Inputs
An input container may be treated as optional
. If the input is not supplied then any output stream referencing that input is removed from the composition.
For example the following composition has an optional subtitle
input:
---
input:
container:
- name: picture
- name: sound
- name: subtitle
optional: true
output:
container:
- name: output1
type: 'mp4 '
{
"input": {
"container": [
{
"name": "picture"
},
{
"name": "sound"
},
{
"name": "subtitle",
"optional": true
}
]
},
"output": {
"container": [
{
"name": "output1",
"type": "mp4 "
}
]
}
}
Multiple Segments
A composition can contain multiple input segments each spanning a portion of the timeline. By default a composition contains a single segment as shown in the previous example.
Multiple input segments are rendered sequentially. For example the following composition renders the preview
container followed by the program
container:
---
input:
segment:
- name: first
container:
- name: preview
- name: second
container:
- name: program
output:
container:
- name: output1
type: 'mp4 '
{
"input": {
"segment": [
{
"name": "first",
"container": [
{
"name": "preview"
}
]
},
{
"name": "second",
"container": [
{
"name": "program"
}
]
}
]
}
}
Multiple Streams
Within a segment (including the default segment) each input stream must be assigned a unique name. Input streams are then routed by name to the output container, for example:
---
input:
container:
- name: picture
video:
- name: v1
audio: []
- name: sound
video: []
audio:
- name: a1
output:
container:
- name: output1
type: 'mp4 '
video:
- name: v1
audio:
- name: a1
{
"input": {
"container": [
{
"name": "picture",
"video": [
{
"name": "v1"
}
],
"audio": []
},
{
"name": "sound",
"video": [],
"audio": [
{
"name": "a1"
}
]
}
]
},
"output": {
"container": [
{
"name": "output1",
"type": "mp4 ",
"video": [
{
"name": "v1"
}
],
"audio": [
{
"name": "a1"
}
]
}
]
}
}
Stitching
Between segments input streams with the same name are joined (or stitched) together, for example:
---
input:
reference: program
segment:
- name: first
container:
- name: preview
video:
- name: v1
audio:
- name: a1
- name: second
container:
- name: program
video:
- name: v1
audio:
- name: a1
output:
container:
- name: output1
type: 'mp4 '
video:
- name: v1
audio:
- name: a1
{
"input": {
"container": [
{
"name": "input",
"path": "input.mov",
"video": [
{
"name": "v1"
}
],
"audio": [
{
"name": "a1"
}
]
}
],
"container": [
{
"name": "overlay",
"path": "overlay.mov",
"video": [
{
"name": "v2"
}
]
}
]
},
"output": {
"container": [
{
"type": "mp4 ",
"name": "output",
"path": "output.mp4",
"video": [
{
"overlay": [
{
"name": "v1",
"name": "v2"
}
]
}
],
"audio": [
{
"route": {
"name": "a1"
}
}
]
}
]
}
}
Reference Container
In a composition with multiple containers the reference
container provides the default values for media properties such as width
, height
, sample_rate
etc.
For example in the previous composition the preview
container will be converted (if necessary) to match the properties of the reference program
container.
Mixed Composition
Streams in the default segment are rendered concurrently with streams stitched together by the timeline segments.
For example the following composition renders a logo
over both the preview
and program
segments. Additionally spanish
subtitles are add to the program
segment.
---
input:
container:
- name: logo
segment:
- name: first
container:
- name: preview
video:
- name: v1
audio:
- name: a1
- name: second
container:
- name: program
video:
- name: v1
audio:
- name: a1
- name: spanish
subtitle:
- name: s1
output:
container:
- name: output1
type: 'mp4 '
video:
- name: v1
overlay:
- name: logo
audio:
- name: a1
subtitle:
- name: s1
{
"input": {
"container": [
{
"name": "logo"
}
],
"segment": [
{
"name": "first",
"container": [
{
"name": "preview",
"video": [
{
"name": "v1"
}
],
"audio": [
{
"name": "a1"
}
]
}
]
},
{
"name": "second",
"container": [
{
"name": "program",
"video": [
{
"name": "v1"
}
],
"audio": [
{
"name": "a1"
}
]
},
{
"name": "spanish",
"subtitle": [
{
"name": "s1"
}
]
}
]
}
]
},
"output": {
"container": [
{
"name": "output1",
"type": "mp4 ",
"video": [
{
"name": "v1",
"overlay": [
{
"name": "logo"
}
]
}
],
"audio": [
{
"name": "a1"
}
],
"subtitle": [
{
"name": "s1"
}
]
}
]
}
}
Updated about 1 year ago