On this page
DocsGuides
Background music
Mix a music track under the original sound at the level you choose.
audio.mix puts more sound under the output's own: a music bed under a voice. The original keeps
its level and the output ends with the video.
The request#
curl "$VIDEXO_API_URL/v1/transcode" \
-H "Authorization: Bearer $VIDEXO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "https://example.com/talk.mp4",
"filename": "talk-music.mp4",
"extra_inputs": {
"music": "https://example.com/music.mp3"
},
"video": {
"codec": "copy"
},
"audio": {
"mix": [
{
"input": "music",
"volume": 0.2
}
]
}
}'Copy failed. The text is selected; copy it with your keyboard.
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/talk.mp4",
"filename": "talk-music.mp4",
"extra_inputs": {
"music": "https://example.com/music.mp3"
},
"video": {
"codec": "copy"
},
"audio": {
"mix": [
{
"input": "music",
"volume": 0.2
}
]
}
}),
});
const job = await response.json();Copy failed. The text is selected; copy it with your keyboard.
ffmpeg \
-i https://example.com/talk.mp4 \
-i https://example.com/music.mp3 \
-filter_complex "[1:a]volume=0.2[o0m0];[0:a:0][o0m0]amix=inputs=2:duration=first:normalize=0[o0a]" \
-map 0:v:0 \
-c:v copy \
-map "[o0a]" \
-c:a aac -b:a 128k -movflags +faststart \
talk-music.mp4Copy failed. The text is selected; copy it with your keyboard.
talk-music.mp4: the same picture, the music at a fifth of its volume under the voice, ending with the video.
The music is an extra input (extra_inputs on a per-operation endpoint, or another entry in
inputs on POST /v1/jobs); volume sets its level, 0.2 is a fifth.
A video without sound#
Mixing needs an audio track to mix under. For a silent video, take the sound from the music instead; the output ends with the video, the music cut there or padded with silence:
curl "$VIDEXO_API_URL/v1/transcode" \
-H "Authorization: Bearer $VIDEXO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "https://example.com/talk.mp4",
"filename": "slideshow.mp4",
"extra_inputs": {
"music": "https://example.com/music.mp3"
},
"video": {
"codec": "copy"
},
"audio": {
"input": "music"
}
}'Copy failed. The text is selected; copy it with your keyboard.
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/talk.mp4",
"filename": "slideshow.mp4",
"extra_inputs": {
"music": "https://example.com/music.mp3"
},
"video": {
"codec": "copy"
},
"audio": {
"input": "music"
}
}),
});
const job = await response.json();Copy failed. The text is selected; copy it with your keyboard.
ffmpeg \
-i https://example.com/talk.mp4 \
-i https://example.com/music.mp3 \
-map 0:v:0 \
-c:v copy \
-map 1:a:0 \
-af apad \
-c:a aac -b:a 128k -shortest -movflags +faststart \
slideshow.mp4Copy failed. The text is selected; copy it with your keyboard.