Skip to content

Instantly share code, notes, and snippets.

@tabvn
Last active December 9, 2017 15:13
Show Gist options
  • Save tabvn/a5c27f3fffdeca0a2d9c60476b89b3d6 to your computer and use it in GitHub Desktop.
Save tabvn/a5c27f3fffdeca0a2d9c60476b89b3d6 to your computer and use it in GitHub Desktop.
const { exec } = require('child_process');
const youtube_stream_key = '';
const frame_rate = 30;
const streamCommand = `/usr/local/bin/ffmpeg -f avfoundation -i "0:0" -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset medium -r 30 -g 60 -b:v 2500k -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/${youtube_stream_key}`
const ls = exec(streamCommand);
ls.stderr.on('data', (data) => {
console.log(`Streaming data: ${data}`);
});
ls.on('close', (code) => {
console.log(`Streaming exist with code: ${code}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment