如何使用Node JS& amp; ffmpeg实时显示水印Angular JS

时间:2015-06-23 09:32:48

标签: angularjs node.js ffmpeg

我正在使用ffmpeg。我已经使用过ffmpeg的水印。在我的过程中,我保存了该视频(标有水印)&然后我能够显示该视频。但我想实时显示水印。我怎么能这样呢?需要这个实时节目的帮助。

这是我的代码:

        try {
            var process = new ffmpeg('public/'+req.body.video);
            process.then(function (video) {
              console.log('The video is ready to be processed');
              var watermarkPath = 'public/images/logo.png',
                newFilepath = 'public/videos/watermarked/'+name,
                settings = {
                    position        : "SC"      // Position: NE NC NW SE SC SW C CE CW
                  , margin_nord     : null      // Margin nord
                  , margin_sud      : null      // Margin sud
                  , margin_east     : null      // Margin east
                  , margin_west     : null      // Margin west
                };
              var callback = function (error, files) {
                if(error){
                  console.log('ERROR: ', error);
                }
                else{
                  console.log('TERMINOU', files);
                  res.send('videos/watermarked/'+name)
                }
              }
              //add watermark
              video.fnAddWatermark(watermarkPath, newFilepath, settings, callback)

            }, function (err) {
              console.log('Error: ' + err);
            });
          } catch (e) {
            console.log(e.code);
            console.log(e.msg);
          }

1 个答案:

答案 0 :(得分:1)

var process = new ffmpeg('public/'+req.body.video);
                    process.then(function (video) {
                        // console.log('The video is ready to be processed');
                        var watermarkPath = 'public/images/logo_2.png',
                            newFilepath = 'public/videos/watermarked/'+name,
                            settings = {
                                position        : "SC"      // Position: NE NC NW SE SC SW C CE CW
                                , margin_nord     : null      // Margin nord
                                , margin_sud      : null      // Margin sud
                                , margin_east     : null      // Margin east
                                , margin_west     : null      // Margin west
                            };
                        var callback = function (error, files) {
                            if(error){
                                console.log('ERROR: ', error);
                            }
                            else{
                                // console.log('TERMINOU', files);
                                res.send('videos/watermarked/'+name)
                            }
                        }
                        //add watermark
                        video.fnAddWatermark(watermarkPath, newFilepath, settings, callback)

                    }, function (err) {
                        console.log('Error: ' + err);
                    });