Sign up ×
Sound Design Stack Exchange is a question and answer site for sound engineers, producers, editors, and enthusiasts. It's 100% free, no registration required.

I've been using avconv to capture my screen and audio input and stream live to, but the audio is always about a second or two behind the video. This doesn't seem to be an issue on the remote end, as I get the same result saving to a local file.

The audio is coming from a capture card (Dazzle DVC100) and the video is the capture card's input displayed in mplayer along with some other windows. Locally, the audio and video are in perfect sync.

The script I'm using to run avconv is:

INRES="850x480" # input resolution
SCREENPOS="+3160,200" #X, Y offset to grab on screen
FPS="12" # target FPS
BITRATE="-b 192k"

if [ "$1" = "live" ]; then
    # output to live stream and to local file
    FILE="/home/rena/video/live/live-`date '+%a-%y%m%d-%H%M%S'`.flv"
    OUTPUT="-f flv rtmp://$STREAM_KEY -f flv $FILE"
    if [ "$1" = "test" ]; then
        OUTPUT="-f flv out.flv" # output to video file
        echo "usage: $0 [live|test]"
        exit 1

#order matters here! need to set the sample rate before specifying the input source.
AUDIO="-f pulse -sample_rate $ARATE -i alsa_input.usb-Pinnacle_Systems_GmbH_DVC100-01-DVC100.analog-stereo"

#more quality/speed tweaks
TWEAKS="-g 3 -filter_complex asyncts=min_delta\=0"

#stuff that probably shouldn't be changed for the most part

avconv $AUDIO -b 2k -f x11grab -show_region 1 -s "$INRES" -r "$FPS" $TWEAKS -i :0.0$SCREENPOS -vcodec "$VCODEC" -s "$OUTRES" $BITRATE -threads 0 $OUTPUT

The asyncts filter seems to help a lot (without it, the audio could be as much as 3 minutes behind by the end of a 10-minute video) but still the audio is always about 2 seconds behind the video.

Things that I've tried that haven't helped:

  • Decreasing audio sampling rate (no effect)
  • Increasing audio sampling rate (FLV doesn't support any higher)
  • Using the -itsoffset flag to delay the video stream (no effect, the flag doesn't seem to be doing anything)
  • Adjusting the video and audio bitrates (no effect, unless using a very high bitrate, then video frames drop and the audio lag is more noticeable)

The last item makes me think that there might be frames dropping, but it doesn't look like they are. I had read about a similar issue someone had, that was related to "duplicate" frames being dropped. I'm not sure how to test or correct frame drop issues, though.

The ffmpeg command is: ffmpeg -f pulse -sample_rate 22050 -i alsa_input.pci-0000_00_14.2.analog-stereo -b:v 2k -f x11grab -show_region 1 -s 850x480 -r 12 -g 3 -i :0.0+3160,200 -vcodec libx264 -s 850x480 -b 192k -threads 0 -f flv out.flv

The output from ffmpeg is:

WARNING: gnome-keyring:: couldn't connect to: /run/user/rena/keyring-QDecyk/pkcs11: No such file or directory
ffmpeg version 0.10.6-6:0.10.6-0ubuntu0jon1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 12 2012 12:53:40 with gcc 4.7.2
  configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.10.6-0ubuntu0jon1' --libdir=/usr/lib/x86_64-linux-gnu --disable-stripping --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[pulse @ 0x12bdbe0] Estimating duration from bitrate, this may be inaccurate
Input #0, pulse, from 'alsa_input.pci-0000_00_14.2.analog-stereo':
  Duration: N/A, start: 0.314092, bitrate: N/A
    Stream #0:0: Audio: pcm_s16le, 22050 Hz, 2 channels, s16, 705 kb/s
[x11grab @ 0x12bb480] device: :0.0+3160,200 -> display: :0.0 x: 3160 y: 200 width: 850 height: 480
[x11grab @ 0x12bb480] shared memory extension found
[x11grab @ 0x12bb480] Estimating duration from bitrate, this may be inaccurate
Input #1, x11grab, from ':0.0+3160,200':
  Duration: N/A, start: 1365239924.136518, bitrate: 156672 kb/s
    Stream #1:0: Video: rawvideo (BGRA / 0x41524742), bgra, 850x480, 156672 kb/s, 12 tbr, 1000k tbn, 12 tbc
Please use -b:a or -b:v, -b is ambiguous
Incompatible pixel format 'bgra' for codec 'libx264', auto-selecting format 'yuv420p'
[buffer @ 0x12bc6c0] w:850 h:480 pixfmt:bgra tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 0x12bc7a0] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
[scale @ 0x12cd8e0] w:850 h:480 fmt:bgra -> w:850 h:480 fmt:yuv420p flags:0x4
[libx264 @ 0x12b9e60] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX XOP FMA4 SSEMisalign LZCNT
[libx264 @ 0x12b9e60] profile High, level 2.2
[libx264 @ 0x12b9e60] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=12 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=192 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'out.flv':
    encoder         : Lavf53.32.100
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 850x480, q=-1--1, 192 kb/s, 1k tbn, 12 tbc
    Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 22050 Hz, 2 channels, s16, 128 kb/s
Stream mapping:
  Stream #1:0 -> #0:0 (rawvideo -> libx264)
  Stream #0:0 -> #0:1 (pcm_s16le -> libmp3lame)
Press [q] to stop, [?] for help
frame=  118 fps= 12 q=-1.0 Lsize=     285kB time=00:00:05.06 bitrate= 460.7kbits/s    
video:200kB audio:79kB global headers:0kB muxing overhead 2.037969%
[libx264 @ 0x12b9e60] frame I:1     Avg QP:26.90  size: 28427
[libx264 @ 0x12b9e60] frame P:74    Avg QP:30.63  size:  1968
[libx264 @ 0x12b9e60] frame B:43    Avg QP:37.52  size:   701
[libx264 @ 0x12b9e60] consecutive B-frames: 40.7% 28.8% 10.2% 20.3%
[libx264 @ 0x12b9e60] mb I  I16..4: 42.1% 28.1% 29.8%
[libx264 @ 0x12b9e60] mb P  I16..4:  2.4%  1.9%  0.8%  P16..4:  9.7%  1.7%  1.2%  0.0%  0.0%    skip:82.3%
[libx264 @ 0x12b9e60] mb B  I16..4:  0.2%  0.2%  0.2%  B16..8:  9.7%  0.9%  0.1%  direct: 0.3%  skip:88.5%  L0:46.5% L1:51.7% BI: 1.8%
[libx264 @ 0x12b9e60] final ratefactor: 30.71
[libx264 @ 0x12b9e60] 8x8 transform intra:35.7% inter:44.7%
[libx264 @ 0x12b9e60] coded y,uvDC,uvAC intra: 24.9% 38.3% 28.7% inter: 2.1% 3.7% 1.5%
[libx264 @ 0x12b9e60] i16 v,h,dc,p: 66% 32%  2%  0%
[libx264 @ 0x12b9e60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9% 11% 61%  3%  4%  3%  3%  2%  3%
[libx264 @ 0x12b9e60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 23% 27%  4%  6%  4%  4%  3%  4%
[libx264 @ 0x12b9e60] i8c dc,h,v,p: 50% 25% 22%  3%
[libx264 @ 0x12b9e60] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x12b9e60] ref P L0: 67.4%  6.1% 17.0%  9.6%
[libx264 @ 0x12b9e60] ref B L0: 80.8% 16.8%  2.4%
[libx264 @ 0x12b9e60] ref B L1: 96.0%  4.0%
[libx264 @ 0x12b9e60] kb/s:166.14
share|improve this question

migrated from Jan 24 '14 at 12:01

This question came from our site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation.

avconv is buggy. Have you tried a recent static build of ffmpeg? The actual, unscripted command and the complete console output from ffmpeg would be useful if it also does not work as expected. –  LordNeckbeard Mar 2 '13 at 0:43
I've added the command and output. Updating to the latest build from hasn't helped. –  Rena Apr 6 '13 at 9:23
Unfortunately the PPA does not offer the latest builds. –  LordNeckbeard Apr 6 '13 at 18:54
Alright, I got the latest from source and compiled it, but the audio lags behind worse than ever. –  Rena Apr 9 '13 at 8:28

1 Answer 1

Try using a different Audio input, like Audacity. It's a great microphone recorder and when broadcasting, you can ask the viewers how you sound and change the audio levels and such. If you were to do a local recording, you would have to sync the audio up, but it's usually not a big hassle.

Audacity Link:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.