[FFmpeg-user] FLV streaming, severe audio sync issues

Rena hyperhacker at gmail.com
Wed Apr 17 00:18:45 CEST 2013


I'm trying to capture from my screen to stream to twitch.tv RTMP server,
but the audio is always going way out of sync. After one minute of
recording the audio is 4 seconds behind. I've tried everything I can find
and nothing is helping. Updating to a recent ffmpeg build only seems to
have made it worse.

For testing I have it recording to a local file instead of to RTMP server:
$ ffmpeg -f pulse -sample_rate 22050 -i
alsa_output.pci-0000_00_14.2.analog-stereo.monitor -f x11grab -show_region
1 -s 850x480 -r 12 -i :0.0+3160,200 -vcodec libx264 -s 850x480 -b:v 384k
-b:a 64k -threads 0 -g 3 -f flv out.flv
ffmpeg version N-51651-g1fabd95 Copyright (c) 2000-2013 the FFmpeg
developers
  built on Apr  6 2013 21:44:28 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
  configuration: --enable-gpl --enable-version3 --enable-nonfree
--enable-avresample --enable-avisynth --enable-libass --enable-libfreetype
--enable-libmp3lame --enable-libopencv --enable-libpulse --enable-librtmp
--enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvpx
--enable-libx264 --enable-openssl --enable-x11grab
  libavutil      52. 25.100 / 52. 25.100
  libavcodec     55.  2.100 / 55.  2.100
  libavformat    55.  1.100 / 55.  1.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 49.100 /  3. 49.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, pulse, from 'alsa_output.pci-0000_00_14.2.analog-stereo.monitor':
  Duration: N/A, start: 0.000000, bitrate: 705 kb/s
    Stream #0:0: Audio: pcm_s16le, 22050 Hz, stereo, s16, 705 kb/s
[x11grab @ 0x25b84a0] device: :0.0+3160,200 -> display: :0.0 x: 3160 y: 200
width: 850 height: 480
[x11grab @ 0x25b84a0] shared memory extension found
Input #1, x11grab, from ':0.0+3160,200':
  Duration: N/A, start: 1366150061.077213, bitrate: 156672 kb/s
    Stream #1:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 850x480, 156672
kb/s, 12 tbr, 1000k tbn, 12 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x25d0180] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2 AVX XOP FMA4 SSEMisalign LZCNT
[libx264 @ 0x25d0180] profile High 4:4:4 Predictive, level 2.2, 4:4:4 8-bit
[libx264 @ 0x25d0180] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec
- Copyleft 2003-2012 - http://www.videolan.org/x264.html - 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=4 threads=12 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=2 b_pyramid=2
b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=3
keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=3 rc=abr mbtree=1
bitrate=384 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':
  Metadata:
    encoder         : Lavf55.1.100
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv444p, 850x480,
q=-1--1, 384 kb/s, 1k tbn, 12 tbc
    Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 22050 Hz, stereo,
s16p, 64 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
[swscaler @ 0x2592320] Warning: data is not aligned! This can lead to a
speedloss
frame= 1269 fps= 12 q=32766.0 Lsize=    6223kB time=00:01:50.54 bitrate=
461.2kbits/s
video:5267kB audio:864kB subtitle:0 global headers:0kB muxing overhead
1.488966%
[libx264 @ 0x25d0180] frame I:424   Avg QP:38.55  size: 11698
[libx264 @ 0x25d0180] frame P:558   Avg QP:46.10  size:   622
[libx264 @ 0x25d0180] frame B:287   Avg QP:47.69  size:   300
[libx264 @ 0x25d0180] consecutive B-frames: 54.8% 45.2%  0.0%
[libx264 @ 0x25d0180] mb I  I16..4: 34.9% 47.8% 17.3%
[libx264 @ 0x25d0180] mb P  I16..4:  2.0%  2.7%  0.2%  P16..4:  5.2%  0.7%
0.2%  0.0%  0.0%    skip:88.9%
[libx264 @ 0x25d0180] mb B  I16..4:  0.1%  0.4%  0.0%  B16..8:  6.4%  0.3%
0.0%  direct: 0.2%  skip:92.5%  L0:39.6% L1:59.5% BI: 0.9%
[libx264 @ 0x25d0180] final ratefactor: 39.24
[libx264 @ 0x25d0180] 8x8 transform intra:48.4% inter:80.1%
[libx264 @ 0x25d0180] coded y,u,v intra: 28.2% 18.4% 18.5% inter: 0.4% 0.5%
0.5%
[libx264 @ 0x25d0180] i16 v,h,dc,p: 46% 48%  4%  2%
[libx264 @ 0x25d0180] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 26% 29%  4%  3%
3%  4%  2%  6%
[libx264 @ 0x25d0180] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 31% 13%  4%  6%
4%  4%  3%  3%
[libx264 @ 0x25d0180] Weighted P-Frames: Y:0.9% UV:0.9%
[libx264 @ 0x25d0180] ref P L0: 94.7%  1.6%  3.7%
[libx264 @ 0x25d0180] kb/s:407.99


The system has no trouble handling the load, but the resulting video always
has severe audio lag.
-- 
Sent from my Game Boy.


More information about the ffmpeg-user mailing list