[FFmpeg-user] Desktop audio falls behind when recording microphone + desktop audio + screen using ffmpeg

Anders Ytterström anders.ytterstrom at gmail.com
Fri Sep 13 00:09:21 CEST 2013


I have put together this script for recording my microphone, my desktop 
audio and my screen using ffmpeg:

    DATE=`which date`
    RESO=2560x1440
    FPS=30
    PRESET=ultrafast
    DIRECTORY=$HOME/Video/
    FILENAME=videocast`$DATE +%d%m%Y_%H.%M.%S`.mkv

    ffmpeg -y -vsync 1 \
    -f pulse -ac 2 -i 
alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
    -f pulse -ac 1 -ar 25000 -i 
alsa_input.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-mono \
    -filter_complex aresample=async=1,amix=duration=shortest,apad \
    -f x11grab -r $FPS -s $RESO -i :0.0 \
    -acodec libvorbis \
    -vcodec libx264 -pix_fmt yuv420p -preset $PRESET -threads 0 \
    $DIRECTORY$FILENAME

Everything is recorded and between the screen and the microphone sound 
there are no issues what so ever, however the desktop audio falls 
behind badly. 

It begins in sync but gets worse over time during playback, also in 
ffplay. It does not matter what application I am getting sound from: 
both Dota 2 (linux native) and Rhythmbox (playing a couple of seconds 
of song then stops, wait and repeat) gets out of sync.

The terminal output complain about 

"ALSA lib pcm.c:7843:(snd_pcm_recover) overrun occurred22.73 
bitrate=10384.5kbits/s    
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred" 

and similarbut I do not know what that means.

Full terminal output here:
http://pastie.org/8321237

Please help me, I am really close to get this working! 

Best regards,
Anders Ytterström


More information about the ffmpeg-user mailing list