私はDebian 9とそのバージョンのffmpegを使用しています。これはffmpeg
画面録画に使用するコマンドです。
ffmpeg -thread_queue_size 4096 -f alsa -i plughw:CARD=Device,DEV=0 -thread_queue_size 4096 \
-f alsa -i default -filter_complex amix=inputs=2:duration=first -thread_queue_size 4096 \
-f x11grab -r 30 -s 1920x1080 -i $DISPLAY+1920,0 -c:v libx264 -crf 20 -preset veryfast \
-c:a aac -ac 2 -b:a 96k -pix_fmt yuv420p -movflags faststart output.mp4
システムサウンドとマイクを同時に正常に録音できます。ただし、まず電源を入れ、pavucontrol
入力デバイスタブでシステムオーディオがデフォルトに設定されていることを確認する必要がありました。を使用しているように、システムサウンドの特定のデバイス名を使用できるようにしたいと思いますplughw:CARD=Device,DEV=0
。しかし、何を使うべきかわかりません。システムサウンドの-f pulse -i alsa_output.pci-0000_00_14.2.analog-stereo.monitor
場合は使用できますが、録画された映像ファイルは約15秒ほどディレイが発生します。だから-f alsa -i $device_name
。
出力は次のとおりですpacmd list-sources
。
2 source(s) available.
index: 0
name: <alsa_input.usb-0c76_USB_PnP_Audio_Device-00.analog-mono>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause:
priority: 9049
volume: mono: 63923 / 98% / -0.65 dB
balance 0.00
base volume: 19944 / 30% / -31.00 dB
volume steps: 65537
muted: no
current latency: 1.85 ms
max rewind: 0 KiB
sample spec: s16le 1ch 48000Hz
channel map: mono
Mono
used by: 1
linked by: 1
configured latency: 40.00 ms; range is 0.50 .. 2000.00 ms
card: 2 <alsa_card.usb-0c76_USB_PnP_Audio_Device-00>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "USB Audio"
alsa.id = "USB Audio"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "2"
alsa.card_name = "USB PnP Audio Device"
alsa.long_card_name = "USB PnP Audio Device at usb-0000:00:10.1-1, full speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:10.1-usb-0:1:1.0"
sysfs.path = "/devices/pci0000:00/0000:00:10.1/usb5/5-1/5-1:1.0/sound/card2"
udev.id = "usb-0c76_USB_PnP_Audio_Device-00"
device.bus = "usb"
device.vendor.id = "0c76"
device.vendor.name = "JMTek, LLC."
device.product.id = "161e"
device.product.name = "USB PnP Audio Device"
device.serial = "0c76_USB_PnP_Audio_Device"
device.string = "hw:2"
device.buffering.buffer_size = "192000"
device.buffering.fragment_size = "96000"
device.access_mode = "mmap+timer"
device.profile.name = "analog-mono"
device.profile.description = "Analog Mono"
device.description = "USB PnP Audio Device Analog Mono"
alsa.mixer_name = "USB Mixer"
alsa.components = "USB0c76:161e"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-usb"
ports:
analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-input-microphone"
active port: <analog-input-mic>
* index: 1
name: <alsa_output.pci-0000_00_14.2.analog-stereo.monitor>
driver: <module-alsa-card.c>
flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause:
priority: 1950
volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 0.00 ms
max rewind: 344 KiB
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 1
linked by: 1
configured latency: 40.00 ms; range is 0.50 .. 1999.82 ms
monitor_of: 0
card: 3 <alsa_card.pci-0000_00_14.2>
module: 9
properties:
device.description = "Monitor of Built-in Audio Analog Stereo"
device.class = "monitor"
alsa.card = "0"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfeb00000 irq 16"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:14.2"
sysfs.path = "/devices/pci0000:00/0000:00:14.2/sound/card0"
device.bus = "pci"
device.vendor.id = "1022"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
device.product.id = "780d"
device.product.name = "FCH Azalia Controller"
device.form_factor = "internal"
device.string = "0"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
出力は次のとおりですarecord -L
。
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=Generic
HD-Audio Generic, ALC662 rev3 Analog
Default Audio Device
front:CARD=Generic,DEV=0
HD-Audio Generic, ALC662 rev3 Analog
Front speakers
dmix:CARD=Generic,DEV=0
HD-Audio Generic, ALC662 rev3 Analog
Direct sample mixing device
dmix:CARD=Generic,DEV=2
HD-Audio Generic, ALC662 rev3 Alt Analog
Direct sample mixing device
dsnoop:CARD=Generic,DEV=0
HD-Audio Generic, ALC662 rev3 Analog
Direct sample snooping device
dsnoop:CARD=Generic,DEV=2
HD-Audio Generic, ALC662 rev3 Alt Analog
Direct sample snooping device
hw:CARD=Generic,DEV=0
HD-Audio Generic, ALC662 rev3 Analog
Direct hardware device without any conversions
hw:CARD=Generic,DEV=2
HD-Audio Generic, ALC662 rev3 Alt Analog
Direct hardware device without any conversions
plughw:CARD=Generic,DEV=0
HD-Audio Generic, ALC662 rev3 Analog
Hardware device with all software conversions
plughw:CARD=Generic,DEV=2
HD-Audio Generic, ALC662 rev3 Alt Analog
Hardware device with all software conversions
sysdefault:CARD=Device
USB PnP Audio Device, USB Audio
Default Audio Device
front:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
Front speakers
surround21:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
Direct sample mixing device
dsnoop:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
Direct sample snooping device
hw:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
Direct hardware device without any conversions
plughw:CARD=Device,DEV=0
USB PnP Audio Device, USB Audio
Hardware device with all software conversions
sysdefault:CARD=U0x46d0x825
USB Device 0x46d:0x825, USB Audio
Default Audio Device
front:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
Front speakers
surround21:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
Direct sample mixing device
dsnoop:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
Direct sample snooping device
hw:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
Direct hardware device without any conversions
plughw:CARD=U0x46d0x825,DEV=0
USB Device 0x46d:0x825, USB Audio
Hardware device with all software conversions
-f alsa -i loopout
私も上記のように使ってみました。ここ。まず、次のコマンドを使用してALSAaloop
カーネルモジュールを有効にしましたinsmod /lib/modules/4.9.0-8-amd64/kernel/sound/drivers/snd-aloop.ko
。正しく読み込まれます。
~$ lsmod | grep aloop
snd_aloop 24576 6
snd_pcm 110592 10 snd_hda_intel,snd_hda_codec,snd_usb_audio,snd_hda_core,snd_hda_codec_hdmi,snd_aloop
snd 86016 35 snd_hda_intel,snd_hwdep,snd_hda_codec,snd_usb_audio,snd_timer,snd_rawmidi,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_usbmidi_lib,snd_seq_device,snd_aloop,snd_hda_codec_realtek,snd_pcm
ただし、ffmpeg:で録画しようとするとエラーが発生します
[alsa @ 0x55bd6922ee40] cannot open audio device loopout (No such file or directory) loopout: Input/output error
。
ループアウト(またはループバック?)を使用するのはおそらく理想的でしょう。私の理解は、これがハードウェアデバイスに関係なく、すべてのシステムサウンドをキャプチャすることです。
要約すると、その時点でどのカードやデバイスがデフォルトであるかに関係なく、ALSAを使用してスクリーンキャプチャ中にすべてのシステム出力サウンドをキャプチャできるようにしたいと思います。