To keep frames whose presentation timestamps fall within a time interval, use FFmpeg’s select filter with a time predicate such as between(t,10,20). Decide whether both endpoints belong in your interval, then check the timestamps of the frames near each boundary. This selects frames by timestamp; it does not request a fixed number of frames or convert the video to a fixed frame rate.
Choose the condition and check its units
The filter evaluates its expression for each input frame. A result of zero discards that frame. Otherwise, the result determines the output: negative values and NaN go to the first output; nonnegative values go to output index ceil(val)-1. With the default single output, Boolean conditions such as between(t,10,20) return 1 when true and 0 when false, so matching frames pass and nonmatching frames are discarded. FFmpeg defines t as the frame’s presentation timestamp (PTS) in seconds and pts as that timestamp in units of the input time base, exposed as TB. For a time interval written in seconds, t is usually the more direct choice. Use pts only when you know the input time base and have converted the desired boundaries into its units. See the official `select` filter documentation.
Follow these steps:
- Write down the intended start and end times, and decide whether each endpoint is included.
- For an interval measured in seconds, express the condition as
select='between(t,10,20)'. FFmpeg’s documented example uses this 10–20-second condition. - If you need strict rather than inclusive endpoints, express the comparisons explicitly, for example
gt(t,10)*lt(t,20). Choose the operators to match the brief; do not assume that “between” excludes its boundaries. - Apply the filter in the video filter chain. The documented examples show
selectused with-vf, including in combination with another frame condition. - Inspect the actual timestamps around the start and end of the selected result. Record whether frames exactly on either boundary are present, if such frames exist.
The official expression-function reference defines between(x,min,max) as 1 when x is in the inclusive range from min to max, and 0 otherwise. Thus a timestamp equal to either limit passes. For strict endpoints, gt(t,10)*lt(t,20) requires t to be greater than 10 and less than 20. These are predicate rules, not a promise that a particular source contains a frame exactly on either limit. See the official expression evaluation documentation.
Acceptance worksheet: hypothetical 10–20 seconds
The following observations are invented to show how to audit the condition, not expected output from FFmpeg. Suppose timestamp inspection of a source reports the rows below. The predicate is the documented between(t,10,20) example.
Frame PTS time t | Predicate result | Audit decision |
|---|---|---|
| 9.967 s | False | Before the interval; should not pass |
| 10.000 s | True | Start boundary is included |
| 10.033 s | True | Inside the interval; should pass |
| 19.967 s | True | Inside the interval; should pass |
| 20.000 s | True | End boundary is included |
| 20.033 s | False | After the interval; should not pass |
For a real source, replace these hypothetical rows with observed frame timestamps. Your acceptance record should name the first and last passing timestamps and say whether an exact-boundary frame was observed. If no frame lands exactly on a boundary, that does not change the predicate’s inclusive rule; it means that boundary case was not present to observe.
Limits and what to do when results differ
A time interval does not imply a fixed frame count. The number selected depends on the timestamps of the frames in the input and which satisfy the expression. Do not replace a timestamp condition with n just to get a familiar count: n is the sequential number of the filtered input frame, while t and pts refer to presentation time.
Use a frame-index trim when the actual requirement is a continuous range defined by frame numbers. Use frame-rate conversion when the requirement is to produce a different output cadence. Those are different jobs from deciding, frame by frame, whether its timestamp satisfies a predicate. FFmpeg documents select as selecting frames to pass; its examples also show combining time and picture-type conditions. See the official filter examples.
If unexpected frames pass, first compare the expression with the intended endpoint policy, then check the observed timestamps and whether the relevant PTS is defined. The documentation says t and pts can be NAN when unavailable; it does not guarantee that every input supplies a usable timestamp. If timestamps are missing or unsuitable, do not infer the correct time from frame count alone. Inspect the source’s timestamp behavior and choose a workflow that establishes the timing needed for your edit.
Three quick questions
Does `between(t,10,20)` include 20 seconds? Yes. The interval includes both limits. Use explicit strict comparisons if the end must be excluded.
Does `pts` mean seconds? No. It is expressed in the input time-base units. `t` is the PTS in seconds.
Will selecting 10 seconds always keep the same number of frames? No. The filter keeps frames whose timestamps satisfy the condition; the selected count depends on the input timestamps.
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.