2013-04-16 90 views
0

我正在運行fluent-ffmpeg sample來傳輸視頻,這很好。現在在合約中展示基於flashe版本的流式播放器中的視頻,我現在使用的是html5版本的流式播放器,但它表示未找到視頻文件。使用fluent-ffmpeg node.js模塊流式傳輸視頻的錯誤

app.get('/video2/abc', function(req, res) { 

    console.log('/video/:filename'); 
    res.contentType('mp4'); 
    var pathToMovie = 'public/flowplayer/470x250.mp4' ; 
    var proc = new ffmpeg({ source: pathToMovie, nolog: true }) 
    .writeToStream(res, function(retcode, error){ 
     if(error) console.error('error',error); 
     else console.log('file has been converted succesfully'); 
    }); 
}); 

這是我的html模板。

<html> 
    <head> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"> </script> 
     <script src="http://releases.flowplayer.org/5.4.0/flowplayer.min.js"></script> 
     <link rel="stylesheet" type="text/css" href="http://releases.flowplayer.org/5.4.0/skin/minimalist.css" /> 
     <title>node-fluent-ffmpeg</title> 
    </head> 
    <body> 
    <script> 
    // global configuration (optional) 
    flowplayer.conf = { 
     rtmp: "rtmp://s3b78u0kbtx79q.cloudfront.net/cfx/st", 
     swf: "http://releases.flowplayer.org/5.4.0/flowplayer.swf" 
    }; 

    // force flash with query - only for testing, do not use this switch in production! 
    if (/flash/.test(location.search)) flowplayer.conf.engine = "flash"; 

    // install player manually 
    $(function() { 
     $(".player").flowplayer({ 
     // reverse fraction of video aspect ratio 
     // video dimensions: 470px/250px 
     ratio: 25/47 
     }); 
    }); 
</script> 
    <div class="flowplayer"> 
     <video> 
      <source type="video/mp4" src="/video2/your_movie"/> 
     </video> 
    </div> 
    </body> 
</html> 

回答

1

我有一個類似的問題,並決定使用video-js代替。其中的功能非常完美。

檢查出來:http://www.videojs.com/

在我來說,我注入視頻標籤使用jQuery和動態加載視頻。像這樣:

//I append the video tag so I remove it if I already appended it before. 
    if($('#player').length) $('#player').remove(); 


    $('body').append('<video id="player" class="video-js vjs-default-skin" controls preload="auto" width="100%" height="100%" poster="my_video_poster.png" data-setup="{}"> <source src="'+url+'" type="video/webm"></video>'); 

    // Load the player dynamically. see: http://www.videojs.com/docs/setup/ 
    _V_("player", {}, function(){});