web-dev-qa-db-fra.com

Enregistrement audio sur le bureau et le microphone avec Avconv

J'utilise Avconv sur Ubuntu 13.10 avec Gnome 3.1 pour enregistrer screencasts Minecraft. Cependant, je ne peux obtenir le son que de mon microphone et non du haut-parleur de l'ordinateur portable. Comment pourrais-je enregistrer à la fois un ordinateur portable et un microphone? J'utilise un casque USB avec un microphone.

Informations demandées par @Sneetsher:

La commande réelle:

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 

Infos 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

enter image description here

Captures d'écran mises à jour:

enter image description hereenter image description here

$ 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
6
Melvin Sowah
  • Installer le contrôle audio par impulsion

    Sudo apt-get install pavucontrol
    
  • Seulement l'enregistrement de lecture (pas de microphone)

    Ouvrez-le → Périphériques d'entrée → Afficher: Tous les périphériques d'entrée → Utilisez le bouton vert à droite pour sélectionner "Moniteur: Analog Audio".

    Il existe différents noms de chaînes, mais vous pouvez lancer un lecteur et voir celui qui a le signal.

    Lorsque Gnome Volume Control est ouvert, il est redéfini sur Microphone. J'ai remarqué cela dans les versions tardives 13.04, 13.10, 14.04. Il ne peut pas être rétabli avec Gnome Volume Control. (Évitez de l'utiliser pour l'enregistrement)

Pulse Audio Control : Input Devices

  • Le microphone et la lecture sont combinés : pactl CLI peut être utilisé. Exemple:

    1. Vérifier le nom de l'évier

      $ 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. Source de microphone en boucle vers récepteur analogique

      $ pactl load-module module-loopback latency_msec=1 sink=alsa_output.pci-0000_00_1b.0.analog-stereo
      30
      
    3. Utilisez la même étape ci-dessus pour sélectionner le bon périphérique d’entrée.

    Pour la fermer:

    $ pactl unload-module 30
    

    ou en utilisant le nom:

    $ pactl unload-module module-loopback
    

    Pour vérifier l'id du module:

    $ pactl list short modules
    
  • Dans le cas où impossible de trouver un moniteur analogique de lecture dans les périphériques d'entrée

    1. Vérifiez l'onglet Configuration, il devrait s'agir Full Duplex (entrée/sortie)

    2. Sinon, il est possible de créer un périphérique de sortie virtuel, puis de le reboucler.

      pactl load-module module-null-sink sink_name=Virtual1
      pactl load-module module-loopback latency_msec=1 sink=Virtual1
      
    3. Utilisez ensuite Pulse Audio Control, Même étape ci-dessus pour sélectionner le bon périphérique d’entrée Virtual1 .

    4. Pour le périphérique de sortie:

      • Utilisez l'onglet Périphériques de sortie si toutes les sorties système mixtes sont nécessaires.

      • Ou utilisez l'onglet Playback si seule une sortie de l'application est nécessaire (par exemple: lecture uniquement de musique VLC ...). Dans ce cas, vous pouvez enregistrer quelque chose et écouter autre chose.

    Comme référence, voir Comment utiliser les flux audio virtuels PulseAudio pour lire de la musique sur Skype?

  • si cela n'a pas fonctionné (votre cas à titre d'exemple)

    1. Vérifiez le nom exact de l'évier "Analog Stereo Output"

      pactl list sinks
      
    2. Microphone en boucle vers "Sortie stéréo analogique"

      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. Vérifiez le nom exact de la source "Analog Stereo Output Monitor"

      pactl list sources
      
    4. Puis enregistrez directement en spécifiant le nom de périphérique "Moniteur de sortie stéréo analogique", Exemple dans votre cas:

      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
      
7
user.dz

- i: 0. "volera" le microphone de Pulse et vous ne pourrez pas utiliser le mirophone pendant l'enregistrement (comme lors d'une conversation sur Skype).

Une interface looback introduira un certain délai entre le son joué et celui enregistré.

Cela a fonctionné pour moi:

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

& 1 sont les sources audio Pulse listées avec

pactl list sinks
2
xvan