[FFmpeg-user] ALSA buffer xrun. (ALSA_BUFFER_SIZE_MAX overflow)

Nicolas George nicolas.george at normalesup.org
Sun Mar 17 15:35:05 CET 2013


Le septidi 27 ventôse, an CCXXI, Johann Rekowski a écrit :
> Hello again dear ffmpeg developers,
> I might have a clue why these ALSA buffer xruns happen when I record
> my stuff. I have changed:
> *
> libavdevice/alsa-audio.h*
> from/#define ALSA_BUFFER_SIZE_MAX 65536/ (standard setting)
> to///#define ALSA_BUFFER_SIZE_MAX 131072/
> 
> I'm trying to record a game with x11grab.
> This is what I use to record my desktop & game:
> /ffmpeg -f alsa -ac 2 -i hw:2,1 -f x11grab -r 30 -s 1920x1080 -i
> :0.0 -acodec pcm_s16le -vcodec huffyuv -threads 8 output.avi/ (Using
> huffyuv now, because it drains less CPU than ffv1.3)
> 
> With the standard setting on the *ALSA_BUFFER_SIZE_MAX* I had buffer
> xruns happening at around this frame:
> frame= 2488 fps= 30 q=0.0 size= 6853401kB time=00:01:22.93
> bitrate=676966.2kbits
> 
> I kinda made a routine to test for errors on that subject so it's
> almost always happening around the same frame.
> 
> After changing the *ALSA_BUFFER_SIZE_MAX* to a higher value (I just
> doubled the standard value) the video went on smooth without buffer
> xruns for a longer period of time, though buffer xruns still
> happened, just at a later frame:
> frame= 4677 fps= 30 q=0.0 size=13727448kB time=00:02:35.90
> bitrate=721329.4kbits
> ALSA buffer xrun.

Can you show the output of the following command:

arecord -D hw:2,1 -f S16_LE -c 2 -r 44100 -v > /dev/null

? Just the part about period and buffer should be enough.

Also, the value of buffer_size inside alsa-audio-common.c may be
interesting. You can get it by just adding:

av_log(0, 16, "buffer_size = %d\n", buffer_size);

at the proper place.

> One buffer xrun ruins the whole audio that comes after it and makes
> my game lag horribly so it has to stop and never happen at all.

What does happen if you run two separate instances of ffmpeg: one for the
audio, and one for the video, with the video one niced?

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20130317/8afa428a/attachment.asc>


More information about the ffmpeg-user mailing list