---
name: add-music-to-video
description: "Lay a music track under a video in the browser: video packets copied, music cut to length, faded and encoded to AAC. Use when someone asks for: add music to video online, add music to video. Free browser tool on Life2Film (life2film.com): runs in the user's browser, nothing is uploaded."
---

# Add Music to Video

Lay a music track under a video in the browser: video packets copied, music cut to length, faded and encoded to AAC.

Page: https://life2film.com/tools/add-music-to-video/?utm_source=skill

## What matters

- Replacing a soundtrack needs no video re-encode: copy the video packets and encode only the new audio.
- Cut the music to the video length and fade the last seconds; an abrupt stop is the commonest tell of a home edit.

## Limits

- Runs entirely in the user's browser. Nothing is uploaded, no account, no watermark.
- Because it runs on the user's machine, you cannot call it as an API: open the page for the person, or drive it with a browser (Playwright) on their machine.

## How to use it as an agent

1. The person has a file and a browser: give them https://life2film.com/tools/add-music-to-video/?utm_source=skill and say what to set. The file stays on their device.
2. You run a browser (Playwright, computer use): open the page, put the file in the drop zone, wait for the result, save the download.

## From code

```js
import { Input, Output, BlobSource, BufferTarget, Mp4OutputFormat, ALL_FORMATS,
  EncodedPacketSink, EncodedVideoPacketSource, AudioBufferSink, AudioBufferSource } from 'mediabunny';

const v = await new Input({ source: new BlobSource(video), formats: ALL_FORMATS }).getPrimaryVideoTrack();
const a = await new Input({ source: new BlobSource(music), formats: ALL_FORMATS }).getPrimaryAudioTrack();
const out = new Output({ format: new Mp4OutputFormat(), target: new BufferTarget() });
const vs = new EncodedVideoPacketSource(v.codec); out.addVideoTrack(vs);
const as = new AudioBufferSource({ codec: 'aac', bitrate: 192e3 }); out.addAudioTrack(as);
await out.start();
let first = true;
for await (const p of new EncodedPacketSink(v).packets()) { await vs.add(p, first ? { decoderConfig: await v.getDecoderConfig() } : undefined); first = false; }
for await (const { buffer } of new AudioBufferSink(a).buffers(0, await v.computeDuration())) await as.add(buffer);
vs.close(); as.close(); await out.finalize();
```

## Life2Film MCP

Every tool on Life2Film and our other sites, their skills and guides, as a read-only MCP server (`list_tools`, `get_tool`):

```sh
# Claude Code
claude mcp add --transport http life2film https://life2film.com/mcp
# Codex CLI
codex mcp add life2film --url https://life2film.com/mcp
```

Claude.ai, Claude Desktop, ChatGPT: add a custom connector with the URL `https://life2film.com/mcp`.
Cursor and other clients (`mcp.json`): `{"mcpServers":{"life2film":{"url":"https://life2film.com/mcp"}}}`

## Related

- [Trim Video](https://life2film.com/tools/video-trimmer/?utm_source=skill)
- [Compress Video](https://life2film.com/tools/video-compressor/?utm_source=skill)
- [Video to MP3](https://life2film.com/tools/video-to-mp3/?utm_source=skill)
- [Convert Video](https://life2film.com/tools/video-converter/?utm_source=skill)
- [Remove Audio](https://life2film.com/tools/remove-audio-from-video/?utm_source=skill)
- [Rotate Video](https://life2film.com/tools/rotate-video/?utm_source=skill)

---
Life2Film: https://life2film.com/ · llms.txt: https://life2film.com/llms.txt
