[FFmpeg-user] ffmpeg - avfoundation Audio stutters / sounds broken with screen capture [sample, config, output included]

kevin kevincastiglione at gmail.com
Sun Apr 26 05:42:12 CEST 2015


I am trying to do a basic screen capture in OS X [10.10.3] with audio from
mic using avfoundation.
The recorded audio is stuttering, breaks, or there is short bursts.


This is the command I use [ffmpeg installed with brew, config and output
below]

ffmpeg -f avfoundation -i "1:0" -r 25  -c:v libx264 -preset fast -crf 22
-c:a libfdk_aac  -b:a 128k -ar 44100 -s 640x480 screen.mp4

I tried different codec, bitrate, and audio is broken in all.

Here is link to the recorded file in which audio is broken:
play on web: https://www.dropbox.com/s/p7ej68mrhi2te8r/screen.mp4?dl=0
downloadable link: https://www.dropbox.com/s/p7ej68mrhi2te8r/screen.mp4?dl=1


However if I capture with FaceTime camera, the audio is great and works
fine.

Can you please suggest what I can do to fix the audio with screen capture.
Thank you for a great library ffmpeg! Please let me know if I need to add
any other info.


Output of command:

 ffmpeg -f avfoundation -i "1:0" -r 25  -c:v libx264 -preset fast -crf 22
-c:a libfdk_aac  -b:a 128k -ar 44100 -s 640x480 screen.mp4
ffmpeg version 2.6.1 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM
3.6.0svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.1 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags=
--enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid
--enable-libfreetype --enable-libvorbis --enable-libvpx --enable-libfaac
--enable-libass --enable-ffplay --enable-libfdk-aac --enable-openssl
--enable-libopus --enable-libquvi --enable-libx265 --enable-nonfree
--enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[avfoundation @ 0x7f9b89001400] Selected pixel format (yuv420p) is not
supported by the input device.
[avfoundation @ 0x7f9b89001400] Supported pixel formats:
[avfoundation @ 0x7f9b89001400]   uyvy422
[avfoundation @ 0x7f9b89001400]   yuyv422
[avfoundation @ 0x7f9b89001400]   nv12
[avfoundation @ 0x7f9b89001400]   0rgb
[avfoundation @ 0x7f9b89001400]   bgr0
[avfoundation @ 0x7f9b89001400] Overriding selected pixel format to use
uyvy422 instead.
[avfoundation @ 0x7f9b89001400] Stream #0: not enough frames to estimate
rate; consider increasing probesize
Input #0, avfoundation, from '1:0':
  Duration: N/A, start: 0.368389, bitrate: N/A
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1440x900,
1000k tbr, 1000k tbn, 1000k tbc
    Stream #0:1: Audio: pcm_f32le, 44100 Hz, stereo, flt, 2822 kb/s
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x7f9b89103200] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.1 Cache64
[libx264 @ 0x7f9b89103200] profile High 4:2:2, level 3.0, 4:2:2 8-bit
[libx264 @ 0x7f9b89103200] 264 - core 144 r2533 c8a773e - H.264/MPEG-4 AVC
codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options:
cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=3
lookahead_threads=1 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=1 keyint=250 keyint_min=25
scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=22.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'screen.mp4':
  Metadata:
    encoder         : Lavf56.25.101
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p,
640x480, q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.26.100 libx264
    Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 44100
Hz, stereo, s16, 128 kb/s
    Metadata:
      encoder         : Lavc56.26.100 libfdk_aac
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_f32le (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame=  255 fps= 25 q=-1.0 Lsize=     286kB time=00:00:10.19 bitrate=
229.8kbits/s dup=102 drop=0
video:137kB audio:136kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 4.737433%
[libx264 @ 0x7f9b89103200] frame I:2     Avg QP:20.52  size: 46726
[libx264 @ 0x7f9b89103200] frame P:65    Avg QP:23.32  size:   640
[libx264 @ 0x7f9b89103200] frame B:188   Avg QP:31.27  size:    22
[libx264 @ 0x7f9b89103200] consecutive B-frames:  1.6%  0.0%  1.2% 97.3%
[libx264 @ 0x7f9b89103200] mb I  I16..4: 15.7% 48.2% 36.1%
[libx264 @ 0x7f9b89103200] mb P  I16..4:  0.0%  0.0%  0.4%  P16..4:  0.8%
 0.1%  0.0%  0.0%  0.0%    skip:98.7%
[libx264 @ 0x7f9b89103200] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.2%
 0.0%  0.0%  direct: 0.0%  skip:99.8%  L0:38.8% L1:61.2% BI: 0.0%
[libx264 @ 0x7f9b89103200] 8x8 transform intra:43.0% inter:2.5%
[libx264 @ 0x7f9b89103200] coded y,uvDC,uvAC intra: 37.2% 37.7% 33.9%
inter: 0.0% 0.1% 0.0%
[libx264 @ 0x7f9b89103200] i16 v,h,dc,p: 60% 40%  0%  0%
[libx264 @ 0x7f9b89103200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 87%  8%  3%  0%
 0%  0%  0%  0%  1%
[libx264 @ 0x7f9b89103200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 39% 12%  3%
 3%  3%  6%  3%  8%
[libx264 @ 0x7f9b89103200] i8c dc,h,v,p: 74% 11% 14%  1%
[libx264 @ 0x7f9b89103200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7f9b89103200] ref P L0: 73.8% 26.2%
[libx264 @ 0x7f9b89103200] ref B L0: 95.1%  4.9%
[libx264 @ 0x7f9b89103200] ref B L1: 95.1%  4.9%
[libx264 @ 0x7f9b89103200] kb/s:109.18
live at MAC:~$ du -h screen.mp4
288K    screen.mp4


More information about the ffmpeg-user mailing list