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

with-music.mp4: Spring On The Horizon by HoliznaCC0 (CC0) at 30% volume, ducked under the launch commentary.Input: launch.mp4with-music.mp4 (18.7 MB)spring-on-the-horizon.mp3

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.

terminalTry it
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"]
  }'
request.mjsTry it
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();
response.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

Ways to add music to a video
OptionPriceLimitsWhat you run
ffmpeg on your own machineFree; LGPL 2.1 or later, or GPL 2 or later with GPL libraries such as libx264Your CPU, disk and bandwidthffmpeg 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 payloadThe layer, S3 in and out, retries
FFmpeg Micro1 token per 10 s of input, 500 tokens for $5100 MB input on the free plan, 1,024 MB on Starter and ProAPI calls
Shotstack20¢ a minute of output, pay as you go; a 30 s video: 10¢1080p max on pay as you goA JSON edit with tracks and clips
ReelSDK$0.02 per compute minute; under a tenth of a cent for this 30 s video500 MB per file, 1 GB per job, 10 minutes of run timeOne 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:a selects the video from launch.mp4 and the audio from music.mp3.
  • -c:v copy -c:a aac -b:a 192k copies the picture and encodes the music to AAC.
  • -shortest stops the output when launch.mp4 ends so -stream_loop -1 doesn'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

  1. 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.mp4 first: up to 100 MiB per upload, kept 7 days, and larger files go up as a multipart upload.

  2. Send the arguments

    -stream_loop -1 loops the music input. asplit copies the original audio: one copy stays in the mix, the other drives sidechaincompress, which pulls the music down while that audio is loud. amix with normalize=0 adds them, and -c:v copy leaves the picture alone.

  3. 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=0 with a webhook_url and fetch GET /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.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains