Audio encoding


I am trying to record audio using a microphone connected to the audio port. First, I started by testing AAC encoding, using the following pipeline (found in the linux driver package multimedia user guide): gst-launch-0.10 audiotestsrc ! ‘audio/x-raw-int, rate=(int)44100, channels=(int)2’ ! ffenc_aac ! qtmux ! filesink location=test.mp4 -v -e . However, this does not execute as the ffenc_aac is missing. Is there a package that I need to install in order to get that encoder or should I use a different one. The audio will be saved along with mjpeg video. Thanks in advance.

Hi piperak,
You need to install “gstreamer0.10-ffmpeg”.

Also, audiotestsrc will generate noise. To record audio from a headset, you will need to use alsasrc.
Plus you will need to apply following amixer settings:

amixer cset name=“Stereo ADC MIXL ADC2 Switch” 0
amixer cset name=“Stereo ADC MIXR ADC2 Switch” 0
amixer cset name=“Int Mic Switch” 0
amixer cset name=“ADC Capture Switch” 1
amixer cset name=“RECMIXL BST1 Switch” 0
amixer cset name=“RECMIXR BST1 Switch” 0
amixer cset name=“RECMIXL BST2 Switch” 1
amixer cset name=“RECMIXR BST2 Switch” 1
amixer cset name=“Stereo ADC L1 Mux” “ADC”
amixer cset name=“Stereo ADC R1 Mux” “ADC”
amixer cset name=“Stereo ADC MIXL ADC1 Switch” 1
amixer cset name=“Stereo ADC MIXR ADC1 Switch” 1
amixer cset name=“Stereo ADC MIXL ADC2 Switch” 0
amixer cset name=“Stereo ADC MIXR ADC2 Switch” 0
amixer cset name=“IN1 Mode Control” “Single ended”
amixer cset name=“IN2 Mode Control” “Single ended”
amixer cset name=“Mic Jack Switch” 1

Let me know if this helps.

I have tried to install gstreamer0.10-ffmpeg but I can’t. The package manager reports that it does not exist. I have enabled both universe and multiverse repositories. Is there another repository that i need to enable? Thanks again.

Looks like the Universe is the right place:

How did you add the Universe? I think the correct way to add Universe or Multiverse is the following:

sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install gstreamer0.10-ffmpeg

The servers are different for ARM and for X86 but with apt-add-repository you don’t need to care.


this is exactly what i did and the result is the following:

Package gstreamer0.10-ffmpeg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘gstreamer0.10-ffmpeg’ has no installation candidate

Is there another way to get gstreamer0.10-ffmpeg?

You can download with e.g. “wget” from the url I mentioned and then install with “sudo dpkg -i file.deb”. but it probably has a bunch of dependencies that you would also need to get manually if the universe and multiverse repositories are not working properly for you.

Is it possible to use the output of a media player (any smartphone) instead of a microphone. Do I need to alter the amixer settings in that case too and if yes are the changes similar to the ones you pointed out earlier in this post? Thanks again.

I assume those amixer settings enable the mic in and you can use the same settings also for recording from a smartphone. You may need to tune the recording volume but I think nothing else.


I tried to use a different encoder and I was able to record sound using the following pipeline:

gst-launch -e alsasrc device=hw:1 ! audioresample ! audioconvert ! lamemp3enc target=1 bitrate=64 cbr=true ! filesink location=/home/ubuntu/audio.mp3

However, I get the following message :

WARNING: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Can’t record audio fast enough
Additional debug info:
gstbaseaudiosrc.c(840): gst_base_audio_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0:
Dropped 8192 samples. This is most likely because downstream can’t keep up and is consuming samples too slowly.

I checked cpu utilization using top and the pipeline is reported to utilize around 10-20% of the cpu. Is this due to an alsa bug? Is there a way to resolve this. Thanks again

Hi piperak,

I encountered the same error, apparently it’s an issue with alsasrc. The work around is to use pulsesrc instead of alsasrc. The setup is a little different, I used “$ pact list | grep alsa_input” to get the appropriate device identifier.

I think for the built in sound card it’s:


but you should check that on your machine.

Some of the documentation that I’ve read on the Jetson states that the mic input is mono, but I think it’s really stereo.

Hope this helps

Hi Kangalow,

thanks for the tip.

Initially, I started with pulsesrc but sometimes I was not even able to record at all. This is the pipeline I used:
gst-launch -e pulsesrc device=“alsa_input.platform-tegra-snd-rt5639.0.analog-stereo” ! audioconvert ! lamemp3enc target=1 bitrate=64 cbr=true ! filesink location=/home/ubuntu/audio2.mp3

The device I got it by executing:
pactl list | grep -A2 ‘Source #’ | grep 'Name: ’ | cut -d" " -f2

It works most of the times. Sometimes when I use ctrl-c to break out, it refuses to stop the pipeline and the output file is 0kb. But overall it works. This is why I tried to use alsa as a more stable alternative but I guess I have to stick with pulsesrc. Thanks for the help.

Hi piperak,

You welcome, it sounds like you already were down the path. As far as I can figure, programming by guessing and StackOverflow is the way that most people use Gstreamer. On the Jetson there seems to be a straddle between 0.10 and 1.0, which compounds the confusion. I’ve found it very frustrating.