[FFmpeg-user] ffmpeg cannot capture audio from capture card

Md Ismail, Zakiah zakiah.md.ismail at intel.com
Wed Jul 31 06:14:22 EEST 2019


Hi all,

I am using ffmpeg to record HDMI audio on another machine - using a capture card.
The capture card looks as follow: https://www.amazon.com/EZCAP-Capture-Recorder-Windows-Streaming/dp/B075T8C1GY.
The capture card is not connected to any monitor - I use a HDMI dummy that looks as follow: https://www.amazon.com/NewerTech-Headless-Video-Accelerator-Dummy/dp/B01ASJCZFK.

On the host, output of arecord -l is as follow:
$ sudo arecord -l
card 11: nuc-03i [ezcap U3 capture], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 12: nuc-03i-usb [USB Audio CODEC], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

As you can see, the HDMI capture card (ezcap U3 capture) is in the list. Then, I ran the following command on the host, while playing a video on the target:
$ sudo ffmpeg -f alsa -i hw:CARD=nuc-03i,DEV=0 -t 30 test-03i-debug.wav -loglevel debug
ffmpeg version 4.0.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'alsa'.
Reading option '-i' ... matched as input url with argument 'hw:CARD=nuc-03i,DEV=0'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '30'.
Reading option 'test-03i-debug.wav' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url hw:CARD=nuc-03i,DEV=0.
Applying option f (force format) with argument alsa.
Successfully parsed a group of options.
Opening an input file: hw:CARD=nuc-03i,DEV=0.
[alsa @ 0x5643d94d4400] All info found
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:CARD=nuc-03i,DEV=0':
  Duration: N/A, start: 1564539037.140202, bitrate: 1536 kb/s
    Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: output url test-03i-debug.wav.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 30.
Successfully parsed a group of options.
Opening an output file: test-03i-debug.wav.
[file @ 0x5643d94e8240] Setting default whitelist 'file,crypto'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
detected 4 logical cores
[graph_0_in_0_0 @ 0x5643d94eb740] Setting 'time_base' to value '1/48000'
[graph_0_in_0_0 @ 0x5643d94eb740] Setting 'sample_rate' to value '48000'
[graph_0_in_0_0 @ 0x5643d94eb740] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_0 @ 0x5643d94eb740] Setting 'channel_layout' to value '0x3'
[graph_0_in_0_0 @ 0x5643d94eb740] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
[format_out_0_0 @ 0x5643d94ec0c0] Setting 'sample_fmts' to value 's16'
[AVFilterGraph @ 0x5643d94ea300] query_formats: 5 queried, 12 merged, 0 already done, 0 delayed
Output #0, wav, to 'test-03i-debug.wav':
  Metadata:
    ISFT            : Lavf58.12.100
    Stream #0:0, 0, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc58.18.100 pcm_s16le
[out_0_0 @ 0x5643d94ec840] EOF on sink link out_0_0:default.=0.244x
No more output streams to write to, finishing.
size=       1kB time=00:00:27.37 bitrate=   0.4kbits/s speed=0.243x
video:0kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.685131%
Input file #0 (hw:CARD=nuc-03i,DEV=0):
  Input stream #0:0 (audio): 8 packets read (1568 bytes); 8 frames decoded (392 samples);
  Total: 8 packets (1568 bytes) demuxed
Output file #0 (test-03i-debug.wav):
  Output stream #0:0 (audio): 7 frames encoded (343 samples); 7 packets muxed (1372 bytes);
  Total: 7 packets (1372 bytes) muxed
8 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x5643d94e83c0] Statistics: 4 seeks, 4 writeouts

The audio capture was not successful - the output file is always a 1KB/2KB file that cannot be played at all.
My knowledge on ffmpeg is limited - can any of you help or just give me clues of what this might be?

Extra information:
I have another capture card connected to target but this is to record audio from the audio jack instead of HDMI. I am able to record audio for that without any issue.

$ sudo ffmpeg -f alsa -i hw:CARD=nuc-03i-usb,DEV=0 -t 30 test-03i-soundcard.wav -loglevel debug
ffmpeg version 4.0.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'alsa'.
Reading option '-i' ... matched as input url with argument 'hw:CARD=nuc-03i-usb,DEV=0'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '30'.
Reading option 'test-03i-soundcard.wav' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url hw:CARD=nuc-03i-usb,DEV=0.
Applying option f (force format) with argument alsa.
Successfully parsed a group of options.
Opening an input file: hw:CARD=nuc-03i-usb,DEV=0.
[alsa @ 0x55f5103ae400] All info found
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:CARD=nuc-03i-usb,DEV=0':
  Duration: N/A, start: 1564542205.434050, bitrate: 1536 kb/s
   Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: output url test-03i-soundcard.wav.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 30.
Successfully parsed a group of options.
Opening an output file: test-03i-soundcard.wav.
File 'test-03i-soundcard.wav' already exists. Overwrite ? [y/N] y
[file @ 0x55f5103c2440] Setting default whitelist 'file,crypto'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
detected 4 logical cores
[graph_0_in_0_0 @ 0x55f5103c6000] Setting 'time_base' to value '1/48000'
[graph_0_in_0_0 @ 0x55f5103c6000] Setting 'sample_rate' to value '48000'
[graph_0_in_0_0 @ 0x55f5103c6000] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_0 @ 0x55f5103c6000] Setting 'channel_layout' to value '0x3'
[graph_0_in_0_0 @ 0x55f5103c6000] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
[format_out_0_0 @ 0x55f5103c2980] Setting 'sample_fmts' to value 's16'
[AVFilterGraph @ 0x55f5103c4bc0] query_formats: 5 queried, 12 merged, 0 already done, 0 delayed
Output #0, wav, to 'test-03i-soundcard.wav':
  Metadata:
    ISFT            : Lavf58.12.100
    Stream #0:0, 0, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc58.18.100 pcm_s16le
[out_0_0 @ 0x55f5103c7100] EOF on sink link out_0_0:default.=1.05x
No more output streams to write to, finishing.
size=    5625kB time=00:00:30.00 bitrate=1536.0kbits/s speed=1.05x
video:0kB audio:5625kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.001354%
Input file #0 (hw:CARD=nuc-03i-usb,DEV=0):
  Input stream #0:0 (audio): 13018 packets read (5760192 bytes); 13018 frames decoded (1440048 samples);
  Total: 13018 packets (5760192 bytes) demuxed
Output file #0 (test-03i-soundcard.wav):
  Output stream #0:0 (audio): 13017 frames encoded (1439949 samples); 13017 packets muxed (5759796 bytes);
  Total: 13017 packets (5759796 bytes) muxed
13018 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x55f5103c2600] Statistics: 4 seeks, 25 writeouts

Regards,
Zakiah



More information about the ffmpeg-user mailing list