ffmpeg cannot grab the audio played through the speaker under windows 10

3

I am using ffmpeg to grab screen. It used to work well under win7 using UScreenCapture and virtual-audio-capturer (all x86 version). On win10, the audio is not recorded. (I cannot hear any sound while playing back). I am using ffmpeg/uscreencapture/virtual-audio-capturer all win32 version since virtual-audio-capturer has no x64 release.

So my question is: How can I record the video and the audio correctly using ffmpeg?

Here is the screen dump out: first the direct show devices on my system

C:\ffmpeg-20190403-ee16d14-win32-static\bin>ffmpeg -list_devices true -f dshow -i dummy
ffmpeg version N-93528-gee16d14b0a Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20190212
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 48.101 / 58. 48.101
  libavformat    58. 26.101 / 58. 26.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[dshow @ 06303ac0] DirectShow video devices (some may be both video and audio devices)
[dshow @ 06303ac0]  "UScreenCapture"
[dshow @ 06303ac0]     Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\UScreenCapture"
[dshow @ 06303ac0] DirectShow audio devices
[dshow @ 06303ac0]  "Microphone Array (Realtek(R) Audio)"
[dshow @ 06303ac0]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{9F102091-1843-44C8-B20E-C6F2E0F11A0F}"
[dshow @ 06303ac0]  "virtual-audio-capturer"
[dshow @ 06303ac0]     Alternative name "@device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\{8E14549B-DB61-4309-AFA1-3578E927E935}"
dummy: Immediate exit requested

2nd, when I use virtual audio capturer, ffmpeg just failed:

C:\ffmpeg-20190403-ee16d14-win32-static\bin>ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone Array (Realtek(R) Audio)" -vf crop=1075:717:189:81 -vcodec mpeg4 -qscale 0 -framerate 60 -acodec libmp3lame -ab 128000 -async 1 output.aviffmpeg -f dshow -i video="UScreenCapture":audio="virtual-audio-capturer" -vf crop=1075:717:189:81 -vcodec mpeg4 -qscale 0 -framerate 60 -acodec libmp3lame -ab 128000 -async 1 output.avi
ffmpeg version N-93528-gee16d14b0a Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20190212
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 48.101 / 58. 48.101
  libavformat    58. 26.101 / 58. 26.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, dshow, from 'video=UScreenCapture:audio=Microphone Array (Realtek(R) Audio)':
  Duration: N/A, start: 6333.289000, bitrate: N/A
    Stream #0:0: Video: rawvideo, bgr24, 3200x1080, 15 fps, 15 tbr, 10000k tbn, 10000k tbc
    Stream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
IMMDeviceEnumerator::GetDefaultAudioEndpoint failed: hr = 0x80070490
[dshow @ 062f4ac0] real-time buffer [UScreenCapture] [video input] too full or near too full (340% of size: 3041280 [rtbufsize parameter])! frame dropped!

When I use the other audio devices, it seems working but there is not audio recorded:

ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone Array (Realtek(R) Audio)" -vf crop=1075:717:189:81 -vcodec mpeg4 -qscale 0 -framerate 60 -acodec libmp3lame -ab 128000 -async 1 output.avi

    C:\ffmpeg-20190403-ee16d14-win32-static\bin>ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone Array (Realtek(R) Audio)" -vf crop=1075:717:189:81 -vcodec mpeg4 -qscale 0 -framerate 60 -acodec libmp3lame -ab 128000 -async 1 output.avi
    ffmpeg version N-93528-gee16d14b0a Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 8.2.1 (GCC) 20190212
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
      libavutil      56. 26.100 / 56. 26.100
      libavcodec     58. 48.101 / 58. 48.101
      libavformat    58. 26.101 / 58. 26.101
      libavdevice    58.  7.100 / 58.  7.100
      libavfilter     7. 48.100 /  7. 48.100
      libswscale      5.  4.100 /  5.  4.100
      libswresample   3.  4.100 /  3.  4.100
      libpostproc    55.  4.100 / 55.  4.100
    Guessed Channel Layout for Input Stream #0.1 : stereo
    Input #0, dshow, from 'video=UScreenCapture:audio=Microphone Array (Realtek(R) Audio)':
      Duration: N/A, start: 6168.067000, bitrate: N/A
        Stream #0:0: Video: rawvideo, bgr24, 3200x1080, 15 fps, 15 tbr, 10000k tbn, 10000k tbc
        Stream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Please use -q:a or -q:v, -qscale is ambiguous
    Stream mapping:
      Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
      Stream #0:1 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
    Press [q] to stop, [?] for help
    -async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.
    Output #0, avi, to 'output.avi':
      Metadata:
        ISFT            : Lavf58.26.101
        Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p(progressive), 1075x717, q=2-31, 200 kb/s, 15 fps, 15 tbn, 15 tbc
        Metadata:
          encoder         : Lavc58.48.101 mpeg4
        Side data:
          cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
        Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
        Metadata:
          encoder         : Lavc58.48.101 libmp3lame
    frame=    8 fps=0.0 q=0.0 size=     522kB time=00:00:00.53 bitrate=8013.1kbitsframe=   16 fps= 16 q=0.0 size=    1034kB time=00:00:01.06 bitrate=7938.7kbitsframe=   23 fps= 15 q=0.0 size=    1546kB time=00:00:01.53 bitrate=8258.0kbitsframe=   31 fps= 15 q=0.0 size=    2058kB time=00:00:02.06 bitrate=8156.4kbitsframe=   38 fps= 15 q=0.0 size=    2058kB time=00:00:02.53 bitrate=6653.9kbitsframe=   46 fps= 15 q=0.0 size=    2570kB time=00:00:03.06 bitrate=6864.4kbitsframe=   54 fps= 15 q=0.0 size=    3082kB time=00:00:03.60 bitrate=7012.6kbitsframe=   61 fps= 15 q=0.0 size=    3338kB time=00:00:04.06 bitrate=6723.5kbitsframe=   69 fps= 15 q=0.0 size=    3850kB time=00:00:04.60 bitrate=6855.8kbitsframe=   76 fps= 15 q=0.0 size=    4106kB time=00:00:05.06 bitrate=6638.2kbitsframe=   84 fps= 15 q=0.0 size=    4618kB time=00:00:05.60 bitrate=6755.0kbitsframe=   91 fps= 15 q=0.0 size=    4874kB time=00:00:06.06 bitrate=6581.1kbitsframe=   99 fps= 15 q=0.0 size=    5130kB time=00:00:06.60 bitrate=6367.0kbitsframe=  106 fps= 15 q=0.0 size=    5642kB time=00:00:07.06 bitrate=6540.1kbitsframe=  114 fps= 15 q=0.0 size=    6154kB time=00:00:07.66 bitrate=6575.3kbitsframe=  121 fps= 15 q=0.0 size=    6410kB time=00:00:08.13 bitrate=6455.9kbitsframe=  129 fps= 15 q=0.0 size=    6666kB time=00:00:08.66 bitrate=6300.6kbitsframe=  136 fps= 15 q=0.0 size=    6922kB time=00:00:09.13 bitrate=6208.3kbitsframe=  144 fps= 15 q=0.0 size=    7434kB time=00:00:09.66 bitrate=6299.7kbitsframe=  151 fps= 15 q=0.0 size=    7690kB time=00:00:10.13 bitrate=6216.5kbitsframe=  159 fps= 15 q=0.0 size=    7946kB time=00:00:10.66 bitrate=6102.3kbitsframe=  167 fps= 15 q=0.0 size=    8458kB time=00:00:11.20 bitrate=6186.2kbitsframe=  174 fps= 15 q=0.0 size=    8970kB time=00:00:11.66 bitrate=6298.3kbitsframe=  182 fps= 15 q=0.0 size=    8970kB time=00:00:12.20 bitrate=6022.9kbitsframe=  189 fps= 15 q=0.0 size=    9482kB time=00:00:12.66 bitrate=6132.2kbitsframe=  190 fps= 15 q=0.0 Lsize=    9602kB time=00:00:12.73 bitrate=6177.3kbits/s speed=   1x
    video:9382kB audio:194kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.265721%
    [dshow @ 06393f40] real-time buffer [UScreenCapture] [video input] too full or near too full (340% of size: 3041280 [rtbufsize parameter])! frame dropped!
    Exiting normally, received signal 2.
audio
ffmpeg
windows-10
asked on Stack Overflow Apr 8, 2019 by shangping

1 Answer

1

I finally got a solution to this under windows 10: Microphone can only get the sound through the air, which may capture undesired voice and quality may be not good. Fortunately we have the alternative solution:

  1. download vb cable from https://www.vb-audio.com/Cable/
  2. unzip and run vbcable_setup.exe under administrator mode
  3. open sound setting, two devices are added: cable input for playback and cable output for recording

  4. make the two devices default devices

  5. select the recording device cable output and select property.
  6. check 'listen to this device' and select playback device as the speaker. (so the sound will finally go to the speaker)

after all this go to ffmpeg by running: ffmpeg -list_devices -f dshow -i dummy the following device name will appear: 'audio-CABLE Output (VB-Audio Virtual Cable)'

Use this as the audio capture device and the problem is solved.

answered on Stack Overflow Apr 19, 2019 by shangping

User contributions licensed under CC BY-SA 3.0