Super User Asked on November 7, 2021
I want to record the output of audio to an mp3 file. What tools and commands can I use in linux ubutu Terminal?
Kudos to @Ahmad. This worked for me:
sox -e signed-integer -L -b16 -c2 -r44100 -t raw "|parec -d alsa_output.pci-0000_0c_00.4.iec958-stereo.monitor" -t mp3 -c2 -C 320.01 stream.mp3 silence 1 0.1 3% 1 3.0 3%
where input stream parameters can be seen with pacmd list-sinks
:
name: <alsa_output.pci-0000_0c_00.4.iec958-stereo>
sample spec: s16le 2ch 44100Hz
properties:
alsa.resolution_bits = "16"
Answered by Michael Kwardakov on November 7, 2021
First you need to extract the name of output device:
To do this, you can install the following modules:
sudo apt-get install pulseaudio-utils lame mpg123
And run:
pacmd list-sinks | grep -e 'name:' -e 'index' -e 'Speakers'
The output could be like this:
index: 1
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
index: 23
name: <alsa_output.pci-0000_00_03.0.hdmi-surround71>
After you found the name, you can run the following command to record the output to an mp3 file:
parec -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | lame -r -V0 - out.mp3
Or using sox
you can do the following, however I found the first solution more robust:
sox -t pulseaudio alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -t mp3 test.mp3
However, if you want to automatically start and stop recording you can run:
parec -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | sox -t raw -b 16 -e signed -c 2 -r 44100 - test.ogg silence 1 0.1 3% 1 3.0 3%
It begins recording when a sounds sent to the speaker and stops if nothing is received after 3 seconds. for more information about sox refer to sox man page in linux
Answered by Ahmad on November 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP