SV: [Speex-dev] Optimal frame size to use for file compression?

Jonas Tärnström njt at
Sat Sep 9 16:03:21 PDT 2006

22050 hz is not optimal for a codec intended for 8000 (narrow band),
16000 (wide band) or 32000 (ultra wideband).
Depending on the quality needs for your specific implementation I would
pick one of the above modes and feed the codec 160, 320 or 640 samples
of the total stream each call to speex_encode. AFAIK the frame size is
hard coded for each speex encoder mode. The documentation should clear
this out for you.

//Regards JT

-----Ursprungligt meddelande-----
Från: speex-dev-bounces at [mailto:speex-dev-bounces at] För
Peter Gien
Skickat: den 9 september 2006 22:15
Till: speex-dev at
Ämne: [Speex-dev] Optimal frame size to use for file compression?

I have raw PCM data that is 180 seconds long and sampled at 22050
samples per second. The data is 16-bit speech audio, male and female
My question is: What is a good frame size to use if I capture the
entire audio stream first and then want to compress it  for later

I noticed that the example encoder code calls:


and I notice that this has the following memory allocation:

bits->bytes = (char*)speex_alloc(MAX_BYTES_PER_FRAME);
bits->buf_size = MAX_BYTES_PER_FRAME;

Somewhere else I noticed that MAX_BYTES_PER_FRAME is #defined to be

So I think the maximum practical value for a frame size is around 1000
samples although we could go higher if we could predict the

So what is a good practical value for FRAME_SIZE with my application
parameters? I need good compression and good performance. SInce these
are usually opposing goals, I'll settle for something in the middle

Thanks in advance. (BTW, Speex is a gem.)

Speex-dev mailing list
Speex-dev at

More information about the Speex-dev mailing list