FFmpeg’s trim filter selects a continuous section of video but keeps the selected frames’ timestamps. If the output needs to start at zero, put setpts=PTS-STARTPTS after trim; if the delivery should retain its original timeline position, do not rebase it. A changed timestamp origin is not a way to correct which frames were selected.
Decide and apply the filter order
Use a zero-based clock when the excerpt is meant to play as a standalone clip or must align with another zero-based sequence. Retain the original timing when a downstream workflow needs the excerpt’s position on the source timeline. Check the receiving workflow’s requirement rather than assuming every export must begin at zero.
- Define the desired kept interval. FFmpeg documents
startas the timestamp of the first kept frame andendas the timestamp of the first frame dropped. It also offers frame-count options such asstart_frameandend_frame; these are different selection criteria, not timestamp resets. - Decide whether the output clock should preserve the selected frames’ source positions or begin at zero.
- For zero-based output, place
setpts=PTS-STARTPTSafter the trim filter, for exampletrim=60:120,setpts=PTS-STARTPTS. The documented trim example selects the second minute; the added filter rebases the resulting video timestamps. - Inspect the output’s first-frame timestamp and confirm the kept visual content begins where intended. Treat these as separate checks: timestamp origin verifies the clock, while visual inspection verifies the selection.
The order matters because STARTPTS refers to the first frame arriving at setpts. After trimming, that is the first frame passed through the trim filter. The FFmpeg trim documentation explicitly says trim does not modify timestamps and recommends a following setpts filter for zero-based output. The setpts documentation defines STARTPTS as the first input frame’s PTS and shows PTS-STARTPTS as the expression for starting PTS counting at zero.
Acceptance worksheet
The figures below are hypothetical, chosen to show the checks rather than promise a particular file’s timestamps. Assume a source has a frame at PTS 12 seconds, followed by frames at 12.04 and 12.08 seconds. Assume the intended trim starts at 12 seconds and includes those frames. The documentation’s trim=60:120 example selects the second minute of an input; it does not establish that this hypothetical source has particular frame timestamps or that those example bounds apply to it.
| Check | Hypothetical observation | Decision |
|---|---|---|
| Source before trim | First frame in the intended section is at PTS 12.00 s | Record the source position as the comparison point |
After trim | The same visual first frame remains at PTS 12.00 s | Selection kept the frame; its timestamp was not rebased |
After setpts=PTS-STARTPTS | That visual frame is at PTS 0.00 s | Accept the new origin if zero-based delivery is required |
| Following frames | The same pictured frames remain in order; their example PTS become 0.00, 0.04, 0.08 s | Check identity and spacing separately from the origin |
The worksheet’s frame identities and intervals are assumed observations, not FFmpeg test results. Compare recognizable frames before and after re-basing; subtracting the first PTS should shift their time origin, not serve as evidence that a different cut boundary was selected.
Limits and next steps
A non-zero first PTS is not automatically an error. Rebasing may be wrong if a later edit expects source-timeline positions. Also, this procedure addresses video PTS: FFmpeg documents setpts for video frames and asetpts for audio. Do not infer from this video filter alone that audio timestamps have also been rebased.
If the first output timestamp is not the expected value, inspect the filter order and determine which frames actually reach setpts; then check the produced file’s timestamps with a suitable media inspection tool. If the first visual frame is wrong, revisit the trim interval or selection method instead of changing the clock expression. If audio must share the new origin, review the audio path and its timing separately. The cited filter documentation describes filter behavior; it does not guarantee a particular container’s final timestamps or a specific editor’s interpretation.
Common questions
Does `trim=60:120` start output at zero? No. It selects frames by timestamp interval; trim does not change their timestamps. Add a following rebase only if the delivery requires it.
Will rebasing change the chosen frames? The expression changes PTS, not the trim selection rule. Verify frame identity and the first-frame time independently in the output.
Must every trimmed clip start at zero? No. Use zero when the receiving edit or delivery requires a standalone, zero-based clock; preserve source timing when the workflow needs the original position.
Sources and next step
This guide interprets public documentation and uses explicitly hypothetical acceptance examples, not application tests. Controls and availability can change; verify the cited manual against your installed version.
For work created in Imagild, carry the input requirements and acceptance checklist into the film workspace. The external software controls discussed above belong to their respective products.