Ricky
Ricky

Reputation: 777

ffmpeg fluent live streaming to youtube not working

I am learning how to using ffmpeg fluent and I am having trouble getting it to stream live to Youtube

here is the command I have tried:

let streamYT = (YTrtmpKey) => {
  var proc3 = new ffmpeg({ source: inputURL, timeout: 0 })
    .addOption('-vcodec', 'libx264')
    .addOption('-acodec', 'aac')
    .addOption('-crf', 26)
    .addOption('-aspect', '640:360')
    .withSize('640x360')
    .on('start', function(commandLine) {
    console.log('Query : ' + commandLine);
    })
    .on('error', function(err) {
    console.log('Error: ' + err.message);
    })
    .output('rtmp://a.rtmp.youtube.com/live2/' + YTrtmpKey, function(stdout, stderr) {
    console.log('Convert complete' +stdout);
  });
  }

this doesn't throw any errors but also doesn't do anything

Upvotes: 0

Views: 979

Answers (2)

RAKESH KANANI
RAKESH KANANI

Reputation: 11

Add the inputOption('-r'). It gives realtime experience to all the viewers.

Upvotes: 0

Ricky
Ricky

Reputation: 777

This is how you do it, I was missing the "-f" and the "flv" and also the run command

let streamYT = (YTrtmp) => {
  console.log("streaming to youtube")
  var proc3 = new ffmpeg({ source: inputURL, timeout: 0 })
    .addOption('-vcodec', 'libx264')
    .addOption('-acodec', 'aac')
    .addOption('-crf', 26)
    .addOption('-aspect', '640:360')
    .addOption('-f', 'flv')
    .withSize('640x360')
    .on('start', function(commandLine) {
    console.log('Query : ' + commandLine);
    })
    .on('error', function(err) {
    console.log('Error: ' + err.message);
    })
    .output('rtmp://a.rtmp.youtube.com/live2/' + YTrtmp, function(stdout, stderr) {
      console.log('Convert complete' +stdout)
    })
    .run()
  }

Upvotes: 1

Related Questions