码迷,mamicode.com
首页 > 系统相关 > 详细

Record system output sound in Linux with pacat (Pulseaudio)

时间:2016-06-14 01:10:07      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:

Record system output sound in Linux with pacat (Pulseaudio)

When pulseaudio is used as the sound server of the system, there is a simple way to record the output sound to file on the command line using the pacat-command. This short article describes how to do it.


 
 In order to find the correct device you should run this command:

pacmd list | grep ".monitor"

When you see something like:

    alsa_output.pci-0000_06_05.0.analog-stereo.monitor/#1: Monitor of CA0106 Soundblaster Analog Stereo

and the soundcard corresponds to the one you want to monitor, you know which device name to use. Here it is: alsa_output.pci-0000_06_05.0.analog-stereo.monitor

Afterwards pacat is used to read the signal and sox is used to change the output format. See the man page of sox for parameters to choose for correct output format. The default output from pacat is raw audio, rate 44100, signed-integer, little-endian, 16-bit and stereo. The sox reads from standard input by specifying "-" as filename. The format of the output file is therefore specified after the "-" in the examples under.

Here is an example of how to write to a float formatted raw audio file with mono sound at a rate of 40000sps:

pacat --record -d alsa_output.pci-0000_06_05.0.analog-stereo.monitor | sox -t raw -r 44100 -s -L -b 16 -c 2 - -t raw -r 40000 -f -b 32 -c 1 output.raw

This one is nice if you will record sounds for using in gnuradio. To record to a wav-file with a rate of 44100sps, simply do like this:

pacat --record -d alsa_output.pci-0000_06_05.0.analog-stereo.monitor | sox -t raw -r 44100 -s -L -b 16 -c 2 - "output.wav"

 

Record system output sound in Linux with pacat (Pulseaudio)

标签:

原文地址:http://www.cnblogs.com/aoo0/p/5582547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!