mediacodec.dev

Trim & cut a video

There are two honest ways to cut video. Stream copy is instant and lossless but can only cut where keyframes already exist. Re-encoding is frame-accurate anywhere, at the cost of an encode. Pick based on what the clip is for.

Start time

-ss

Where the clip begins, as hh:mm:ss(.ms) or plain seconds. Placed before -i, this seeks by index instead of decoding everything up to the point, which is why it is fast even deep into a long file.

Clip length as

-t

How much video to keep from the start point.

Specify how long the clip runs, or where it should stop.

Duration

-t

Length of the clip to keep.

Cutting mode

-c copy

Copies compressed data untouched: a one-second operation with zero quality loss. But playback can only start on a keyframe, so your cut may begin up to a few seconds before the requested time, wherever the previous keyframe sits.

The central trade-off of trimming: speed and zero quality loss versus frame accuracy.

Your command

ffmpeg -ss 00:00:10 \
  -i input.mp4 -t 00:00:30 \
  -c copy \
  output.mp4

Worth knowing

With -ss before -i, FFmpeg jumps by the container’s index instead of decoding from the start: seeking to minute 50 of a two-hour file is as fast as seeking to minute 1.

In stream-copy mode, -c copy applies to every stream: video, audio and subtitles all pass through untouched.

If a stream-copied clip shows a frozen or black first moment in some players, that is the keyframe problem in action; re-encode mode fixes it.

Run this on your own file

no FFmpeg · runs in this tab

The command above needs FFmpeg on a machine. The settings it encodes do not: your browser can perform the same operation on a real file, right here, through WebCodecs.

Drop a video or audio file here, or

Files are processed in this tab and never uploaded.

True -c copy has no browser equivalent for a mid-file cut: packets only pass through when the cut starts at the very beginning, so this run re-encodes, and lands frame-accurate as a side effect. The keyframe snap the command teaches is real in FFmpeg; you just cannot watch it happen here.

Waiting on a file.