ReelSDK adds a music track to any video with one POST /v1/ffmpeg call at $0.02 per compute minute, so 30 s of video costs under a tenth of a cent. The track loops, sits at 30% volume, dips under the video's own audio and fades out over 3 s.
Add music to video API
Yes: ReelSDK lays a music bed under speech in one request. The picture is copied instead of re-encoded, so a 30-second 1080p video needs about 2 seconds of compute.
Use casesUpdated
The request
POST /v1/ffmpeg
Mix a looped music track under a video's own audio with ducking and a fade-out in one ffmpeg call, for a fraction of a cent.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"launch.mp4": "https://api.reelsdk.com/f/lib/in/use-cases/launch.mp4",
"music.mp3": "https://api.reelsdk.com/f/lib/music/cinematic/spring-on-the-horizon.mp3"
},
"args": [
"-i", "launch.mp4", "-stream_loop", "-1", "-i", "music.mp3",
"-filter_complex",
"[0:a]asplit=2[voice][key];[1:a]volume=0.3,afade=t=out:st=27:d=3[music];[music][key]sidechaincompress=threshold=0.01:ratio=8:attack=20:release=400[ducked];[voice][ducked]amix=inputs=2:duration=first:normalize=0,alimiter=limit=0.95[mix]",
"-map", "0:v", "-map", "[mix]", "-c:v", "copy", "-c:a", "aac", "-b:a",
"192k", "-shortest", "-movflags", "+faststart", "with-music.mp4"
],
"outputs": ["with-music.mp4"]
}'const res = await fetch("https://api.reelsdk.com/v1/ffmpeg?wait=60", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.REELSDK_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"inputs": {
"launch.mp4": "https://api.reelsdk.com/f/lib/in/use-cases/launch.mp4",
"music.mp3": "https://api.reelsdk.com/f/lib/music/cinematic/spring-on-the-horizon.mp3"
},
"args": [
"-i", "launch.mp4", "-stream_loop", "-1", "-i", "music.mp3",
"-filter_complex",
"[0:a]asplit=2[voice][key];[1:a]volume=0.3,afade=t=out:st=27:d=3[music];[music][key]sidechaincompress=threshold=0.01:ratio=8:attack=20:release=400[ducked];[voice][ducked]amix=inputs=2:duration=first:normalize=0,alimiter=limit=0.95[mix]",
"-map", "0:v", "-map", "[mix]", "-c:v", "copy", "-c:a", "aac", "-b:a",
"192k", "-shortest", "-movflags", "+faststart", "with-music.mp4"
],
"outputs": ["with-music.mp4"]
}),
});
const { job } = await res.json();{
"job": {
"id": "job_uhk5lz7dvgfru0k7qku8",
"op": "ffmpeg",
"status": "succeeded",
"stage": null,
"created_at": "2026-11-07T01:24:00.420Z",
"finished_at": "2026-11-07T01:24:04.766Z",
"outputs": {
"with-music.mp4": "https://api.reelsdk.com/f/out/job_uhk5lz7dvgfru0k7qku8/with-music.mp4?s=..."
},
"result": null,
"duration_s": 29.997,
"error": null,
"usage": {
"output_seconds": 29.997,
"audio_seconds": 0,
"tts_characters": 0,
"images": 0
},
"poll_url": "https://api.reelsdk.com/v1/jobs/job_uhk5lz7dvgfru0k7qku8"
}
}How the filtergraph works
The job runs on ffmpeg 8.1 via the raw ffmpeg endpoint. Inside -filter_complex, asplit=2 splits the audio from launch.mp4 into two streams, [voice] for the final mix and [key] to trigger the compressor. Before music.mp3 hits the filtergraph, -stream_loop -1 loops it so a short track won't run out before the video ends. Then volume=0.3 sets the music to 30% volume, and afade=t=out:st=27:d=3 fades it out over the last 3 s starting at 27 s.
From there, sidechaincompress takes the music and [key] and lowers the music whenever the original audio gets loud. We pass threshold=0.01, ratio=8, attack=20 (20 ms) and release=400 (400 ms). Once the music is ducked, amix=inputs=2:duration=first:normalize=0 adds [voice] and [ducked] together without rescaling their levels, and alimiter=limit=0.95 catches any peaks. Because -c:v copy copies the H.264 stream straight from launch.mp4 into with-music.mp4 and only encodes the new AAC track at -b:a 192k, the whole job billed about 2 seconds of compute.
At a glance
Ways to add music to a video
| Option | Price | Limits | What you run |
|---|---|---|---|
| ffmpeg on your own machine | Free; LGPL 2.1 or later, or GPL 2 or later with GPL libraries such as libx264 | Your CPU, disk and bandwidth | ffmpeg builds, a job queue, storage |
| AWS Lambda with an ffmpeg layer | $0.0000166667 per GB-second plus $0.20 per 1M requests (x86, US East) | 900 s per run, 10,240 MB memory and /tmp, 250 MB of code and layers, 6 MB sync payload | The layer, S3 in and out, retries |
| FFmpeg Micro | 1 token per 10 s of input, 500 tokens for $5 | 100 MB input on the free plan, 1,024 MB on Starter and Pro | API calls |
| Shotstack | 20¢ a minute of output, pay as you go; a 30 s video: 10¢ | 1080p max on pay as you go | A JSON edit with tracks and clips |
| ReelSDK | $0.02 per compute minute; under a tenth of a cent for this 30 s video | 500 MB per file, 1 GB per job, 10 minutes of run time | One HTTP call |
Sources: FFmpeg license and legal, AWS Lambda quotas, AWS Lambda pricing, FFmpeg Micro pricing, Shotstack pricing, checked November 2026.
Starting from images instead
If you don't have a finished video yet and you're building one from still photos, use POST /v1/slideshow instead of writing an audio filtergraph by hand. The slideshow API takes your images, a voiceover and a music track, and it loops or trims the music, fades it out at the end and ducks it under the voiceover for you.
You don't pay by compute time on that endpoint. It costs $0.03 per output minute, and if you have ReelSDK read the voiceover for you, that adds $0.05 per 1,000 characters.
Cost, limits and variations
ReelSDK bills POST /v1/ffmpeg at $0.02 per compute minute, counted by the second with a 1 s minimum, and machine start-up isn't billed. That put this 30-second clip at under a tenth of a cent, failed jobs cost $0, and you get $0.50 of free credit at sign-up; see pricing for the rest. If you want to replace the original sound on launch.mp4 instead of mixing under it, drop -filter_complex, map the music as the only audio stream and keep -shortest:
-map 0:v -map 1:aselects the video fromlaunch.mp4and the audio frommusic.mp3.-c:v copy -c:a aac -b:a 192kcopies the picture and encodes the music to AAC.-shorteststops the output whenlaunch.mp4ends so-stream_loop -1doesn't run forever.
What it costs
What this job cost
- Compute: fetching the inputs, running ffmpeg and storing the file
- 2.1 s
- Rate
- $0.02 per compute minute
- Charged
- $0.0007
Billed per second with a 1 s minimum. Machine start-up is not billed, and failed jobs cost $0.
Limits
What one request takes
- Input files
- 500 MB each, 1 GB per job
- Job run time
- Up to 10 minutes
- Inputs per job
- Up to 50
- Waiting for a result
- 60 s by default, up to 300 s
- Output retention
- 7 days
How it works
From request to file
Host the input
Any public http or https URL on the default port works, as long as it has no username or password in it; ReelSDK downloads it before ffmpeg starts. A local file goes up with
POST /v1/uploads?filename=clip.mp4first: up to 100 MiB per upload, kept 7 days, and larger files go up as a multipart upload.Send the arguments
-stream_loop -1loops the music input.asplitcopies the original audio: one copy stays in the mix, the other drivessidechaincompress, which pulls the music down while that audio is loud.amixwithnormalize=0adds them, and-c:v copyleaves the picture alone.Download the result
Every file is listed under
job.outputs, and the links work for 7 days, so copy what you keep. For long jobs, send?wait=0with awebhook_urland fetchGET /v1/jobs/{id}when the webhook arrives.
FAQ
Questions, answered
Does adding background music change the video quality?
No. Passing -c:v copy copies the H.264 picture stream into the output without decoding or re-encoding it. Only the audio goes through -filter_complex and gets encoded with -c:a aac -b:a 192k, so the file barely changes: 18.6 MB in, 18.7 MB out.
How do I adjust the music volume or fade time for a different clip length?
Change volume=0.3 in -filter_complex to raise or lower the base music level, and adjust threshold=0.01, ratio=8, attack=20 or release=400 on sidechaincompress to change how hard and how fast the music ducks under speech. The fade-out uses afade=t=out:st=27:d=3, where st=27 is the start time in seconds and d=3 is the fade duration. For a clip that isn't 30 s long, set st to your video's length minus d.
How does the cost compare to Shotstack, FFmpeg Micro and AWS Lambda?
On ReelSDK this 30-second job cost under a tenth of a cent, since it billed about 2 seconds of compute at $0.02 per minute. Shotstack charges 20¢ per output minute on pay as you go ($10 for 50 minutes, capped at 1080p), so a 30 s video costs 10¢. FFmpeg Micro charges 1 token per 10 seconds of input metered per second, with 500 tokens for $5, and caps inputs at 100 MB on the free plan or 1,024 MB on Starter and Pro. On AWS Lambda you pay $0.0000166667 per GB-second (x86, US East) plus $0.20 per 1M requests.
- Mix two audio tracks with ffmpegLay music under a voice or combine any two tracks with amix, set their levels with weights, and avoid the three defaults that bite.
- Duck music under a voice with ffmpegLower background music only while someone speaks, with sidechaincompress keyed by the voice and amix to put them together.
- Video to MP3Pull the audio track out of any video as an MP3 with one ffmpeg call, under a tenth of a cent for a 30 s clip.
- Merge videosJoin clips into one MP4 by URL with the concat filter or demuxer, up to 50 inputs, for well under a cent a merge.
- Burn subtitlesHard-code an SRT, ASS or VTT file into a video with one ffmpeg call and 10 bundled fonts, for well under a cent a clip.
- Slideshow API: photos to a narrated video for $0.03 a minuteSend 1 to 100 photo URLs and get an MP4 with Ken Burns motion, transitions, an AI voiceover, music and captions. $0.03 per output minute, plus $0.05 per 1,000 voiceover characters.
- FFmpeg API reference: POST /v1/ffmpegPOST /v1/ffmpeg runs ffmpeg 8.1 with your own arguments: up to 50 inputs of 500 MB, 20 outputs and 600 s per command, with tested recipes for GIFs, thumbnails and subtitles.
Sources, checked November 2026
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
