Skip to main content

Quick start

This guide explains creating a basic compositor setup. We will take two input videos and produce an output video with both of them side-by-side.

Configure inputs and output

Start the compositor

import LiveCompositor from "@live-compositor/node"

async function start() {
const compositor = new LiveCompositor();
await compositor.init();
}

Register input stream input_1.

await compositor.registerInput("input_1", {
type: "rtp_stream",
transportProtocol: "tcp_server",
port: 9001,
video: {
decoder: "ffmpeg_h264"
},
audio: {
decoder: "opus"
}
})

After registerInput call is done you can establish the connection and start sending the stream. Check out how to deliver input streams to learn more.

Register input stream input_2.

await compositor.registerInput("input_2", {
type: "rtp_stream",
transportProtocol: "tcp_server",
port: 9002,
video: {
decoder: "ffmpeg_h264"
},
audio: {
decoder: "opus"
}
})

After registerInput call is done you can establish the connection and start sending the stream. Check out how to deliver input streams to learn more.

Register output stream output_1.

Configure it to:

  • render an empty View component with a background color set to #4d4d4d (gray)
  • produce silent audio
function App() {
return <View backgroundColor="#4d4d4d"/>
}

async function start() {
// init code from previous steps

await compositor.registerOutput("output_1", {
type: "rtp_stream",
transportProtocol: "tcp_server",
port: 9003,
video: {
resolution: { width: 1280, height: 720 },
encoder": {
type: "ffmpeg_h264",
preset: "ultrafast"
},
root: <App />
},
audio: {
encoder: {
type: "opus",
channels: "stereo"
},
}
})
}

After registerOutput is done you can establish the connection and start listening for the stream. Check out how to receive output streams to learn more.

View component does not have any children, so on the output you should see just a blank screen of a specified color as shown below. There are no InputStream components in the scene and useAudioInput hook was not used, so output audio will be silent.

Output stream

Update output

Configure it to:

  • Show input streams input_1 and input_2 using Tiles component.
  • Mix audio from input streams input_1 and input_2, where input_1 volume is slightly lowered.
function App() {
return (
<Tiles backgroundColor="#4d4d4d">
<InputStream inputId="input_1" volume={0.9} />
<InputStream inputId="input_2" />
</Tiles>
)
}

Output stream