2016-11-22 138 views
0

我需要将视频从我的网络摄像头传输到所有进入我网页的用户。如何以角度从网络摄像头获取视频流

如果我目前进入我的网页,我可以在网络摄像头看到自己,但我希望每个浏览到我的网页的用户都能看到我的直播。

我是新来的角,我在这里错过了什么?我如何向所有进入我的页面的用户进行广播?

我有这样的HTML代码:

<body> 

    <div ng-app="myapp" ng-controller="mainController"> 


     <webcam channel="channel" 
       on-streaming="onSuccess()" 
       on-error="onError(err)" 
       on-stream="onStream(stream)"> 
     </webcam> 
     <button ng-click="makeSnapshot()">take picture</button> 
     <canvas id="snapshot" width="300" height="300"></canvas> 
    </div> 

    <div class="webcam" ng-transclude></div> 

    <div id="stream" ></div> 


</body> 

而我的模块代码:

var webcam = angular.module('myapp', ['webcam']) 
.controller('mainController', function ($scope) { 
    var _video = null, 
    patData = null; 

    $scope.patOpts = { x: 0, y: 0, w: 25, h: 25 }; 

    $scope.channel = {}; 

    $scope.webcamError = false; 
    $scope.onError = function (err) { 

    }; 

    $scope.onSuccess = function() { 

     _video = $scope.channel.video; 
     $scope.$apply(function() { 
      $scope.patOpts.w = _video.width; 
      $scope.patOpts.h = _video.height; 
      $scope.showDemos = true; 
     }); 
    }; 

    $scope.onStream = function (stream) { 
     //i think it is here i need to add some code for streaming 
    }; 

    $scope.makeSnapshot = function() { 

    }; 

    $scope.downloadSnapshot = function downloadSnapshot(dataURL) { 
     window.location.href = dataURL; 
    }; 

    var getVideoData = function getVideoData(x, y, w, h) { 

    }; 

    var sendSnapshotToServer = function sendSnapshotToServer(imgBase64) { 
     $scope.snapshotData = imgBase64; 
    }; 
}); 

回答

0

你需要创建一个实时视频流。

  1. 录制视频流

  2. 发送流到你的服务器和保存文件的MP4

  3. 在主页上,读公共MP4(通过URL)

例如: Live Video Streaming with PHP

相关问题