Changes between Version 1 and Version 2 of Capture/ALSA


Ignore:
Timestamp:
Jul 5, 2012, 7:57:04 PM (7 years ago)
Author:
burek
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Capture/ALSA

    v1 v2  
    3636ffmpeg -f alsa -i hw:1 -t 30 out.wav
    3737}}}
    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:
     38That 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:
    4139{{{
    4240ffmpeg -f alsa -i hw:0,2 -t 30 out.wav
    4341}}}
     42The 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 ==
    4445
    4546But, '''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:
     
    110111This way, you're always asking for the input from that certain device and will never mix things up.
    111112
    112 Also, you might find useful a tool named '''alsamixer'''.
     113== ALSA mixer tool ==
    113114
    114 [[Image()]]
     115You might find useful a tool named '''alsamixer'''.
     116
     117[[Image(alsamixer.png)]]
    115118
    116119It 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).
    117120
    118 
    119121= Input options =
    120122
    121 .
     123The 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
     125Specifying audio sampling rate/frequency will force the audio card to record the audio at that specified rate. Usually the default value is "44100" (Hz).
     126Specifying 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
     132When doing screencast recordings, you usually want to record your voice too, so you would probably want to do something like this:
     133{{{
     134ffmpeg -f alsa -ac 1 -ar 44100 -i hw:0 -t 30 out.wav
     135}}}
     136Looking at our example device listing, this would be the same as this:
     137{{{
     138ffmpeg -f alsa -ac 1 -ar 44100 -i default:CARD=ICH5 -t 30 out.wav
     139}}}