Changes between Version 2 and Version 3 of Capturing audio with FFmpeg and ALSA
- Timestamp:
- 07/05/2012 07:01:14 PM (11 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Capturing audio with FFmpeg and ALSA
v2 v3 8 8 = Selecting the input card = 9 9 10 '''input_device''' tells FFmpeg which audio capturing device`/`card you would like to use. To get a list of all supported devices, you can type '''arecord -l''' (small L) or '''arecord -L''' (longer output).10 '''input_device''' tells FFmpeg which audio capturing card`/`device you would like to use. To get the list of all installed cards on your machine, you can type '''arecord -l''' (small L) or '''arecord -L''' (longer output). 11 11 12 So, first, list your recording devices:12 So, first, list your recording cards/devices: 13 13 {{{ 14 14 # arecord -l … … 32 32 }}} 33 33 34 We can see there are 2 audio cards that provide capturing capabilities, namely "'''card 0'''" (Intel ICH5) and "'''card 1'''" (Microphone on the USB web cam). The easiest thing to do is to reference each of them directly using "'''-f alsa -i hw:0'''" or "'''-f alsa -i hw:1'''":34 We can see there are 2 audio cards installed that provide capturing capabilities, namely "'''card 0'''" (Intel ICH5) and "'''card 1'''" (Microphone on the USB web cam). The easiest thing to do is to reference each of them directly using "'''-f alsa -i hw:0'''" or "'''-f alsa -i hw:1'''": 35 35 {{{ 36 36 ffmpeg -f alsa -i hw:1 -t 30 out.wav 37 37 }}} 38 That will give us a 30 seconds WAV audio output, recorded from our USB camera's default recording device (microphone). The default recording device can be selected using "alsamixer" tool (see below) or specifying the device using an additional parameter '''hw:<X>,<Y>''', where <X>=card, <Y>=device. For example, to select "MIC2 ADC" from Intel card, we would use:38 That will give us a 30 seconds WAV audio output, recorded from our USB camera's '''default recording device''' (microphone). The default recording device can be selected using "alsamixer" tool (see below) or specifying the device using an additional parameter Y in '''hw:<X>,<Y>''', where <X>=card, <Y>=device. For example, to select "MIC2 ADC" from Intel card (look above at the list), we would use: 39 39 {{{ 40 40 ffmpeg -f alsa -i hw:0,2 -t 30 out.wav 41 41 }}} 42 The best way is to select your default device with "alsamixer" tool, because some audio cards havecomplicated way of selecting the default input through the FFmpeg's command line.42 The best way is to select your card and default recording device with "alsamixer" tool, because some audio cards have a complicated way of selecting the default input through the FFmpeg's command line. 43 43 44 44 == Surviving the reboot == 45 45 46 But, '''if you reboot'''your machine, you will notice sometimes your cards get reordered, so "card 0" is listed as USB Audio and "card 1" is listed as Intel audio card. You might want to play with [http://www.reactivated.net/writing_udev_rules.html udev rules], but there is an easier solution for this. Typing '''arecord -L''' will give us a little bit more detailed listing of recording devices:46 If you reboot your machine, you will notice sometimes your cards get reordered, so "card 0" is listed as USB Audio and "card 1" is listed as Intel audio card. You might want to play with [http://www.reactivated.net/writing_udev_rules.html udev rules], but there is an easier solution for this. Typing '''arecord -L''' will give us a little bit more detailed listing of recording devices: 47 47 {{{ 48 48 #!html … … 109 109 </pre> 110 110 }}} 111 This way, you're always asking for the input from that certain device and will never mix things up.111 This way, you're always asking for the input from that certain device (the default recording device from the USB Audio device) and will never mix things up. 112 112 113 113 == ALSA mixer tool ==


