On this page
DocsGuides
Picture in picture
Place a second video, scaled down, in a corner of the first.
An overlay can be a video: a camera over a screen recording, a reaction over the clip it reacts to.
The request#
bash
curl "$VIDEXO_API_URL/v1/transcode" \
-H "Authorization: Bearer $VIDEXO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "https://example.com/screen.mp4",
"filename": "lesson.mp4",
"extra_inputs": {
"camera": "https://example.com/camera.mp4"
},
"overlays": [
{
"input": "camera",
"position": "top-right",
"margin": 32,
"width": 480
}
],
"audio": {
"input": "camera"
}
}'Copy failed. The text is selected; copy it with your keyboard.
JavaScript
const response = await fetch(`${process.env.VIDEXO_API_URL}/v1/transcode`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VIDEXO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input": "https://example.com/screen.mp4",
"filename": "lesson.mp4",
"extra_inputs": {
"camera": "https://example.com/camera.mp4"
},
"overlays": [
{
"input": "camera",
"position": "top-right",
"margin": 32,
"width": 480
}
],
"audio": {
"input": "camera"
}
}),
});
const job = await response.json();Copy failed. The text is selected; copy it with your keyboard.
bash
ffmpeg \
-i https://example.com/screen.mp4 \
-i https://example.com/camera.mp4 \
-filter_complex "[0:v:0]scale='min(trunc(iw/2)*2,min(7680,min(trunc(7680*iw/ih/2)*2,trunc(sqrt(33554432*iw/ih)/2)*2)))':-2[o0s0];[1:v]scale=480:7680:force_original_aspect_ratio=decrease,tpad=stop=-1:stop_mode=clone[o0l0];[o0s0][o0l0]overlay=x=W-w-32:y=32:shortest=1[o0s1]" \
-map "[o0s1]" \
-c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p \
-map 1:a:0 \
-af apad \
-c:a aac -b:a 128k -shortest -movflags +faststart \
lesson.mp4Copy failed. The text is selected; copy it with your keyboard.
lesson.mp4: the screen recording with the camera 480 pixels wide in the top right, 32 pixels in, and the camera’s sound.
audio.input takes the sound from the camera. Without it the output keeps the main video's sound.
The output ends with the main video: a longer camera is cut there, and a shorter one holds its last
picture (end hides it) while its sound is padded with silence.