32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
|
const child_process = require('child_process');
|
||
|
|
||
|
// Requirements:
|
||
|
// gstreamer: gst-launch-1.0
|
||
|
// ffmpeg: ffmpeg
|
||
|
|
||
|
// gstreamer = audio recording
|
||
|
// see `pacmd list` for audio sources
|
||
|
// -v for verbose output
|
||
|
// $ gst-launch-1.0 -v pulsesrc device = "alsa_output.pci-0000_00_1f.3.analog-stereo.monitor" ! wavenc ! filesink location="output.wav"
|
||
|
function start_recording() {
|
||
|
let device = 'alsa_output.pci-0000_00_1f.3.analog-stereo.monitor';
|
||
|
let output = 'output.wav';
|
||
|
let recording_process = child_process.spawn(
|
||
|
'gst-launch-1.0', [ '-v', 'pulsesrc', 'device', '=', device, '!', 'wavenc', '!', 'filesink', 'location', '=', output ]
|
||
|
);
|
||
|
return recording_process;
|
||
|
}
|
||
|
|
||
|
async function stop_recording() {
|
||
|
|
||
|
}
|
||
|
|
||
|
// ffmpeg = file conversion (wav -> mp3)
|
||
|
// $ ffmpeg -i output.wav -b:a 192k output.mp3
|
||
|
// metadata can be added as follows
|
||
|
// $ ffmpeg -i output.wav \
|
||
|
// -metadata title="Song Name" \
|
||
|
// -metadata author="Song Artist" \
|
||
|
// -metadata album="Song Album" \
|
||
|
// -b:a 192k output.mp3
|