container filter

The FFmpeg trim filter

Selects a time range from a stream inside the filter graph.

3 of 3 variants measured Measured 2026-08-20

The part that catches people

trim leaves the original timestamps intact, so the output starts at whatever time you trimmed from and most players show a gap. setpts=PTS-STARTPTS after it is what actually rebases the clip to zero, and it is required, not optional.

Measured, not described

Every row below is a real job. The same 1280x720 five-second H.264 source went through each variant, so the numbers are comparable to each other and to every other filter page on this site. Encode time is the FFmpeg step on its own, separated from the download and the upload.

VariantEncodeOutputCost
Seconds 1 to 4714 ms363.1 KB · 1280x720$0.0022
Duration form725 ms363.1 KB · 1280x720$0.0021
Without the rebase667 ms363.1 KB · 1280x720$0.0021

The fastest variant here is not the smallest. Without the rebase finished the encode in 667 ms, while Seconds 1 to 4 produced the smallest file at 363.1 KB. Which one matters depends on whether you are paying for compute or for storage.

The exact commands

Seconds 1 to 4

job_293d57ea89b7473e

The correct form, with the rebase.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vf "trim=start=1:end=4,setpts=PTS-STARTPTS" -t 5 out.mp4

Duration form

job_aa1f03cb64984016

Same window expressed as a length.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vf "trim=start=1:duration=3,setpts=PTS-STARTPTS" -t 5 out.mp4

Without the rebase

job_0d3587d28fa34efc

Included to show the timestamps problem, not as a recommendation.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vf "trim=start=1:end=4" -t 5 out.mp4

How these numbers were produced

Each variant was submitted to the Rendobar API as an ffmpeg job against the same public source file, and the response was recorded verbatim. Encode time is the API's own per-step timing for the FFmpeg step. Output size is the byte count of the file the job produced. Cost is what the job was actually billed.

Nothing here was estimated, and the whole set is re-runnable, so if a figure looks wrong it can be checked rather than argued about. The 72 variants behind this filter reference cost $0.193082 in total to measure.

Frequently asked questions

What does the FFmpeg trim filter do?

Selects a time range from a stream inside the filter graph.

What is the most common mistake with trim?

trim leaves the original timestamps intact, so the output starts at whatever time you trimmed from and most players show a gap. setpts=PTS-STARTPTS after it is what actually rebases the clip to zero, and it is required, not optional.

How long does trim take to run?

On a 1280x720 five-second H.264 source, the fastest variant on this page (Without the rebase) spent 667 ms inside FFmpeg. That figure is the encode step alone, measured separately from the download and the upload, so it is the filter's own cost rather than the round trip.

Do I need FFmpeg installed to use trim?

Not with Rendobar. Every command on this page ran through the Rendobar API against a URL, with no local FFmpeg install and no server. The job id next to each row is the real job that produced the numbers.

Run trim without installing FFmpeg

Every command on this page ran through the API against a URL. No binary, no server.