实时视频Facebook API与FFMPEG nodejs



我已经创建了Object Live Video作为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

当我试图将mp4发送到rtmp服务器时,我也得到了这个错误。首先将文件转换为flv,因为这是rtmp服务器读取和解码的文件类型。

ffmpeg(infs).videoCodec('libx264').audioCodec('aac').toFormat('flv').save(publish)

您是否尝试过传递引号输入?像这样:

publish = ""rtmp://... live=1 app=..."";

相关内容

  • 没有找到相关文章

最新更新