[FFmpeg-devel] [PATCH] libspeex encoder

Justin Ruggles justin.ruggles
Tue Jul 7 01:51:22 CEST 2009


Art Clarke wrote:
> On Sat, Jun 20, 2009 at 10:08 PM, Justin Ruggles
> <justin.ruggles at gmail.com>wrote:
> 
>> Hi,
>>
>> This patch adds Speex encoding through libspeex.  It depends on the
>> speex-in-ogg muxer patch I sent earlier.
>>
>> The sample rate must match 8000, 16000, or 32000.
>> Both mono and stereo are supported.
>> CBR mode is the default.
>> Using -aq (or CODEC_FLAG_QSCALE and global_quality) turns on VBR mode.
>> (global_quality 0.0 to 10.0)
>> Using -compression_level changes the encoding complexity.
>> (compression_level 1 to 10)
>>
>> Thanks,
>> Justin
>>
> 
> 
> Ah, found it :)
> 
> I like your approach on VBR and compression setting much better than mine.
> We still have the problem of how many frames per packet to use (sure would
> be nice if we could get it from AVCodecContext).  Here's my other thoughts:
> 
> 0) SPEEX_FRAMES_PER_PACKET of 10 results in 200ms of audio data per packet
> -- which in some ways defeats the purpose of using Speex (for example, we
> want to use speex to reduce the speech latency in a conferencing
> application).  We really need to make that configurable so users can
> determine if they want increased latency (your approach) or increased
> overhead (Adobe's).

That would be nice, but I think for now I prefer your approach of using
2 frames-per-packet so it will play nice with FLV.

> 1) Try it with my FLV muxer patch and see if you can make the resulting FLV
> play with Adobe's Flash player.  I had to add the bit-termination stuff for
> that -- but who knows, that might have been user error during testing.

Well, that is what speexenc does, but I looked at the libspeex source
and it shouldn't matter.  The terminator is only added if the frame is
not byte-aligned.  So you should end up with the same data either way.

> 2) I like using the SpeexHeader to maintain things like packet_size in your
> LibSpeexEncContext rather than separate fields like packet_size.

ok.

> 3) Once you set the mode in speex you don't need to separately set the
> SPEEX_SET_SAMPLING_RATE.

Ah, I didn't know that. Thanks.

> 4) You may want to add the FLT code from my patch if you want to support the
> FMT_FLT audio sample type

Yes.

> 5) You check buf_size for being too small AFTER you write to it.  You
> probably want to check before you write.  Use speex_bits_nbytes to detect
> how many bytes needed.

Well, speex_bits_write() will only write as many bytes as you tell it
to, so there is no problem doing this.  But your approach might be
better anyway since mine does not properly handle the case where the
output size is exactly the same as buf_size.  I'll change it.

-Justin


-- 
Justin



More information about the ffmpeg-devel mailing list