1

我正在尝试使用模块 node-fluent-ffmpeg ( https://github.com/schaermu/node-fluent-ffmpeg ) 对视频文件进行转码和流式传输。由于我在 Windows 机器上,我首先从官方网站 ( http://ffmpeg.zeranoe.com/builds/ ) 下载了 FFMpeg。然后我提取文件夹 C:/FFmpeg 中的文件并将路径添加到系统路径(准确地说是 bin 文件夹)。我通过在命令提示符下键入来检查 FFmpeg 是否工作:ffmpeg -version。它给出了成功的回应。

之后,我继续从模块中复制/更改了以下代码(https://github.com/schaermu/node-fluent-ffmpeg/blob/master/examples/express-stream.js):

app.get('/video/:filename', function(req, res) {
res.contentType('avi');
console.log('Setting up stream')

var stream = 'c:/temp/' + req.params.filename
var proc = new ffmpeg({ source: configfileResults.moviepath + req.params.filename, nolog: true, timeout: 120, })
    .usingPreset('divx')
    .withAspect('4:3')
    .withSize('640x480')
    .writeToStream(res, function(retcode, error){
        if (!error){
            console.log('file has been converted succesfully',retcode);
        }else{
            console.log('file conversion error',error);
        }
    });
});

我已经用 flowplayer 正确设置了客户端并试图让它运行但没有任何反应。我检查了控制台,它说:

file conversion error timeout

之后我增加了超时,但不知何故,它只在我重新加载页面时开始。但是由于页面重新加载,当然会立即停止。我是否需要为文件转码制作单独的节点服务器?还是我需要触发某种事件?

我可能错过了一些简单的东西,但我似乎无法让它工作。希望有人能指出我错过了什么。

谢谢

4

1 回答 1

1

我已经通过使用 videoJs 而不是 Flowplayer 来修复它。在我的情况下,flowplayer 的启动方式无法正常工作。所以我初始化流,然后初始化 videojs 以显示流。效果很好。

于 2013-04-29T17:36:59.927 回答