Skip to the tool workspace
Browser 123

Handleidingen Video and audio

How to trim, crop or change the speed of a video

Cut a clip to length, crop it square or vertical, or play it at double speed. The ffmpeg commands for each, why a fast trim can start in the wrong place, and when the browser editor is the easier route.

Each of these is one ffmpeg command, and you can do all three in one go. The only part that catches people out is trimming fast, without re-encoding: it is instant and lossless, but the cut can only start on a keyframe, and the wrong flag order loses the picture.

The Browser Video Crop & Time Stretch editor with clip.mp4 loaded: a square 1:1 crop box over the video, the file size, duration 0:08 and resolution 1280×720 below it, and the Timeline filmstrip with the trim handles pulled in to a three-second selection

A three-second cut, cropped square, before export.

The direct wayffmpegmacOS · Linux · Windows

Trim to the part from 3 s to 6 s, exactly:

ffmpeg -ss 3 -to 6 -i input.mp4 -c:v libx264 -crf 18 -c:a aac output.mp4

Crop to a square from the middle of a 1280×720 frame, at double speed:

ffmpeg -i input.mp4 -vf "crop=720:720:280:0,setpts=PTS/2" -af "atempo=2.0" output.mp4

Both re-encode, so the cut is frame-accurate and the filters can work. For a fast lossless trim, see the copy section below.

Trim

Exact cuts: re-encode

ffmpeg -ss 3 -to 6 -i input.mp4 -c:v libx264 -crf 18 -c:a aac output.mp4

-ss is the start and -to the end, both in seconds or as 00:01:23.5. Use -t 3 instead of -to to give a length. Put before -i, they make ffmpeg seek in the input, which is fast even on a long file. On our 8-second sample this gave a file of exactly 3.000 s, 75 frames at 25 fps, and its first frame is the source frame at 3.00 s, not the one before. -crf 18 keeps the quality close to the original. The cost is time, and a little quality, because every frame is compressed again.

Fast cuts: copy the streams

ffmpeg -ss 3 -to 6 -i input.mp4 -c copy output.mp4

-c copy copies the compressed video as it is: no quality loss, done in a moment. But most frames in a video only make sense relative to the keyframe before them, so a copied cut has to start at a keyframe. To see where yours are:

ffprobe -v error -select_streams v -skip_frame nokey -show_entries frame=pts_time -of csv=p=0 input.mp4

We cut 3 s to 6 s from a clip with a keyframe every 2 seconds (0, 2, 4, 6), each way, and measured the results with ffprobe:

Command What you get
-ss 3 -to 6 -i in.mp4 -c copy out.mp4 Starts at 3 s in players that honour MP4 edit lists. The file still holds the video from the 2 s keyframe, with that second marked as hidden, and the picture runs 3.2 s
-ss 3 -to 6 -i in.mp4 -c copy out.mkv Starts at the 2 s keyframe: 4.3 s long, a second early. MKV has no way to hide the lead-in
-i in.mp4 -ss 3 -to 6 -c copy out.mp4 Sound from 3 s, picture only from the 4 s keyframe: the first second has no picture
-ss 3 -to 6 -i in.mp4 -c:v libx264 … out.mp4 Exactly 3.000 s, from the right frame
Keep -ss before -i when you copy

After -i, a copied cut drops everything before the start and writes no video until the next keyframe. Our 8-second sample has one keyframe, at 0 s, so cutting it that way produced a file with sound and no video track at all.

So: -ss before -i, -c copy, save as MP4, and the cut usually plays from the right place, a little long at the end. A player or editor that ignores MP4 edit lists shows the hidden lead-in. If the cut point matters, re-encode.

On a Mac, for a trim only

QuickTime Player can trim. Open the video, choose Edit > Trim, drag the yellow handles and click Trim, then save. Holding a handle shows single frames for a finer cut. Apple's steps are in Trim a movie or clip in QuickTime Player. It has no crop and no speed control.

Crop

ffmpeg -i input.mp4 -vf "crop=720:720:280:0" -c:a copy output.mp4

crop=w:h:x:y: the width and height to keep, then the top-left corner, counted from the top left of the frame. 280 is (1280 − 720) / 2, which centres the square. Leave out x:y and ffmpeg centres it for you, so a vertical 9:16 cut from landscape footage is:

ffmpeg -i input.mp4 -vf "crop=ih*9/16:ih" -c:a copy output.mp4

On 1280×720 that came out 404×720. H.264 needs even dimensions, and ffmpeg rounded the 405 down. -c:a copy leaves the sound untouched; the video has to be re-encoded, because cropping changes every frame.

Change the speed

ffmpeg -i input.mp4 -vf "setpts=PTS/2" -af "atempo=2.0" output.mp4

setpts=PTS/2 halves every frame's timestamp, so the picture plays twice as fast. It does nothing to the sound, which is what atempo=2.0 is for: it speeds the audio up without raising the pitch. The 8-second sample came out 4.0 s long, still at 25 fps (ffmpeg dropped every other frame). To slow down, multiply instead: setpts=PTS*2 with atempo=0.5.

One atempo takes 0.5 to 100, so a quarter speed fails with Value 0.250000 for parameter 'tempo' out of range [0.5 - 100]. Chain two:

ffmpeg -i input.mp4 -vf "setpts=PTS*4" -af "atempo=0.5,atempo=0.5" -r 25 output.mp4

That gave 32 s from 8. Without -r 25, slowing 25 fps footage down leaves it at 12.5 or 6.25 frames a second, which looks choppy. -r 25 repeats frames to fill the gap; it does not invent new ones. No sound wanted? Swap the -af for -an.

All three at once

Filters run in the order you write them, so crop first, then the speed:

ffmpeg -ss 3 -to 6 -i input.mp4 -vf "crop=720:720:280:0,setpts=PTS/2" -af "atempo=2.0" output.mp4

On our sample: a 720×720 file, 1.5 seconds long, cut from 3 s to 6 s and played at double speed.

In the browser

The editor does the same job with a timeline and a crop box, and it re-encodes every time (H.264 for MP4 and MOV, VP8 for WebM). There is no lossless copy mode, so a long file takes real encoding time, even for a trim alone.

  1. Open the video editor and drop the video on it, or click Choose video.
  2. Drag the two handles on the Timeline to the start and end you want. The header shows the length of the selection and the length it will export at.
  3. Under Crop, pick an Aspect ratio (1:1, 4:5, 9:16, 16:9 or 21:9, or Freeform) and drag the box over the part to keep. Rotate & flip is there too.
  4. Under Speed, pick a Playback speed from 0.25x to 2x, or type up to 4 under Custom. Target duration works it out from the length you want. Preserve pitch keeps voices natural; Change with speed lets them rise and fall like a tape.
  5. Under Export, choose MP4 · recommended, a Quality, and a Frame rate if you slowed it down. Click Export video, then Download.
The Speed panel with 2x selected under Playback speed, the Custom and Target duration fields, and Preserve pitch selected under Audio pitch, while the Timeline header shows the selection and the shorter length it will export at

At 2x the three-second selection exports at half the length.

The Export panel after a render: MP4 · recommended, Match crop, Medium and the original frame rate selected (their labels cut off by the narrow buttons), the Output line 720×720 · 0:03 · MP4, Your video is ready, a preview player and a Download button with the file size

The result plays in the panel before you download it.

It runs in your browser's memory, so files up to about 300 MB work best.

Which to use

  • Just a shorter copy, quickly: ffmpeg -ss … -to … -i input.mp4 -c copy output.mp4, or QuickTime Player's Trim on a Mac.
  • A cut on an exact frame, a crop or a new speed: ffmpeg with re-encoding, using the commands above.
  • No ffmpeg, a managed laptop, or you want to see the crop before you commit: the video editor. Your file stays on your computer.

If the result is too big to send, compress it next.

Questions people ask

Can I trim a video without re-encoding it?

Yes, with ffmpeg -c copy, and it is instant and loses nothing. The catch is that a copied cut can only start on a keyframe. Put -ss before -i and save as MP4, and ffmpeg hides the extra lead-in for players that respect it. If the cut has to land on an exact frame, re-encode.

Why does my trimmed video start with sound but no picture?

The cut was copied (-c copy) with -ss after -i. ffmpeg then drops everything before the cut and waits for the next keyframe before it writes any video, so the picture starts late. On a clip with very few keyframes the video track can go missing altogether. Move -ss before -i, or re-encode.

ffmpeg says atempo 0.25 is out of range. How do I slow down to a quarter?

One atempo filter accepts 0.5 to 100. For 0.25x, chain two: -af "atempo=0.5,atempo=0.5". The browser editor builds that chain for you anywhere from 0.25x to 4x.

Why does my slow motion look choppy?

Slowing a video down does not make new frames. A 25 fps clip at half speed plays 12.5 frames a second, or each frame is shown twice if you force 25. Smooth slow motion needs footage shot at a high frame rate, such as a phone's 120 or 240 fps mode.

Can QuickTime Player crop a video or change its speed?

Not in a way that ends up in the file. QuickTime Player can trim, split, rotate and flip, but it has no crop and no speed setting on export. Use ffmpeg or the browser editor for those.

Tools in deze handleiding

Alles draait op je apparaat

Alle handleidingen

Draait in je browser·Je bestanden blijven op dit apparaat
Out0 B