I don't know about image. But if you have a video then you can stream it to youtube with ffmpeg.
Method: 1
Without nodejs it can be done with the cli like this. Open the cli where your video file is stored. And run the follwing command:
ffmpeg -re -i vieo_you_wanna_stream.mp4 -c copy -f flv rtmp://a.rtmp.youtube.com/live2/SECRET_STREAM_KEY
Method: 2
If you really need to stream from nodejs server then you can do the following:
Create a file called runCommand.js with these lines of code:
var spawn = require('child_process').spawn;
module.exports = (cmd, args, onData, onFinish) => {
var proc = spawn(cmd, args.split(' '));
proc.stdout.on('data', onData);
proc.stderr.setEncoding("utf8")
proc.stderr.on('data', err => console.log(err) );
proc.on('close', onFinish);
}
Now in your app.js file put these lines of codes:
const runCommand = require('./runCommand')
runCommand(
'ffmpeg',
'-re -i vieo_you_wanna_stream.mp4 -c copy -f flv rtmp://a.rtmp.youtube.com/live2/SECRET_STREAM_KEY',
(data) => console.log(data),
() => console.log('finished')
)
Now from cli run
node app.js
If your video path, ffmpeg and your youtube rtmp link is corrent the it will immediately start the stream.
Note:
If you really want to stream only image to youtube with this method, then you can convert your image to a video with any kind of converter. And use this method to stream the video to youtube.