Trim a video without re-encoding

Cuts a section out of a video by copying streams, which is effectively instant and lossless.

ffmpeg -ss 1 -i https://cdn.rendobar.com/assets/examples/sample.mp4 -t 3 -c copy out.mp4
Encode
51 ms
Output
278.5 KB
Cost
$0.0016
Result
1280x720

job_7fe6d02b42b84c72

The part everyone gets wrong

-ss before -i seeks fast but lands on the nearest keyframe, so the cut may not be frame-accurate. -ss after -i is accurate but decodes from the start. With -c copy you are always keyframe-bound regardless, so put -ss first and accept the keyframe, or drop -c copy and re-encode for an exact cut.

What the common version does

Putting -ss after -i decodes to the seek point instead of jumping. Measured on this clip it did something worse than being slow: it produced a 36 KB file with no video stream at all, and did not error.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -ss 1 -t 3 -c copy out.mp4
It succeeds, and that is the problem

It did not error. It produced a 36.7 KB file with no video stream at all, where the correct command produced 278.5 KB at 1280x720. Nothing in a normal pipeline would catch that.

job_70c0b453bd9d4c8e

Frequently asked questions

How do I trim video ffmpeg?

Cuts a section out of a video by copying streams, which is effectively instant and lossless.

What goes wrong most often?

-ss before -i seeks fast but lands on the nearest keyframe, so the cut may not be frame-accurate. -ss after -i is accurate but decodes from the start. With -c copy you are always keyframe-bound regardless, so put -ss first and accept the keyframe, or drop -c copy and re-encode for an exact cut.

What happens if I get it wrong?

We ran the naive version too. It did not error. It produced a 36.7 KB file with no video stream at all, where the correct command produced 278.5 KB at 1280x720. Nothing in a normal pipeline would catch that.

Do I need FFmpeg installed?

Not with Rendobar. The command on this page ran through the API against a URL, with no local FFmpeg and no server. The job id below it is the job that produced these numbers.

Run this without installing FFmpeg

This exact command ran through the API against a URL.