What You Will Learn
- The meaning and usage of
-ss(start position),-to(end position), and-t(duration) - The behavioral difference between placing
-ssbefore vs. after the input (speed vs. accuracy) - Fast trimming with stream copy (
-c copy) and its precision limitations - Frame-accurate trimming with re-encoding
- How to use time formats (
HH:MM:SS.msand seconds)
Tested version: Verified with FFmpeg 6.1 (ubuntu-latest / CI-validated) Target OS: Windows / macOS / Linux
Basic Options Reference
| Option | Position | Description |
|---|---|---|
-ss position | Before input or before output | Specifies where processing starts |
-to position | Before output | Specifies where processing ends (absolute timestamp from file start) |
-t duration | Before input or before output | Specifies the duration to process |
-toand-tcannot be used together. If both are specified,-ttakes precedence (per the FFmpeg official documentation).
Time Formats
FFmpeg accepts two styles of time specification.
| Format | Example | Description |
|---|---|---|
HH:MM:SS | 00:01:30 | 1 minute 30 seconds |
HH:MM:SS.ms | 00:01:30.500 | 1 minute 30 seconds 500 milliseconds |
| Seconds (decimal allowed) | 90 or 90.5 | 90 seconds (or 90.5 seconds) |
Input-Side -ss vs. Output-Side -ss (Most Important)
The position of -ss is the single biggest factor controlling trimming speed and accuracy.
Input-Side -ss (Fast Seek / Keyframe-Based)
ffmpeg -ss 00:01:00 -i input.mp4 -to 00:02:00 -c copy output.mp4
Placing -ss before -i causes FFmpeg to perform a fast seek (fast seek) to the keyframe immediately before the specified time.
- Benefit: Completes in seconds even for large files
- Drawback: The result is rounded to a keyframe boundary, so the output may start slightly before the specified time
Output-Side -ss (Slow Seek / Frame-Accurate)
ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy output.mp4
Placing -ss after -i causes FFmpeg to decode from the beginning of the file up to the specified frame.
- Benefit: Cuts from the exact frame at the specified time
- Drawback: Very slow for extracting segments from late in a long video, because it decodes from the start
Which Should You Use?
| Use Case | Recommendation |
|---|---|
| Fast extraction with stream copy (-c copy) | Input-side -ss (speed priority) |
| Frame-accurate cut required | Input-side -ss + re-encoding (see below) |
| Quickly extracting a short clip for review | Input-side -ss |
Fast Trimming with Stream Copy (-c copy)
Extremely fast because no re-encoding occurs. However, accuracy depends on keyframe boundaries.
ffmpeg -ss 00:00:30 -i input.mp4 -to 00:01:30 -c copy output.mp4
ffmpeg -ss 90 -i input.mp4 -t 60 -c copy output.mp4
Notes:
- If the start point does not coincide with a keyframe, the beginning of the output may show visual artifacts (block noise)
- Because
-c copyskips re-encoding, file size depends on the source material
Accurate Trimming (with Re-Encoding)
For frame-accurate cuts, combine input-side -ss with re-encoding. Input-side -ss performs a fast seek, then re-encoding begins from there — a good balance of speed and accuracy.
ffmpeg -ss 00:00:30 -i input.mp4 -to 00:01:30 -c:v libx264 -crf 23 -c:a aac output.mp4
Specifying by duration:
ffmpeg -ss 00:01:00 -i input.mp4 -t 30 -c:v libx264 -crf 23 -c:a aac output.mp4
Choosing Between -to and -t
-to: Specify by End Timestamp
ffmpeg -ss 00:01:00 -i input.mp4 -to 00:03:00 -c copy output.mp4
This example extracts 2 minutes from 1:00 to 3:00. -to is an absolute timestamp from the file start.
-t: Specify by Duration
ffmpeg -ss 00:01:00 -i input.mp4 -t 120 -c copy output.mp4
This example extracts 120 seconds (2 minutes) starting at 1:00. Convenient because you do not need to calculate the end time.
Common Pitfalls
Output Beginning Looks Corrupted with -c copy
Cause: The cut start point is not a keyframe, so the decoder cannot correctly reconstruct frames.
Fix: Re-encode with -c:v libx264 -c:a aac, or adjust the start point to a keyframe position.
-to Timestamp Behavior Is Affected by Input-Side -ss
Behavior may vary depending on the FFmpeg version and situation. If results are unexpected, replacing -to with -t (duration) gives more predictable results.
Output Has No Audio or No Video
Verify that audio and/or video streams exist in the source. Also check that -an (no audio) or -vn (no video) has not been specified unintentionally.
Related Articles
Tested with: ffmpeg 6.1.1 / Ubuntu 24.04 (GitHub Actions runner) Primary sources: ffmpeg.org/ffmpeg.html / trac.ffmpeg.org/wiki/Seeking / ffmpeg.org/ffmpeg-formats.html