> ## Content Index
> Fetch the complete content index at: https://ffmpeguru.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Trim to first N seconds with stream copy (fast, keyframe-snapped)
- URL: https://ffmpeguru.com/trim-to-first-n-seconds-with-stream-copy-fast-keyframe-snapped/
- Published: 2026-10-21T09:00:00.000Z
- Updated: 2026-10-21T09:00:00.000Z
- Author: FFmpeguru
- Tags: ffmpeg

Need the first 30 seconds of a video? `-t` with stream copy grabs the head of the file and stops after a duration rather than at a timestamp. It is the same speed as timestamp-based stream copy and the same precision trade-off.

## The command

```
ffmpeg -i input.mp4 -t 30 -c copy output.mp4
```

## What it does

FFmpeg starts at the beginning of the input, copies packets for 30 seconds of timeline, then stops. The output is the first 30 seconds of the source, possibly snapped to the nearest keyframe on the back edge. The copy is lossless and the wall-clock time is bounded by disk read speed.

## When to use it

For previews, social media first-frame clips, or any time you want a fixed-length snippet from the head of a file. The most common use is extracting the first 30 or 60 seconds of a long recording to send as a preview.

## Video and audio requirements

Any container and codec FFmpeg supports. The 30-second window is measured on the source's timeline, not real time, so variable frame rate sources and time-shifted audio are handled correctly.

## Things to avoid

- Expecting the output to be exactly 30.000 seconds. It will be between 30 and 31 seconds depending on the keyframe distance. For exact duration, re-encode.
- Using `-t` to specify end time. `-t` is duration from the start, not a target timestamp. To cut from one time to another, use `-ss` and `-to`.
- Trimming a file with a damaged index. FFmpeg may stop early or produce an output with missing packets. Rebuild the index with `-fflags +genpts`.
- Expecting stream-copy to fix the source. If the source has bad timestamps, the output will too; the copy is byte-faithful.