我在用着AVCONV在 Ubuntu 13.10 上Gnome 3.10记录Minecraft 截屏视频。但是,我只能从麦克风获取声音,而不能从笔记本电脑扬声器获取声音。我该如何同时录制笔记本电脑和麦克风的声音?我使用的是带麦克风的 USB 耳机。
@Sneetsher 请求的信息:
实际命令:
avconv -f pulse -i default -b 64k -f x11grab -r 25 -s 1280x800 -i :0.0 -vcodec libx264 -preset ultrafast -threads 4 -y myscreencast2.mp4
PulseAudio 信息:
$ pactl list short
0 module-device-restore
1 module-stream-restore
2 module-card-restore
3 module-augment-properties
4 module-switch-on-port-available
5 module-alsa-card device_id="0" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1"
6 module-alsa-card device_id="1" name="usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device" card_name="alsa_card.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1"
7 module-udev-detect
8 module-bluetooth-policy
9 module-bluetooth-discover
10 module-native-protocol-unix
11 module-default-device-restore
12 module-rescue-streams
13 module-always-sink
14 module-intended-roles
15 module-suspend-on-idle
16 module-systemd-login
17 module-position-event-sounds
18 module-filter-heuristics
19 module-filter-apply
20 module-x11-publish display=:0
21 module-x11-bell display=:0 sample=bell.ogg
22 module-x11-cork-request display=:0
23 module-x11-xsmp display=:0 session_manager=local/MELVIN-124833:@/tmp/.ICE-unix/2013,unix/MELVIN-124833:/tmp/.ICE-unix/2013
0 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz IDLE
1 alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.iec958-stereo module-alsa-card.c s16le 2ch 44100Hz IDLE
0 alsa_output.pci-0000_00_1b.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz RUNNING
1 alsa_input.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
2 alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.iec958-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz RUNNING
3 alsa_input.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.analog-mono module-alsa-card.c s16le 1ch 44100Hz RUNNING
15 0 28 protocol-native.c float32le 1ch 25Hz
16 1 28 protocol-native.c float32le 1ch 25Hz
17 2 28 protocol-native.c float32le 1ch 25Hz
18 3 28 protocol-native.c float32le 1ch 25Hz
0 module-systemd-login.c (null)
5 module-x11-xsmp.c (null)
6 protocol-native.c gnome-settings-daemon
7 protocol-native.c gnome-shell
8 protocol-native.c gnome-shell
9 protocol-native.c chrome
28 protocol-native.c pavucontrol
36 protocol-native.c pactl
0 screen-capture s16le 2ch 96000Hz 0.872
1 bell-window-system s16le 2ch 44100Hz 0.749
0 alsa_card.pci-0000_00_1b.0 module-alsa-card.c
1 alsa_card.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device module-alsa-card.c
$ pactl stats
Currently in use: 12 blocks containing 548.2 KiB bytes total.
Allocated during whole lifetime: 7254422 blocks containing 2.9 GiB bytes total.
Sample cache size: 456.2 KiB
Server String: unix:/run/user/1000/pulse/native
Library Protocol Version: 28
Server Protocol Version: 28
Is Local: yes
Client Index: 37
Tile Size: 65496
User Name: guilmon
Host Name: MELVIN-124833
Server Name: pulseaudio
Server Version: 4.0
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.iec958-stereo
Default Source: alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.iec958-stereo.monitor
Cookie: 3f2a:1764
更新截图:
$ pactl list sources
Source #0
State: SUSPENDED
Name: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
Description: Monitor of Built-in Audio Analogue Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 5
Mute: no
Volume: 0: 20% 1: 20%
0: -42.50 dB 1: -42.50 dB
balance 0.00
Base Volume: 100%
0.00 dB
Monitor of Sink: alsa_output.pci-0000_00_1b.0.analog-stereo
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY
Properties:
device.description = "Monitor of Built-in Audio Analogue Stereo"
device.class = "monitor"
alsa.card = "0"
alsa.card_name = "HDA Intel"
alsa.long_card_name = "HDA Intel at 0xe4644000 irq 48"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:1b.0"
sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "284b"
device.product.name = "82801H (ICH8 Family) HD Audio Controller"
device.form_factor = "internal"
device.string = "0"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
Formats:
pcm
Source #1
State: SUSPENDED
Name: alsa_input.pci-0000_00_1b.0.analog-stereo
Description: Built-in Audio Analogue Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 5
Mute: no
Volume: 0: 84% 1: 84%
0: -4.50 dB 1: -4.50 dB
balance 0.00
Base Volume: 13%
-52.50 dB
Monitor of Sink: n/a
Latency: 0 usec, configured 0 usec
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "AD198x Analog"
alsa.id = "AD198x Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "HDA Intel"
alsa.long_card_name = "HDA Intel at 0xe4644000 irq 48"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:1b.0"
sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "284b"
device.product.name = "82801H (ICH8 Family) HD Audio Controller"
device.form_factor = "internal"
device.string = "front:0"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analogue Stereo"
device.description = "Built-in Audio Analogue Stereo"
alsa.mixer_name = "Analog Devices AD1981"
alsa.components = "HDA:11d41981,103c30be,00100200 HDA:14f12c06,103c1379,00100000"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
Ports:
analog-input-microphone-internal: Internal Microphone (priority: 8900)
analog-input-microphone-dock: Dock Microphone (priority: 7800)
analog-input-microphone: Microphone (priority: 8700)
Active Port: analog-input-microphone
Formats:
pcm
Source #5
State: SUSPENDED
Name: alsa_input.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.analog-mono
Description: USB PnP Sound Device Analogue Mono
Driver: module-alsa-card.c
Sample Specification: s16le 1ch 48000Hz
Channel Map: mono
Owner Module: 26
Mute: no
Volume: 0: 85%
0: -4.10 dB
balance 0.00
Base Volume: 40%
-23.81 dB
Monitor of Sink: n/a
Latency: 0 usec, configured 0 usec
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
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 = "1"
alsa.card_name = "USB PnP Sound Device"
alsa.long_card_name = "C-Media Electronics Inc. USB PnP Sound Device at usb-0000:00:1d.2-2, full speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:1d.2-usb-0:2:1.0"
sysfs.path = "/devices/pci0000:00/0000:00:1d.2/usb7/7-2/7-2:1.0/sound/card1"
udev.id = "usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device"
device.bus = "usb"
device.vendor.id = "0d8c"
device.vendor.name = "C-Media Electronics, Inc."
device.product.id = "0139"
device.product.name = "USB PnP Sound Device"
device.serial = "C-Media_Electronics_Inc._USB_PnP_Sound_Device"
device.string = "hw:1"
device.buffering.buffer_size = "176400"
device.buffering.fragment_size = "88200"
device.access_mode = "mmap+timer"
device.profile.name = "analog-mono"
device.profile.description = "Analogue Mono"
device.description = "USB PnP Sound Device Analogue Mono"
alsa.mixer_name = "USB Mixer"
alsa.components = "USB0d8c:0139"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-usb"
Ports:
analog-input-microphone: Microphone (priority: 8700)
Active Port: analog-input-microphone
Formats:
pcm
Source #8
State: SUSPENDED
Name: alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.analog-stereo.monitor
Description: Monitor of USB PnP Sound Device Analogue Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 26
Mute: no
Volume: 0: 100% 1: 100%
0: 0.00 dB 1: 0.00 dB
balance 0.00
Base Volume: 100%
0.00 dB
Monitor of Sink: alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.analog-stereo
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY
Properties:
device.description = "Monitor of USB PnP Sound Device Analogue Stereo"
device.class = "monitor"
alsa.card = "1"
alsa.card_name = "USB PnP Sound Device"
alsa.long_card_name = "C-Media Electronics Inc. USB PnP Sound Device at usb-0000:00:1d.2-2, full speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:1d.2-usb-0:2:1.0"
sysfs.path = "/devices/pci0000:00/0000:00:1d.2/usb7/7-2/7-2:1.0/sound/card1"
udev.id = "usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device"
device.bus = "usb"
device.vendor.id = "0d8c"
device.vendor.name = "C-Media Electronics, Inc."
device.product.id = "0139"
device.product.name = "USB PnP Sound Device"
device.serial = "C-Media_Electronics_Inc._USB_PnP_Sound_Device"
device.string = "1"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-usb"
Formats:
pcm
答案1
安装脉冲音频控制
sudo apt-get install pavucontrol
仅播放记录(无麦克风)
打开它 → 输入设备 → 显示:所有输入设备 → 使用右侧的绿色按钮选择“监视器:模拟音频”
有不同的频道名称,但您可以运行一些播放器并查看哪个有信号。
当 Gnome 音量控制打开时,它会将其覆盖回麦克风。我注意到在后期版本 13.04、13.10、14.04 中。无法使用 Gnome 音量控制将其改回。(避免在录音时使用它)
麦克风和播放混合:
pactl
可以使用 CLI。例如:检查水槽名称
$ pactl list short sinks 0 alsa_output.pci-0000_01_00.1.hdmi-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 1 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
环回麦克风源至模拟接收器
$ pactl load-module module-loopback latency_msec=1 sink=alsa_output.pci-0000_00_1b.0.analog-stereo 30
使用上述相同的步骤选择正确的输入设备。
要关闭它:
$ pactl unload-module 30
或使用名称:
$ pactl unload-module module-loopback
检查模块 ID:
$ pactl list short modules
以防万一,无法在输入设备中找到播放模拟监视器
检查配置选项卡,它应该是全双工(输入输出)
否则,可以创建一个虚拟输出设备然后将其循环回来。
pactl load-module module-null-sink sink_name=Virtual1 pactl load-module module-loopback latency_msec=1 sink=Virtual1
然后使用脉冲音频控制,与上述步骤相同,选择正确的输入设备虚拟1。
对于输出设备:
使用输出设备如果需要所有混合系统输出,请按选项卡。
或者使用回放如果只需要某些应用程序输出(例如:仅播放 VLC 音乐...),则单击选项卡。在这种情况下,您可以录制一些东西,然后收听其他东西。
如果它不起作用(以你的情况为例)
检查“模拟立体声输出”接收器的确切名称
pactl list sinks
将麦克风环回至“模拟立体声输出”
pactl load-module module-loopback latency_msec=1 sink=alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.analog-stereo
检查“模拟立体声输出监视器”源的确切名称
pactl list sources
然后通过指定“模拟立体声输出监视器”的设备名称直接录制,例如:
avconv -f pulse -i "alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.analog-stereo.monitor" -b 64k -f x11grab -r 25 -s 1280x800 -i :0.0 -vcodec libx264 -preset ultrafast -threads 4 -y myscreencast2.mp4
答案2
-i:0.0将从脉冲中“窃取”麦克风,并且您将无法在录音时使用麦克风(例如在 Skype 对话中)。
回放接口将在播放的声音和录制的声音之间引入一些延迟。
这对我有用:
ffmpeg -f pulse -i 0 -f pulse -i 1 -filter_complex amerge out.wav
0 & 1脉冲音频源是否列出
pactl list sinks
答案3
注意:这是一个同时录制桌面音频和麦克风音频的解决方案,与发布的具体问题无关。
不管怎样,我一直在谷歌上苦苦寻找一个不复杂的答案。
安装并使用 Open Broadcaster Software (OBS)。说真的,就是这样。谷歌搜索应该会显示针对您的机器定制的安装说明。
只需使用 OBS 录制,它就会制作一个包含音频的视频。如果您只想录制音频,只需录制而不使用视频源,它就会制作一个包含您录制内容的空白视频。
(请注意,这会为您提供一个视频文件。这并不困扰我,但如果您需要像 mp3 这样的音频文件,您将必须弄清楚如何将您制作的视频文件转换为音频文件(有很多资源可以做到这一点)。)