Grave áudio do desktop e do microfone com o Avconv

6

Estou usando o Avconv no Ubuntu 13.10 com o Gnome 3.10 para gravar screencasts do Minecraft . No entanto, só consigo obter o som do meu microfone e não do alto-falante do laptop. Como eu iria gravar tanto o laptop quanto o microfone? Estou usando um fone de ouvido USB com microfone.

Informação solicitada por @Sneetsher:

O comando atual:

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 

Informações do 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

Imagens atualizadas:

$ 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
    
por Melvin Sowah 25.01.2014 / 22:46

2 respostas

7
  • Instalar o controle de áudio por pulso

    sudo apt-get install pavucontrol
    
  • Somente registro de reprodução (sem microfone)

    Abra → Dispositivos de Entrada → Mostrar: Todos os dispositivos de entrada → Use o Botão Verde para a direita para selecionar "Monitor: Áudio Analógico"

    Existem nomes de canais diferentes, mas você pode executar algum player e ver qual deles tem sinal.

    Quando o Controle de Volume do Gnome é aberto, ele o substitui novamente pelo Microfone. Tenho notado que nas últimas versões 13.04, 13.10, 14.04. Não pode ser alterado novamente usando o Gnome Volume Control. (Evite usá-lo na gravação)

  • O microfone e a reprodução misturados : pactl CLI podem ser usados. Exemplo:

    1. Verifique o nome do coletor

      $ 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
      
    2. Fonte de microfone de loopback para o coletor analógico

      $ pactl load-module module-loopback latency_msec=1 sink=alsa_output.pci-0000_00_1b.0.analog-stereo
      30
      
    3. Use o mesmo passo acima para selecionar o dispositivo de entrada correto.

    Para fechá-lo:

    $ pactl unload-module 30
    

    ou usando o nome:

    $ pactl unload-module module-loopback
    

    Para verificar o ID do módulo:

    $ pactl list short modules
    
  • No caso, não é possível encontrar um monitor analógico de reprodução nos dispositivos de entrada

    1. Verifique a guia Configuração, deve ser Full Duplex (entrada / saída)

    2. Caso contrário, é possível criar um dispositivo de saída virtual e, em seguida, fazer o loopback.

      pactl load-module module-null-sink sink_name=Virtual1
      pactl load-module module-loopback latency_msec=1 sink=Virtual1
      
    3. Em seguida, use o Pulse Audio Control, o mesmo passo acima para selecionar o dispositivo de entrada correto Virtual1 .

    4. Para o dispositivo de saída:

      • Use a guia Dispositivos de saída se todas as saídas mistas do sistema forem necessárias.

      • Ou use a guia Reprodução se apenas alguma saída de aplicativo for necessária (como: apenas reprodução de música VLC ...). Nesse caso, você pode gravar algumas coisas e ouvir outras coisas.

    Como referência veja, Como posso usar os streams de áudio virtual PulseAudio para reproduzir música pelo Skype?

  • se não funcionou (seu caso como exemplo)

    1. Verifique o nome exato do coletor "Saída analógica estéreo"

      pactl list sinks
      
    2. Faça o retorno do microfone para "Saída analógica estéreo"

      pactl load-module module-loopback latency_msec=1 sink=alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00-Device.ana‌​log-stereo
      
    3. Verifique o nome exato da fonte "Analog Stereo Output Monitor"

      pactl list sources
      
    4. Em seguida, grave diretamente, especificando o nome do dispositivo "Analog Stereo Output Monitor", Exemplo no seu caso:

      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
      
por user.dz 26.01.2014 / 00:36
2

-i: 0.0 "roubará" o microfone do pulso e você não poderá usar o mirophone enquanto grava (como em uma conversa no skype).

Uma interface de looback introduzirá algum atraso entre o som reproduzido e o gravado.

Isso funcionou para mim:

ffmpeg -f pulse -i 0 -f pulse -i 1  -filter_complex amerge  out.wav

0 & amp; 1 são fontes de áudio de pulso listadas com

pactl list sinks
    
por xvan 21.11.2014 / 21:29