Is there a way to trim off N samples from audio file using SoX / FFmpeg or the likes of?
Asked
Active
Viewed 2,873 times
2 Answers
8
Using SoX trim :
sox in.wav out.wav trim 0s 1000s
Trims first 1000 samples with 0 samples offset.
's' here means 'sample', not 'second'. To trim by 'seconds' you should remove 's'
To trim specified range of sample(s):
sox in.wav out.wav trim 5000s 100s
Trims 100 samples, from 5000 to 5100 (5000s - samples offset, 100s - number of samples to trim after offset)
sox in.wav out.wav trim 123456788s 1s
Trims 123456789-nd sample (123456788s - samples offset, 1s - number of samples to trim after offset)

Vasyl Shumskyi
- 133
- 1
- 7
2
Use the atrim filter:
ffmpeg -i input -af atrim=start_sample=65614:end_sample=102400 output
start_sample
- The number of the first sample that should be output.end_sample
- The number of the first sample that should be dropped.

llogan
- 121,796
- 28
- 232
- 243
-
Thanks! Exactly what i needed. Is it possible to combine both of the parameters to get N-th sample with one FFmpeg invocation (let's say 123456789)? I've tried ffmpeg -i input.wav -af atrim=start_sample=123456788 -af atrim=end_sample=123456789 output.wav – Vasyl Shumskyi Oct 02 '16 at 07:21
-