gstreamer-recorder
GStreamer wrapper for recording desktop.
Requires GStreamer-1.0 with gst-launch-1.0
binary and following GStreamer1 plugins: base, good, bad, ugly.
Used by GNOME Shell Extension Cast to TV and gst-rec terminal app.
Examples
Record desktop directly to file:
var gstRecorder = require('gstreamer-recorder');
var recorder = new gstRecorder({
output: 'file',
format: 'mp4',
file: {
dir: '/tmp',
name: 'My Recording'
}
});
var duration = 10000;
recorder.start();
setTimeout(() => recorder.stop(), duration);
console.log(`Recording ${duration/1000} sec video to ${recorder.opts.file.dir}`);
Pipe output:
var fs = require('fs');
var gstRecorder = require('gstreamer-recorder');
var recorder = new gstRecorder({ output: 'stdout', format: 'matroska' });
var destFile = '/tmp/recording.mkv';
var writableStream = fs.createWriteStream(destFile);
var duration = 10000;
recorder.start().pipe(writableStream);
setTimeout(() => recorder.stop(), duration);
console.log(`Piping output to ${destFile} for ${duration/1000} seconds`);
Create tcp server:
var gstRecorder = require('gstreamer-recorder');
var recorder = new gstRecorder({ output: 'server', server: { port: 8080 }});
recorder.start();
process.on('SIGINT', () => recorder.stop());
process.on('SIGTERM', () => recorder.stop());
console.log(`Started tcp media server on port ${recorder.opts.server.port}`);
Donation
If you like my work please support it by buying me a cup of coffee :grin: