簡體   English   中英

如何從網絡攝像頭獲取視頻流

[英]How to get video stream from webcam in angular

我需要將視頻從網絡攝像頭流傳輸到所有進入我的網頁的用戶。

如果我當前轉到我的頁面,則可以在網絡攝像頭中看到自己,但是我希望每個瀏覽到我的頁面的用戶都可以實時觀看我的廣播。

我是新手,我在這里想念什么? 如何向所有進入我的頁面的用戶廣播?

我有這個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;
    };
});

您需要創建一個Stream Live視頻。

  1. 記錄網絡攝像頭流

  2. 將流發送到您的服務器並保存mp4文件

  3. 在首頁中,閱讀公共mp4(按url)

例如: 使用PHP進行實時視頻流

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM