[FFmpeg-user] How can I get byte-accurate segments?
Paul B Mahol
onemda at gmail.com
Fri Feb 12 12:44:47 CET 2016
On 2/12/16, Moritz Barsnick <barsnick at gmx.net> wrote:
> On Fri, Feb 12, 2016 at 11:02:32 +0100, Paul B Mahol wrote:
>> ffmpeg -f lavfi -i
>> anoisesrc=sample_rate=16000:duration=35:nb_samples=16000 -map 0:a -c:a
>> pcm_s16le -ac 1 -f segment -segment_time 5 -segment_format s16le
> Well, anoisesrc was just an for creating arbitrary input. The original
> poster may not be able to influence the sample rate and number of
> samples in his input. Therefore I sought after other flags to influence
>> You can't resample after, you will get different number of samples
>> per packet.
> So, in the real world: Would you recommend inserting the aresample
> filter? (And possibly something for downmixing to mono.)
> My head is spinning. Samples, packets, frames. How do they relate in
> audio? Especially regarding this codec.
> I would have thought that, in the path from codec to muxer, the concept
> of frames would be somewhat broken down, and (for this particular
> codec) there would be a frame per sample. Or is it a packet per sample?
> Or neither of the two?
> Anyway, I would have thought that this codec, being "key frame only",
> could and would be cut at exact points, assuming the sample rate allows
> an exact number of samples to fit into the given time interval.
> Carl Eugen's response was better than both of mine: Just try to solve
> the problem, don't try to understand all the mechanisms. ;-)
Use aresample=16000,asetnsamples=16000 and it should work
More information about the ffmpeg-user