我正在尝试在 Ubuntu 12.10 中进行一些直播,但音频方面出现了一些问题。更具体地说,质量非常糟糕,并且与视频至少有 10 秒不同步。
我正在使用一个优秀的指南找到这里设置我的环回设备,以便我可以将桌面音频与麦克风输入结合起来。这似乎有效,因为我能够将音频和视频流式传输到 Twitch.tv。但是,正如我所说,音频质量很糟糕。麦克风音频非常非常低,但如果我增加它,我会得到绝对无法忍受的可怕的乱码声音。在 VoIP 通话期间或使用录音机单独录音时不会出现这种情况,所以这不是麦克风本身的问题。与视频流相比,整个音频流也延迟了大约 10-15 秒。
我整理了我的设置的 imgur 相册。
以下是我在流式传输时的一些示例输出:
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':
Metadata:
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.
有什么办法可以解决这个问题吗?视频延迟完全可以接受,所以我不认为是网络问题导致了音频延迟。
任何帮助,将不胜感激。
答案1
11090 nevon 20 0 526m 109m 14m S 101,4 0,7 1:14.19 avconv
我怀疑这是关键所在。 avconv
似乎正在单线程运行,并且完全限制了它所运行的 CPU 核心。您的系统使用哪种视频芯片组?您可能需要运行 vdpau(假设您使用 nvidia)才能正常运行。
它是可能的但我认为问题不太可能出在音频本身——您可以尝试只捕获一个通道而不是两个,并且使用较低的比特率,看看是否有帮助。不过,我真的认为问题出在视频上。