I have created Object Live Video as Facebook's document.
"stream_url": "rtmp://rtmp-api.facebook.com:80/rtmp/641310872699778?ds=1&a=AaYx3JYoFLTXAvBK
"
I using https://github.com/fluent-ffmpeg/node-fluent-ffmpeg for stream but I failed.
Does anyone have solutions to stream video file (eg: mp4) to Object Video Facebook API?
var ffmpeg = require('fluent-ffmpeg'),
fs = require('fs');
// open input stream
var infs = fs.createReadStream(__dirname + '/2.mp4');
infs.on('error', function(err) {
console.log(err);
});
var publish = "rtmp://rtmp-api.facebook.com:80/rtmp/641310872699778?ds=1&a=AaYx3JYoFLTXAvBK";
// make sure you set the correct path to your video file
var proc = ffmpeg(infs)
.format('mp4')
.size('320x?')
.videoBitrate('512k')
.videoCodec('libx264')
.fps(24)
.audioBitrate('96k')
.audioCodec('aac')
.audioFrequency(22050)
.audioChannels(2)
// setup event handlers
.on('end', function() {
console.log('file has been converted succesfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
// save to stream
.save(publish); //end = true, close output stream after writing
an error happened: ffmpeg exited with code 1: rtmp://rtmp-api.facebook.com:80/rtmp/641310872699778?ds=1&a=AaYx3JYoFLTXAvBK: Operation not permitted
I got this error too when I tried to send an mp4 to a rtmp server. Convert the file to flv first because that is the file type that rtmp servers read and decode.
ffmpeg(infs).videoCodec('libx264').audioCodec('aac').toFormat('flv').save(publish)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With