Changes between Version 1 and Version 2 of Capture/ALSA
- Timestamp:
- Jul 5, 2012, 4:57:04 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Capture/ALSA
v1 v2 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). 39 40 If you need a specific device from the specified card, then you can use '''hw:<X>,<Y>''' notation, 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 '''hw:<X>,<Y>''', where <X>=card, <Y>=device. For example, to select "MIC2 ADC" from Intel card, we would use: 41 39 {{{ 42 40 ffmpeg -f alsa -i hw:0,2 -t 30 out.wav 43 41 }}} 42 The best way is to select your default device with "alsamixer" tool, because some audio cards have complicated way of selecting the default input through the FFmpeg's command line. 43 44 == Surviving the reboot == 44 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: … … 110 111 This way, you're always asking for the input from that certain device and will never mix things up. 111 112 112 Also, you might find useful a tool named '''alsamixer'''. 113 == ALSA mixer tool == 113 114 114 [[Image()]] 115 You might find useful a tool named '''alsamixer'''. 116 117 [[Image(alsamixer.png)]] 115 118 116 119 It will let you visually select, for each specified card (intel or usb), which recording device do you want to use (if the specified card has got multiple inputs, like Line-In, CD-In, Mic, ...), so you can just run "alsamixer", press F6 to choose the card and then use TAB key to switch to recording devices (pressing it multiple times just switches between playback/recording/all devices), after that just use arrow keys to highlight desired device and just hit the SPACEBAR key to select it (and up/down, page up/dn keys to change the input volume). 117 120 118 119 121 = Input options = 120 122 121 . 123 The only useful [http://ffmpeg.org/ffmpeg.html#Audio-Options audio input options] for ALSA input are "-ar" (audio sample rate) and "-ac" (audio channels). 124 125 Specifying audio sampling rate/frequency will force the audio card to record the audio at that specified rate. Usually the default value is "44100" (Hz). 126 Specifying audio channels will force the audio card to record the audio as mono, stereo or even 2.1/5.1 (if supported by your audio card). Usually the default value is "1" (mono) for Mic input and "2" (stereo) for Line-In input. 127 128 = Examples = 129 130 == Grab an audio from your microphone == 131 132 When doing screencast recordings, you usually want to record your voice too, so you would probably want to do something like this: 133 {{{ 134 ffmpeg -f alsa -ac 1 -ar 44100 -i hw:0 -t 30 out.wav 135 }}} 136 Looking at our example device listing, this would be the same as this: 137 {{{ 138 ffmpeg -f alsa -ac 1 -ar 44100 -i default:CARD=ICH5 -t 30 out.wav 139 }}}
