저는 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
나는 또한 위에서 언급 한 것처럼 사용해 보았습니다.여기. 먼저 다음 명령을 사용하여 ALSA aloop
커널 모듈을 활성화했습니다 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를 사용하여 화면 캡처 중에 모든 시스템 출력 사운드를 캡처할 수 있기를 원합니다.