# Video & Audio Trimmer – Cut MP4 & MP3 Clips by Timestamp (`gazidev/video-trimmer`) Actor

Cut clips from your video and audio files by start and end time: many clips per file, lossless fast cut (no re-encode) or frame-accurate cut, MP4, MOV, WebM, MP3, M4A and WAV. Optional fades and format change. Bulk from URLs, CSV or a dataset, with a download link per clip. $2 per 1,000 clips.

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

## Pricing

from $2.00 / 1,000 clip cut (fast)s

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 & Audio Trimmer – Cut MP4 & MP3 Clips by Timestamp

Cut **many clips out of your video and audio files** by start and end time, in bulk, in the cloud. Give a file URL and a list of timestamps, get back **one download link per clip**:

- **Many segments per file** – `00:01:00-00:01:30, 00:05:10-00:05:40` – the file is downloaded once and every clip is cut from it.
- **Fast, lossless cut (default)** – stream copy with FFmpeg (`-c copy`): no re-encoding, no quality loss, a few seconds even for long recordings. **$0.002 per clip.**
- **Frame-accurate cut** – re-encode to H.264/AAC (or WebM, MOV, MP3, M4A, WAV, FLAC) so the clip starts on the exact frame you asked for.
- **Optional fades** (in/out), **downscale** to 1080p / 720p / 480p and **format change** (e.g. cut an MP4 and save the clip as MP3).
- **Your own clip names** – `intro.mp4`, `highlight-03.mp3` – and a clean table with requested and actual start/end of every clip.
- **Bulk input** – a JSON list of clips, one segment list applied to many files, a pasted CSV (`url,start,end,name`), another Apify dataset, or files uploaded in the Console.

Works with MP4, MOV, M4V, WebM, MKV, MPEG-TS, AVI, MP3, M4A, AAC, WAV, FLAC, OGG and Opus files – anything FFmpeg reads.

> **Need to convert, compress or resize whole files instead?** Use [Video Converter & Compressor](https://apify.com/gazidev/media-converter) (`gazidev/media-converter`): MP4/WebM/MOV conversion, compress to a target size, MP4 to MP3, GIFs, speed, rotate and loudness. This Actor is only about **cutting clips**.

> **Not a YouTube / TikTok / Instagram downloader.** Pages of YouTube, TikTok, Instagram, Facebook, X, Vimeo, Twitch, SoundCloud and similar platforms are refused with a free error row. Use direct links to files you own or may process: your CDN, S3 / R2 / GCS bucket, Dropbox direct links, podcast hosting, form uploads.

### What can I use it for?

- **Podcast and video highlights** – cut the best 30-second moments of an episode for social posts, show notes or trailers.
- **Shorts from long recordings** – webinars, Zoom calls, livestream recordings, lectures: cut ten clips per file in one run.
- **Before transcription** – cut audio into the parts you need before sending it to Whisper, Deepgram or another speech-to-text service.
- **Ringtones, previews and samples** – cut an MP3 preview (`0+30`) of every track in a catalog with one segment list.
- **Dataset and QA pipelines** – cut labelled segments out of media files from a CSV of timestamps.
- **Automations** – call it from Make, Zapier, n8n or your backend, or chain it after another Actor that outputs media URLs.

### Fast or accurate? (read this once)

| | `fast` (default) | `accurate` |
|---|---|---|
| How | Stream copy, no re-encode | Re-encode (H.264 + AAC by default) |
| Quality | Identical to the source | Visually lossless (CRF 22) |
| Speed | Seconds, any length | About real time or faster |
| Video start | **Nearest keyframe at or before your start** | Exact frame |
| Audio files (MP3, M4A, WAV, FLAC) | Practically exact (MP3 frames are 26 ms) | Exact |
| Price | **$0.002 per clip** | Per started output minute (see Pricing) |

Video keyframes are often 2–10 seconds apart, so a `fast` video clip can start a few seconds **earlier** than you asked. The output always shows `actualStart` and `actualEnd`, and a `note` when the start moved by more than 0.1 s. If the first second matters, use `accurate`. A format change, fades or `maxResolution` switch the run to `accurate` automatically.

### Input

| Field | Description |
|---|---|
| `clips` | List of `{ "url", "start", "end", "name" }` objects. `end` can be left out (to the end of the file), or give `duration` instead |
| `mediaUrls` + `segments` | The same segments for every file, e.g. `["00:00:00-00:00:30", "90+30", "10:00-"]` |
| `bulkText` | URL list (cut with `segments`) or CSV with the header `url,start,end,name` (one row per clip) |
| `datasetId`, `datasetField` | Another dataset: items with `start`/`end` become clips, items with only a URL use `segments` |
| `uploadedFiles`, `uploadStore` | Files uploaded in the Console (cut with `segments`) |
| `mode` | `fast` (stream copy, default) or `accurate` (re-encode) |
| `outputFormat` | `same` (default), `mp4`, `webm`, `mov`, `mp3`, `m4a`, `wav`, `flac` |
| `fadeInSec`, `fadeOutSec` | Fades in seconds (0 = none) |
| `maxResolution` | `source` (default), `1080`, `720`, `480` – accurate mode, never upscales |
| `maxClipsPerFile`, `maxFileSizeMb`, `maxConcurrency` | Limits: 50 clips, 2,000 MB, 2 files in parallel |

**Time formats:** `90`, `90.5`, `01:30`, `00:01:30.250`, `1m30s`, `2h`. **Segment formats:** `start-end` (`00:01:00-00:01:30`, `90-120`), `start+length` (`90+30`), `start-` or `start-end` keyword (to the end), `-30` (first 30 seconds). Several segments can go on one line, separated by commas.

Cut two named clips from one video and one from a podcast:

```json
{
  "clips": [
    { "url": "https://example.com/webinar.mp4", "start": "00:12:05", "end": "00:12:50", "name": "pricing-question" },
    { "url": "https://example.com/webinar.mp4", "start": "00:41:10", "end": "00:42:00", "name": "demo" },
    { "url": "https://example.com/episode-42.mp3", "start": "1m30s", "duration": 45, "name": "ep42-teaser" }
  ]
}
```

A 30-second MP3 preview of every track, with a fade-out:

```json
{
  "mediaUrls": ["https://example.com/track-01.wav", "https://example.com/track-02.wav"],
  "segments": ["0+30"],
  "outputFormat": "mp3",
  "fadeOutSec": 2
}
```

CSV in `bulkText`:

```
url,start,end,name
https://example.com/talk.mp4,00:03:00,00:03:40,opening
https://example.com/talk.mp4,00:27:15,00:28:00,key-point
```

### Output

One dataset row per clip (the **Clips** view shows a table with download links), plus a free `SUMMARY` record in the key-value store. The clip files are stored in the run's key-value store; `clipUrl` is a direct download link.

```json
{
  "sourceUrl": "https://download.samplelib.com/mp4/sample-10s.mp4",
  "name": "intro",
  "segment": "00:00:02-00:00:06",
  "requestedStart": 2.0,
  "requestedEnd": 6.0,
  "status": "ok",
  "sourceDurationSec": 10.216,
  "note": "Fast mode starts at the keyframe at 0.000s (2.00s before the requested start). Use mode 'accurate' for a frame-exact cut",
  "actualStart": 0.0,
  "actualEnd": 6.096,
  "durationSec": 6.096,
  "mode": "fast",
  "format": "mp4",
  "width": 1920,
  "height": 1080,
  "videoCodec": "h264",
  "audioCodec": "aac",
  "bytes": 3466418,
  "clipUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/intro.mp4",
  "clipKey": "intro.mp4",
  "billedEvents": { "clip": 1 }
}
```

Failed clips have `status: "error"`, an `errorCode` (`INVALID_SEGMENT`, `SEGMENT_OUT_OF_RANGE`, `NOT_MEDIA`, `HTTP_404`, `FILE_TOO_LARGE`, `UNSUPPORTED_PLATFORM`, `MAX_CHARGE_REACHED`, …) and are **never charged**. An end time after the end of the file is cut at the end of the file and noted in `note`.

### Pricing (pay per event)

| Event | Price | When |
|---|---|---|
| `clip` | **$0.002** | Each clip cut in `fast` mode (one event per started 60 minutes of clip) |
| `video-minute` | $0.008 | `accurate` mode, per started output minute, video ≤ 576p |
| `hd-video-minute` | $0.025 | `accurate`, output 720p |
| `fullhd-video-minute` | $0.05 | `accurate`, output 1080p |
| `4k-video-minute` | $0.20 | `accurate`, output above 1080p |
| `audio-minute` | $0.003 | `accurate`, audio output (MP3, M4A, WAV, FLAC), per started minute |

$2 per 1,000 fast clips. Accurate-mode prices are the same as in [gazidev/media-converter](https://apify.com/gazidev/media-converter). Free: invalid or platform URLs, bad timestamps, segments outside the file, download and encode failures, clips skipped at your maximum charge, the `SUMMARY` record.

Other trimmers in the Apify Store (public prices, November 2026): data-done-right/video-trimmer $0.025 per clip; automa-flow/bulk-ffmpeg-media-processor $0.01 per file; whitewalk/ffmpeg-cloud-mcp $0.01 per call plus $0.03 per start; nexgensignal/media-converter $0.05 per minute.

**Maximum charge:** before each clip the Actor checks that your run's maximum total charge still covers it. When it does not, the remaining clips get a free `MAX_CHARGE_REACHED` row and the run ends normally.

### FAQ

**Why does my fast clip start earlier than I asked?** Stream copy can only start a video on a keyframe. Use `mode: accurate` for an exact start. The end is always close to your end time.

**Is the fast cut really lossless?** Yes. The audio and video packets are copied unchanged into a new file of the same container (MP4 → MP4, MP3 → MP3, WebM → WebM, MKV → MKV). Metadata such as titles and GPS tags is removed. FLAC is re-encoded losslessly so its length header is correct.

**How long can files and clips be?** Files up to 2,000 MB by default (`maxFileSizeMb`). Clips can be any length; a fast clip up to 60 minutes is one `clip` event. Long accurate clips need more memory (CPU): 1,024 MB is the default, use 4,096 MB for 1080p re-encodes.

**Can I trim YouTube or TikTok videos?** No. This Actor only processes direct links to media files you own or may process.

**Can I upload files instead of giving links?** Yes: upload them in the Console (`uploadedFiles`), select the same key-value store in `uploadStore`, and set `segments`.

**HLS (`.m3u8`) streams?** Not supported here. [gazidev/media-converter](https://apify.com/gazidev/media-converter) can trim an HLS stream with `startTime`/`endTime`.

### Use with AI agents / Apify MCP

Add this Actor as a tool in the [Apify MCP server](https://mcp.apify.com) (`gazidev/video-trimmer`) and let your agent cut clips: give it file URLs and timestamps, and it gets one row per clip with a `clipUrl` download link. The input is plain JSON (`clips` with `url`, `start`, `end`, `name`), and every row reports the real `actualStart`/`actualEnd`, so an agent can check what was cut. It also works through the Apify API and the Python and JavaScript clients:

```bash
curl -X POST "https://api.apify.com/v2/acts/gazidev~video-trimmer/run-sync-get-dataset-items?token=<YOUR_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"clips":[{"url":"https://example.com/episode.mp3","start":"00:10:00","end":"00:10:45","name":"teaser"}]}'
```

### Limits

- Direct file links only; files are downloaded once per run (no partial range reads).
- Fast mode: video clips start on a keyframe (see above). Subtitle and data tracks are dropped.
- Accurate mode re-encodes to H.264/AAC (MP4, MOV), VP9/Opus (WebM) or the chosen audio format; other video codecs are not offered.
- Clip files stay in the run's key-value store for your account's data retention period. Download them or copy them elsewhere if you need them longer.

# Actor input Schema

## `clips` (type: `array`):

One object per clip: `url` (direct link to a video or audio FILE), `start`, `end` and an optional `name` (used as the file name). Times: seconds (`90`), `01:30`, `00:01:30.5` or `1m30s`; leave `end` out to cut to the end of the file, or give `duration` instead. Several clips may share one URL: the file is downloaded once. YouTube/TikTok/Instagram pages are refused - this is a trimmer, not a downloader.

## `mediaUrls` (type: `array`):

Direct links to video or audio files (MP4, MOV, WebM, MKV, MP3, M4A, WAV, FLAC, OGG...). Every file is cut with the `segments` below.

## `segments` (type: `array`):

Applied to every file in `mediaUrls`, `bulkText` and `datasetId` that has no own times. Formats: `00:01:00-00:01:30`, `90-120`, `90+30` (start + length), `90-` or `90-end` (to the end), `-30` (first 30 s). Several per line with commas also work.

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

One URL per line (cut with `segments`), or a CSV with the header `url,start,end,name` (also `segment` instead of start/end) - one row per clip.

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

Items with `start`/`end` (or `segment`) fields become clips; items with only a URL are cut with `segments`.

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

Field name in that dataset.

## `uploadedFiles` (type: `array`):

Upload video or audio files in the Console; they are cut with `segments`. This Actor runs with limited permissions, so ALSO select the store you uploaded into in 'Key-value store with your uploads'. When you upload files, the pre-filled demo clips are ignored.

## `uploadStore` (type: `string`):

Grants this run read access to that store only. If `uploadedFiles` points into it, only those files are cut; otherwise every media file in the store is (up to 1,000).

## `mode` (type: `string`):

`fast` copies the streams without re-encoding: no quality loss and very quick, but a video clip starts on the nearest keyframe at or BEFORE your start time (the row shows `actualStart`). Audio files (MP3, M4A, WAV) cut practically exactly. `accurate` re-encodes for a frame-exact start. A format change, fades or a max resolution switch to `accurate` automatically.

## `outputFormat` (type: `string`):

Anything other than `same` re-encodes (mode `accurate`). Audio formats from a video file give the audio of the clip.

## `fadeInSec` (type: `number`):

Video and audio fade-in at the start of every clip (re-encodes).

## `fadeOutSec` (type: `number`):

Fade-out at the end of every clip (re-encodes).

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

Downscale the short side; never upscales. Re-encodes.

## `maxClipsPerFile` (type: `integer`):

Extra clips get a free error row.

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

Larger files are skipped (free). Files are downloaded once; above ~2,000 MB give the run more memory (disk).

## `maxConcurrency` (type: `integer`):

Clips of one file are cut one after another.

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

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

## Actor input object example

```json
{
  "clips": [
    {
      "url": "https://download.samplelib.com/mp4/sample-10s.mp4",
      "start": "00:00:02",
      "end": "00:00:06",
      "name": "intro"
    },
    {
      "url": "https://download.samplelib.com/mp3/sample-9s.mp3",
      "start": "1",
      "end": "5"
    }
  ],
  "datasetField": "url",
  "mode": "fast",
  "outputFormat": "same",
  "fadeInSec": 0,
  "fadeOutSec": 0,
  "maxResolution": "source",
  "maxClipsPerFile": 50,
  "maxFileSizeMb": 2000,
  "maxConcurrency": 2,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `clips` (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 = {
    "clips": [
        {
            "url": "https://download.samplelib.com/mp4/sample-10s.mp4",
            "start": "00:00:02",
            "end": "00:00:06",
            "name": "intro"
        },
        {
            "url": "https://download.samplelib.com/mp3/sample-9s.mp3",
            "start": "1",
            "end": "5"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/video-trimmer").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 = { "clips": [
        {
            "url": "https://download.samplelib.com/mp4/sample-10s.mp4",
            "start": "00:00:02",
            "end": "00:00:06",
            "name": "intro",
        },
        {
            "url": "https://download.samplelib.com/mp3/sample-9s.mp3",
            "start": "1",
            "end": "5",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("gazidev/video-trimmer").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 '{
  "clips": [
    {
      "url": "https://download.samplelib.com/mp4/sample-10s.mp4",
      "start": "00:00:02",
      "end": "00:00:06",
      "name": "intro"
    },
    {
      "url": "https://download.samplelib.com/mp3/sample-9s.mp3",
      "start": "1",
      "end": "5"
    }
  ]
}' |
apify call gazidev/video-trimmer --silent --output-dataset

```

## MCP server setup

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

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/aSvF3UN9VCqkbsvlB/builds/hHroGvYQ3bAP7VEL4/openapi.json
