Trim the input so that the output contains one continuous subpart of the input.
This filter accepts the following options:
- start
-
Timestamp (in seconds) of the start of the kept section. I.e. the audio sample with the timestamp start will be the first sample in the output.
- end
-
Timestamp (in seconds) of the first audio sample that will be dropped. I.e. the audio sample immediately preceding the one with the timestamp end will be the last sample in the output.
- start_pts
-
Same as start, except this option sets the start timestamp in samples instead of seconds.
- end_pts
-
Same as end, except this option sets the end timestamp in samples instead of seconds.
- duration
-
Maximum duration of the output in seconds.
- start_sample
-
Number of the first sample that should be passed to output.
- end_sample
-
Number of the first sample that should be dropped.
Note that the first two sets of the start/end options and the duration option look at the frame timestamp, while the _sample options simply count the samples that pass through the filter. So start/end_pts and start/end_sample will give different results when the timestamps are wrong, inexact or do not start at zero. Also note that this filter does not modify the timestamps. If you wish that the output timestamps start at zero, insert the asetpts filter after the atrim filter.
If multiple start or end options are set, this filter tries to be greedy and keep all samples that match at least one of the specified constraints. To keep only the part that matches all the constraints at once, chain multiple atrim filters.
The defaults are such that all the input is kept. So it is possible to set e.g. just the end values to keep everything before the specified time.
Examples:
-
drop everything except the second minute of input
ffmpeg -i INPUT -af atrim=60:120
-
keep only the first 1000 samples
ffmpeg -i INPUT -af atrim=end_sample=1000