Record system output sound in Linux with pacat (Pulseaudio)

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"

 

转载于:https://www.cnblogs.com/aoo0/p/5582547.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值