[FFmpeg-devel] rtmp buffering

Howard Chu hyc
Mon May 24 20:02:00 CEST 2010

Tom Janiszewski wrote:
> I've been working with the built-in support in ffmpeg for rtmp (not
> librtmp, but the avformat rtmpproto/pkt implementation), and had a
> question about buffering:  Currently the rtmp stream reading uses the
> default IO buffer size of 32768.  Is it possible to reduce this to
> provide lower-latency on the rtmp read?
> Depending on the rtmp codec settings, anywhere from 5-20 packets will
> buffer up before being processed by ffmpeg, which usually translates to
> latency of 500-1000ms.  Is this something that should be changed in
> rtmpproto.c (i.e. max_packet_size) or is there a way to set the max
> buffer size at the application level?

It looks like IO_BUFFER_SIZE 32768 in aviobuf.c and max_packet_size are the 
only available settings. Mucking with max_packet_size would probably be a bad 
idea since RTMP packets can have widely varying sizes.

Perhaps just change rtmp_read() to return at most 1 packet's worth of data at 
a time.

   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

More information about the ffmpeg-devel mailing list