Practical audio guide
How to Trim Audio Without Re-encoding
A trim does not always require a new encode. If the source codec can live in the selected output container, FFmpeg can copy compressed packets from the chosen interval. This avoids generation loss and is fast, but boundaries follow codec packet structure.
Key takeaways
- Keep the source format to maximize the chance of stream copy.
- Do not request bitrate, channel, sample-rate, or effect changes during a lossless trim.
- Compressed packet boundaries may not land on an arbitrary decoded sample.
- Re-encode only when exact boundaries or a different format are more important than avoiding generation loss.
What stream copy preserves
Stream copy moves encoded packets without running a decoder and encoder. The copied section retains its codec, bitrate behavior, and encoded quality. Container metadata may still be rewritten because a new file is created.
Why timestamps can move slightly
Compressed audio groups samples into frames. A decoder can play from within that structure, but a standalone copied file must begin with valid packet data. The practical cut can therefore align to a nearby frame boundary.
When re-encoding is required
Changing MP3 to M4A, changing bitrate, mixing channels, adjusting volume, normalizing loudness, or applying fades all require decoding and encoding. WAV PCM can be cut very precisely because its samples are not stored in perceptual codec frames.
Measured example
We retained seconds 10 through 25 of a 60-second, 320 kbps MP3 using stream copy. The 2.40 MB source produced a 0.60 MB, 15-second clip—approximately one quarter of the duration and size, with no new MP3 encode.
Method and sources
Examples use controlled synthetic references so settings are reproducible and no private user audio is involved. Production runs FFmpeg 5.1.9; benchmark fixtures were generated and verified with FFmpeg 8.1.2.