I'm trying to do some live streaming in Ubuntu 12.10, but I'm having some problems with audio. More specifically, the quality is complete garbage and it's at least 10 seconds out of sync with the video.

I'm using an excellent guide found here to set up my loopback devices so that I can combine the desktop audio with the microphone input. It seems to work, as I'm able to stream both audio and video to Twitch.tv. But, as I said, the audio quality is terrible. The microphone audio is very, very low, but if I increase it, I get a horrible garbled sound that is absolutely unbearable. Nothing like that is present during VoIP calls or when recording sound alone with the sound recorder, so it's not an issue with the microphone itself. The entire audio stream is also delayed about 10-15 seconds compared to the video stream.

I put together an imgur album of my settings.

Here is some example output from when I'm streaming:

avconv version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:51:11 with gcc 4.7.2
[x11grab @ 0x162fd80] device: :0.0+570,262 -> display: :0.0 x: 570 y: 262 width: 1280 height: 720
[x11grab @ 0x162fd80] shared memory extension  found
[x11grab @ 0x162fd80] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+570,262':
  Duration: N/A, start: 1353181686.735113, bitrate: 884736 kb/s
    Stream #0.0: Video: rawvideo, bgra, 1280x720, 884736 kb/s, 30 tbr, 1000k tbn, 30 tbc
[alsa @ 0x163fce0] capture with some ALSA plugins, especially dsnoop, may hang.
[alsa @ 0x163fce0] Estimating duration from bitrate, this may be inaccurate
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1353181686.773841, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
Incompatible pixel format 'bgra' for codec 'libx264', auto-selecting format 'yuv420p'
[buffer @ 0x1641ec0] w:1280 h:720 pixfmt:bgra
[scale @ 0x1642480] w:1280 h:720 fmt:bgra -> w:852 h:480 fmt:yuv420p flags:0x4
[libx264 @ 0x165ae80] VBV maxrate unspecified, assuming CBR
[libx264 @ 0x165ae80] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x165ae80] profile Main, level 3.1
[libx264 @ 0x165ae80] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=1 b_bias=0 direct=1 weightb=0 open_gop=1 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=cbr mbtree=1 bitrate=712 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=712 vbv_bufsize=512 nal_hrd=none ip_ratio=1.25 aq=1:1.00
Output #0, flv, to 'rtmp://live.justin.tv/app/live_23011330_Pt1plSRM0z5WVNJ0QmCHvTPmpUnfC4':
    encoder         : Lavf53.21.0
    Stream #0.0: Video: libx264, yuv420p, 852x480, q=-1--1, 712 kb/s, 1k tbn, 30 tbc
    Stream #0.1: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 712 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
  Stream #1:0 -> #0:1 (pcm_s16le -> libmp3lame)
Press ctrl-c to stop encoding
frame=   17 fps=  0 q=0.0 size=       0kB time=10000000000.00 bitrate=   0.0kbitframe=   32 fps= 31 q=0.0 size=       0kB time=10000000000.00 bitrate=   0.0kbitframe=   40 fps= 23 q=29.0 size=      44kB time=0.03 bitrate=13786.2kbits/s dup=frame=   47 fps= 21 q=31.0 size=      93kB time=2.73 bitrate= 277.7kbits/s dup=0frame=   62 fps= 23 q=29.0 size=     160kB time=3.23 bitrate= 406.2kbits/s dup=0frame=   77 fps= 24 q=23.0 size=     209kB time=3.71 bitrate= 462.5kbits/s dup=0frame=   92 fps= 25 q=20.0 size=     267kB time=4.91 bitrate= 445.2kbits/s dup=0frame=  107 fps= 25 q=20.0 size=     318kB time=5.41 bitrate= 482.1kbits/s dup=0frame=  123 fps= 26 q=18.0 size=     368kB time=5.96 bitrate= 505.7kbits/s dup=0frame=  139 fps= 26 q=16.0 size=     419kB time=6.48 bitrate= 529.7kbits/s dup=0frame=  155 fps= 27 q=15.0 size=     473kB time=7.00 bitrate= 553.6kbits/s dup=0frame=  170 fps= 27 q=14.0 size=     525kB time=7.52 bitrate= 571.7kbits/s dup=0
frame=  180 fps= 25 q=-1.0 Lsize=     652kB time=7.97 bitrate= 670.0kbits/s dup=0 drop=32

//Here I stop the streaming

video:531kB audio:112kB global headers:0kB muxing overhead 1.345945%
[libx264 @ 0x165ae80] frame I:1     Avg QP:30.43  size: 39748
[libx264 @ 0x165ae80] frame P:45    Avg QP:11.37  size: 11110
[libx264 @ 0x165ae80] frame B:134   Avg QP:15.93  size:    27
[libx264 @ 0x165ae80] consecutive B-frames:  0.6%  0.0%  1.7% 97.8%
[libx264 @ 0x165ae80] mb I  I16..4:  7.3%  0.0% 92.7%
[libx264 @ 0x165ae80] mb P  I16..4:  0.1%  0.0%  0.1%  P16..4: 49.1%  1.2%  2.1%  0.0%  0.0%    skip:47.4%
[libx264 @ 0x165ae80] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.1%  0.0%  0.0%  direct: 0.0%  skip:99.9%  L0:42.5% L1:56.9% BI: 0.6%
[libx264 @ 0x165ae80] coded y,uvDC,uvAC intra: 82.3% 87.4% 71.9% inter: 7.1% 8.4% 7.0%
[libx264 @ 0x165ae80] i16 v,h,dc,p: 27% 29% 16% 28%
[libx264 @ 0x165ae80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 21% 14%  8%  8%  8%  7%  5%  7%
[libx264 @ 0x165ae80] i8c dc,h,v,p: 47% 22% 20% 11%
[libx264 @ 0x165ae80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x165ae80] ref P L0: 96.4%  3.6%
[libx264 @ 0x165ae80] kb/s:474.19
Received signal 2: terminating.

Any ideas on how I can resolve this? The video delay is perfectly acceptable, so I wouldn't think that it's a network issue that's causing the delay in the audio.

Any help would be appreciated.

EDIT: Output from top and iotop.

  • Can you post output from top and iotop while streaming and getting awful quality? (Need to make sure it's not a simple case of CPU and/or I/O contention.) – Jim Salter Nov 25 '12 at 21:55
  • @JimSalter There, I've added links to the output of both top and iotop (I had to host them on external sites, as I exceeded the character limit by about 100,000 characters). – Tommy Brunn Nov 26 '12 at 14:13
11090 nevon     20   0  526m 109m  14m S 101,4  0,7   1:14.19 avconv

I suspect this is the key here. avconv seems to be running single-threaded and is completely pegging the CPU core it's running under. What sort of video chipset does your system have? You may need to get vdpau (assuming you have nvidia) running in order to get things running properly.

It's possible but seems unlikely to me that the problem could be the audio itself - you might try only capturing one channel rather than two and at a lower bitrate, to see if that helps. I really think it's going to be the video that's the issue, though.

  • It's an Nvidia Geforce GTX 460, using the new 310.14 drivers. I'll try capturing only the microphone input, and see if it's equally garbled then. – Tommy Brunn Nov 26 '12 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.