Home

atrim

atrim is an audio filter in FFmpeg’s libavfilter that trims an input audio stream by discarding samples outside a specified interval. It is commonly used to remove silence at the beginning or end of a track, or to cut a section from a recording. The filter preserves audio properties such as sample rate and channel layout.

The filter accepts time-based and sample-based specifications. Time-based trimming uses start and end in seconds (or

Examples illustrate typical usage. To trim a 5 to 25 second segment from an input file and

Notes: atrim is a standard FFmpeg filter available in typical builds. It does not perform resampling or

fractions),
while
sample-based
trimming
uses
start_sample
and
end_sample.
The
general
syntax
is
atrim=start=...:end=...[:start_sample=...[:end_sample=...]]
and
can
be
applied
to
an
audio
stream
with
-filter:a
in
FFmpeg
command
lines.
If
end
is
omitted,
trimming
continues
to
the
end
of
the
stream;
if
start
is
omitted,
trimming
begins
at
the
start.
Combining
with
asetpts=PTS-STARTPTS
is
common
to
reset
timestamps
after
trimming.
reset
timestamps,
you
would
use:
ffmpeg
-i
input.mp3
-filter:a
"atrim=start=5:end=25,asetpts=PTS-STARTPTS"
output.mp3.
For
sample-based
trimming,
to
keep
samples
1000
through
5000,
you
could
use:
ffmpeg
-i
input.wav
-filter:a
"atrim=start_sample=1000:end_sample=5000,asetpts=PTS-STARTPTS"
output.wav.
Either
approach
can
be
combined
with
other
filters
as
part
of
a
complex
audio
processing
workflow.
format
conversion
by
itself;
use
additional
filters
if
needed
for
format
changes.