如何在fluent-ffmpeg中使用管道而不是保存方法?

时间:2019-06-27 11:27:42

标签: node.js ffmpeg pipe streaming fluent-ffmpeg

我要用流利的ffmpeg在视频上写点东西 我用这个鳕鱼

var proc = ffmpeg(req.filePath). videoFilters(
  {
    filter: 'drawtext',
    options: {
      text: 'VERY LONG TEXT VERY VERY VERY VERY LOL!!!',
      fontsize: 36,
      fontcolor: 'white',
      x: '(main_w/2-text_w/2)',
      y: '(text_h/2)+15',
      shadowcolor: 'black',
      shadowx: 2,
      shadowy: 2
    }}

)
// use the 'flashvideo' preset (located in /lib/presets/flashvideo.js)
.on('end', function() {
  console.log('file has been converted succesfully');
})
.on('error', function(err) {
  console.log('an error happened: ' + err.message);
}).save('/home/gheidar/Desktop/ffmpeg_test/rt.ts');

一切都正确 但我想将此输出导出到流以响应请求 表示我想使用pipe()而不是save方法

类似这样的东西:

var proc = ffmpeg(req.filePath). videoFilters(
  {
    filter: 'drawtext',
    options: {
      text: 'VERY LONG TEXT VERY VERY VERY VERY LOL!!!',
      fontsize: 36,
      fontcolor: 'white',
      x: '(main_w/2-text_w/2)',
      y: '(text_h/2)+15',
      shadowcolor: 'black',
      shadowx: 2,
      shadowy: 2
    }}

)
// use the 'flashvideo' preset (located in /lib/presets/flashvideo.js)
.on('end', function() {
  console.log('file has been converted succesfully');
})
.on('error', function(err) {
  console.log('an error happened: ' + err.message);
}).pipe(res)
  

它只是在最后一行更改   我得到这个错误:

an error happened: ffmpeg exited with code 1: pipe:1: Invalid argument

如何导出此ffmpeg命令以流式传输响应????

0 个答案:

没有答案