我创建了对象直播视频作为Facebook的文档。
"stream_url": "rtmp://rtmp-api.facebook.com:80/rtmp/641310872699778?ds=1&a=AaYx3JYoFLTXAvBK
“
我使用https://github.com/fluent-ffmpeg/node-fluent-ffmpeg作为流但我失败了。
有没有人有解决方案将视频文件(例如:mp4)流式传输到对象视频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
答案 0 :(得分:1)
当我尝试将mp4发送到rtmp服务器时,我也遇到了此错误。首先将文件转换为flv,因为这是rtmp服务器读取和解码的文件类型。
ffmpeg(infs).videoCodec('libx264').audioCodec('aac').toFormat('flv').save(publish)
答案 1 :(得分:-1)
您是否尝试过传入引用的输入?像这样:
publish = "\"rtmp://... live=1 app=...\"";