# Video Merger – Join MP4 Clips, Add Music & Intro (`gazidev/video-merger`) Actor

Video merger: join MP4/MOV/WebM clips and photos from URLs into one MP4 in your order. Lossless when formats match, else re-encode to 1080p/720p, 16:9, 9:16 or 1:1. Add intro/outro, crossfade transitions, background music. Public download link. $0.09 per output minute (1080p).

- **URL**: https://apify.com/gazidev/video-merger.md
- **Developed by:** [Cemal Atakli](https://apify.com/gazidev) (community)
- **Features:** Limited permissions
- **Stats:** 4 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $90.00 / 1,000 full hd merged video minutes

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Video Merger – Join MP4 Clips, Add Music & Intro

**Merge videos online from URLs**: paste links to your clips in playback order and get back **one MP4** with a public download link. Join MP4, MOV, WebM, MKV and AVI files, add an **intro and outro**, **crossfade transitions**, **background music** with fade in/out, and photos as slides – all with FFmpeg in the cloud, no software to install.

- **Lossless join** when all clips share the same format, resolution and frame rate (phone or camera recordings, split recordings, video chapters): stream copy, no quality loss, seconds per file.
- **Smart re-encode** when they differ: every clip is scaled to one size and frame rate (letterboxed or cropped), audio is resampled, silent clips get a silent track – so the result always plays everywhere (H.264 + AAC, MP4 fast start).
- **Vertical, square or landscape output**: 16:9, **9:16 for Reels / Shorts / TikTok**, 1:1, 4:5, 4:3 – up to 4K.
- **Background music**: any MP3/M4A/WAV URL, volume, loop, fade in/out, mixed under the clips' own audio or replacing it.
- **Transitions**: crossfade, fade through black/white, dissolve, wipe, slide, circle, radial.
- **Photos** (JPG/PNG/WebP) in the clip list become slides of N seconds – build a slideshow with music.
- **Batch**: many merges in one run with the `jobs` list.

> **Not a YouTube / TikTok / Instagram downloader.** Links to pages of YouTube, TikTok, Instagram, Facebook, X, Vimeo and similar platforms are refused (free). Use direct links to files you own or are allowed to process: your CDN, S3 / R2 / GCS bucket, Dropbox or Drive direct links, stock footage, form uploads.

### What can I use it for?

- **Combine phone or camera clips** into one video without re-encoding (GoPro chapters, dashcam segments, split screen recordings).
- **Social media editing at scale**: brand intro + clip + outro with music, in 9:16 for Reels, Shorts and TikTok.
- **User-generated content**: stitch customer or testimonial clips into one compilation.
- **Real-estate, product and event slideshows** from photos and short clips with background music.
- **AI video pipelines**: join generated scenes (Runway, Pika, Kling, Veo, Sora outputs) into one final MP4 from n8n, Make, Zapier or your backend.

### Input

| Field | Description |
|---|---|
| `videoUrls` (+ `bulkText`, `datasetId`) | Direct links to clips or photos, **in playback order** |
| `introUrl`, `outroUrl` | Optional clip or image before / after the clips |
| `backgroundMusicUrl` | Optional music; `musicVolume` (0.3), `keepOriginalAudio` (true), `originalVolume`, `loopMusic`, `musicFadeInSec` (1), `musicFadeOutSec` (2) |
| `transition`, `transitionSec` | `none` (default), `fade`, `fadeblack`, `fadewhite`, `dissolve`, `wipeleft`, `slideleft`, … and 0.5 s |
| `maxResolution` | `1080` (default), `original`, `2160`, `1440`, `720`, `480`, `360` – never upscales |
| `aspectRatio`, `fitMode`, `padColor` | `auto` (first clip), `16:9`, `9:16`, `1:1`, `4:5`, `4:3`; `pad` or `crop`; letterbox color |
| `imageDurationSec`, `fps`, `quality` | 3 s per photo; 0 = first clip's fps; `small` / `balanced` / `high` |
| `forceReencode` | Re-encode even when a lossless join is possible |
| `outputName`, `jobs` | File name; batch of merges (`[{videoUrls, introUrl, outroUrl, backgroundMusicUrl, outputName}]`) |
| `skipFailedClips`, `maxFileSizeMb`, `maxDurationMinutes`, `maxClips` | Safety limits (500 MB per file, 60 min output, 100 clips) |

Vertical reel with an intro card, crossfades and music:

```json
{
  "introUrl": "https://example.com/brand/intro-card.png",
  "videoUrls": [
    "https://example.com/uploads/clip-1.mp4",
    "https://example.com/uploads/clip-2.mov"
  ],
  "outroUrl": "https://example.com/brand/outro.mp4",
  "aspectRatio": "9:16",
  "fitMode": "crop",
  "maxResolution": "1080",
  "transition": "fade",
  "transitionSec": 0.5,
  "backgroundMusicUrl": "https://example.com/music/track.mp3",
  "musicVolume": 0.3
}
```

Lossless join of recordings that share one format:

```json
{ "videoUrls": ["https://example.com/cam/part1.mp4", "https://example.com/cam/part2.mp4"], "outputName": "full-recording" }
```

### Output

One dataset row per merged video (table view "Merged videos"), the MP4 in the run's key-value store, and a `SUMMARY` record.

```json
{
  "job": 1,
  "outputName": "merged",
  "status": "ok",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/merged.mp4",
  "fileKey": "merged.mp4",
  "mode": "re-encode",
  "reencodeReasons": ["clips differ in codec/resolution/frame rate"],
  "clipCount": 2,
  "transition": "none",
  "backgroundMusicUrl": "https://download.samplelib.com/mp3/sample-15s.mp3",
  "output": {"duration": 15.81, "width": 1920, "height": 1080, "fps": 30.0, "videoCodec": "h264", "audioCodec": "aac", "sizeBytes": 9332075},
  "clips": [
    {"url": "https://download.samplelib.com/mp4/sample-5s.mp4", "role": "clip", "duration": 5.7, "width": 1920, "height": 1080, "fps": 30.0, "videoCodec": "h264", "audioCodec": "aac", "isImage": false},
    {"url": "https://download.samplelib.com/mp4/sample-10s.mp4", "role": "clip", "duration": 10.11, "width": 1920, "height": 1080, "fps": 29.97, "videoCodec": "h264", "audioCodec": "aac", "isImage": false}
  ],
  "billedEvents": {"fullhd-video-minute": 1},
  "processingSec": 12.4
}
```

`mode` is `stream-copy` (lossless) or `re-encode`; `reencodeReasons` says why a lossless join was not possible. Failed merges get `status: "error"`, an `errorCode` (`HTTP_404`, `NOT_MEDIA`, `UNSUPPORTED_PLATFORM`, `TOO_LONG`, `MUSIC_HTTP_403`, `MAX_CHARGE_REACHED`, …) and are **not charged**.

### Pricing

Pay per started minute of the **merged output video**. Nothing else: downloads, failed merges and errors are free.

| Event | Price |
|---|---|
| Lossless merge (stream copy, any resolution) | **$0.02 / minute** |
| SD re-encode (≤ 576p) | $0.04 / minute |
| HD re-encode (720p) | $0.06 / minute |
| **Full HD re-encode (1080p, default)** | **$0.09 / minute** |
| 4K re-encode (1440p / 2160p) | $0.35 / minute |

Examples: 3 clips of 20 s at 1080p with music = 1 minute = **$0.09**. Two 30-minute camera files joined losslessly = **$1.20**.

| Actor (Apify Store) | Price | Notes |
|---|---|---|
| **This Actor** | $0.02–0.09 per output minute (1080p) | Lossless join, transitions, music, intro/outro, photos, 9:16 |
| agentutilitylabs/short-video-assembler | $0.20 per video | Short-video assembly |
| whitewalk/ffmpeg-cloud-mcp | $0.03–0.04 per operation | Generic FFmpeg MCP server |

Set a **maximum total charge** for the run in Apify Console: the Actor checks the cost of each merge before encoding and stops gracefully (no surprise bills).

### FAQ

**Which formats can I merge?** Anything FFmpeg reads: MP4, MOV, M4V, WebM, MKV, AVI, MPEG-TS, HLS `.m3u8`, and JPG/PNG/WebP photos. Output is always MP4 (H.264 + AAC), playable everywhere.

**Will the quality drop?** Not when the clips match (same codec, resolution, frame rate, audio): they are joined losslessly. Otherwise each clip is re-encoded once at `quality` (CRF 23 by default, visually near-lossless for web).

**My clips have different sizes / are vertical and horizontal.** All clips are fitted into the output frame (first clip's shape or `aspectRatio`): `pad` keeps the whole picture with bars, `crop` fills the frame.

**Some clips have no sound.** They get a silent track so the merge stays in sync; background music plays across all of them.

**How long can the video be?** Up to `maxDurationMinutes` (60 by default, max 600). Long 1080p merges take about real time or less to encode; give the run more memory for long 4K jobs.

**Can I merge YouTube or TikTok videos?** No. Use files you own or are licensed to use; music too.

**How long are the files kept?** In the run's default key-value store, according to your Apify data retention. Download them or copy them to your storage from an automation.

### Use with AI agents / Apify MCP

The Actor works as a tool in the [Apify MCP server](https://mcp.apify.com) (`gazidev/video-merger`) for Claude, Cursor, ChatGPT and other MCP clients: an agent can generate or collect clips, call the merger with `videoUrls` + `backgroundMusicUrl`, and return the `fileUrl`. Via API:

```bash
curl -X POST "https://api.apify.com/v2/acts/gazidev~video-merger/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"videoUrls": ["https://example.com/a.mp4", "https://example.com/b.mp4"], "transition": "fade"}'
```

Works the same from Make, Zapier, n8n (Apify node) and the Python / JavaScript clients.

# Actor input Schema

## `videoUrls` (type: `array`):

Direct links to video FILES (MP4, MOV, WebM, MKV, AVI, M4V, HLS .m3u8) or photos (JPG, PNG, WebP), joined top to bottom into one MP4. Pages of YouTube, TikTok, Instagram, Vimeo etc. are refused: this is a merger, not a downloader.

## `bulkText` (type: `string`):

Optional: more clip URLs, one per line (or a CSV with a `url` column), appended after `videoUrls` in this order.

## `datasetId` (type: `string`):

Optional: chain after another Actor that outputs video file URLs; items are merged in dataset order.

## `datasetField` (type: `string`):

Field name in that dataset.

## `introUrl` (type: `string`):

Optional video (or title-card image) placed before the first clip.

## `outroUrl` (type: `string`):

Optional video (or end-card image) placed after the last clip.

## `backgroundMusicUrl` (type: `string`):

Optional audio file laid under the whole video, cut to the video length with fade in/out. Use music you have the rights to.

## `musicVolume` (type: `number`):

1 = original loudness. 0.2–0.4 keeps speech in the clips audible; use 1 when `keepOriginalAudio` is off.

## `keepOriginalAudio` (type: `boolean`):

Off = music only (or a silent video when no music is given).

## `originalVolume` (type: `number`):

Volume of the clips' own audio when mixed with music.

## `loopMusic` (type: `boolean`):

Off = the music plays once, then silence.

## `musicFadeInSec` (type: `number`):

Seconds to fade the background music in at the start. 0 = no fade.

## `musicFadeOutSec` (type: `number`):

Seconds to fade the background music out at the end. 0 = no fade.

## `transition` (type: `string`):

Transitions overlap neighbouring clips by `transitionSec` (video and audio crossfade) and always re-encode.

## `transitionSec` (type: `number`):

Capped at half of the shortest clip.

## `maxResolution` (type: `string`):

The output takes the first clip's size, with the short side capped at this value (never upscaled). Billing depends on the output resolution.

## `aspectRatio` (type: `string`):

Clips with a different shape are letterboxed (`pad`) or cropped to fill (`crop`).

## `fitMode` (type: `string`):

How clips with a different aspect ratio than the output are fitted: pad keeps the whole picture with bars, crop fills the frame.

## `padColor` (type: `string`):

Color name or hex like `#202020`.

## `imageDurationSec` (type: `number`):

How long each JPG/PNG/WebP in the list (or intro/outro image) is shown.

## `fps` (type: `integer`):

0 = the first clip's frame rate.

## `quality` (type: `string`):

Encoding quality used when clips must be re-encoded. Lossless joins are not affected.

## `forceReencode` (type: `boolean`):

By default clips with identical format, resolution and frame rate are joined losslessly (stream copy: fast, no quality loss, billed as lossless minutes). Turn on to always re-encode to H.264/AAC.

## `outputName` (type: `string`):

Name of the MP4 in the key-value store (letters, digits, - \_ . only).

## `jobs` (type: `array`):

Optional list of objects `{"videoUrls": [...], "introUrl", "outroUrl", "backgroundMusicUrl", "outputName"}` - one MP4 per object, all other settings shared. When set, the top-level clip fields are ignored.

## `skipFailedClips` (type: `boolean`):

Off = a merge with a broken clip is not produced (error row, not charged). On = merge the remaining clips and list the skipped ones.

## `maxFileSizeMb` (type: `integer`):

Larger files fail with an error (not charged). For many big files give the run more memory (disk).

## `maxDurationMinutes` (type: `integer`):

Cost cap: longer merges are refused before encoding (not charged).

## `maxClips` (type: `integer`):

Safety limit on the number of clips in one merge.

## `proxyConfiguration` (type: `object`):

Only for hosts that block datacenter IPs (HTTP 403).

## Actor input object example

```json
{
  "videoUrls": [
    "https://download.samplelib.com/mp4/sample-5s.mp4",
    "https://download.samplelib.com/mp4/sample-10s.mp4"
  ],
  "datasetField": "url",
  "backgroundMusicUrl": "https://download.samplelib.com/mp3/sample-15s.mp3",
  "musicVolume": 0.3,
  "keepOriginalAudio": true,
  "originalVolume": 1,
  "loopMusic": true,
  "musicFadeInSec": 1,
  "musicFadeOutSec": 2,
  "transition": "none",
  "transitionSec": 0.5,
  "maxResolution": "1080",
  "aspectRatio": "auto",
  "fitMode": "pad",
  "padColor": "black",
  "imageDurationSec": 3,
  "fps": 0,
  "quality": "balanced",
  "forceReencode": false,
  "outputName": "merged",
  "skipFailedClips": false,
  "maxFileSizeMb": 500,
  "maxDurationMinutes": 60,
  "maxClips": 100,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `all` (type: `string`):

No description

## `files` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "videoUrls": [
        "https://download.samplelib.com/mp4/sample-5s.mp4",
        "https://download.samplelib.com/mp4/sample-10s.mp4"
    ],
    "backgroundMusicUrl": "https://download.samplelib.com/mp3/sample-15s.mp3"
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/video-merger").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "videoUrls": [
        "https://download.samplelib.com/mp4/sample-5s.mp4",
        "https://download.samplelib.com/mp4/sample-10s.mp4",
    ],
    "backgroundMusicUrl": "https://download.samplelib.com/mp3/sample-15s.mp3",
}

# Run the Actor and wait for it to finish
run = client.actor("gazidev/video-merger").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "videoUrls": [
    "https://download.samplelib.com/mp4/sample-5s.mp4",
    "https://download.samplelib.com/mp4/sample-10s.mp4"
  ],
  "backgroundMusicUrl": "https://download.samplelib.com/mp3/sample-15s.mp3"
}' |
apify call gazidev/video-merger --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gazidev/video-merger"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/5YgDNQGo8IQG0Vybp/builds/0Ojg7RXF1OLv03Voc/openapi.json
