[FFmpeg-user] How can I get byte-accurate segments?
barsnick at gmx.net
Fri Feb 12 10:08:19 CET 2016
On Thu, Feb 11, 2016 at 17:19:47 -0700, Grant Curtis wrote:
> I'm working with a Speech-to-text service that wants audio files that are
> exactly 160kb large, which means 80,000 16-bit samples
Which makes this uncompressed "raw audio", basically.
> So far I've converted my video stream into an audio file with a sampling
> rate of 16,000 and converted it to s16le. Now I just have to grab 80,000
> samples out of it.
> Is there any way to do that? Or perhaps I need to begin with a source file
> in a specific bitrate so that the math lines up?
16000 samples per second, a total of 80000 samples, that makes exactly
five seconds, right? Regardless of your input, it should be no issue
telling ffmpeg this length: "-t 5".
On the other hand, you don't mention the word "segment" in your text,
just in the subject. Do you want to take an input file of arbitrary
length, and split it into segments of exactly five seconds each? You
should probably have a look at the segment muxer then:
I fail to get constant length output there though. Hmmm. I have no idea
why. With videos and keyframes and the likes, I understand the issue.
$ ffmpeg -t 35 -f lavfi -i anoisesrc -map 0:a -c:a pcm_s16le -ac 1 -ar 16000 -f segment -segment_time 5 -segment_format s16le out.%03d.raw
More information about the ffmpeg-user