2017-04-24 4 views
0

ウェブサーバ上の選択したビデオファイルをクライアントにストリーミングする必要があります。私は要求されたこれらのファイルをストリーミングするためにPHPスクリプトを使用していますが、私はローカルネット上にある場合、それはうまく動作する問題に実行されていますが、私は離れている場合、それはstutters。例えば。十分なメディアが再生できるようになるまで、ストリームをロードし、停止し、さらにロードし、停止します。私はこのことを初めて熟知しているので、この問題を克服する方法について助言が必要です。帯域幅は問題ではないはずなので、何が起こっているのかは分かりません。私はいくつかのPHPストリーマを試しましたが、すべて同じように動作します。私はvideojsを使用してクライアント内に表示しています。サーバからPHPを使用してビデオをストリーミングする

<?php 
use vendor\videojswidget\VideoJsWidget; 
$url = Yii::$app->urlManager->createUrl('/site/putvideo'); 
$currentVideo = ''; 
$script1 = "function playAnotherVideo(){ 
    var source = document.getElementById('fileSelector'); 
    var path = source.value; 
    $.ajax({ 
     type: 'post', 
     data: {file: path}, 
     url: '" .$url. "', 
     success: function(result){ 
      var video = document.getElementById('videoPlayer'); 
      video.src = result; 
      alert(result); 
      video.load(); 
     }, 
     error: function(){ 
      alert('error'); 
     } 
    }); 
}"; 

$this->registerJs($script1, yii\web\View::POS_END, 'my-options'); 

/* @var $this yii\web\View */ 

$this->title = 'View Vault Lecture Capture System'; 
?> 
<div class="site-index" style="background-color: black; color: yellow;"> 

    <div style="background-color: black;"> 
     </br></br></br></br>  
     <h1 align="center">Welcome to the TEKVOX Lecture Capture System</h1> 
     </br></br></br></br> 
    </div> 
    <div class="body-content"> 
     <div style="width: 100%; overflow: hidden;"> 
     <div style="width: 50px; float: left;"> 
     </br></br> 
     <label for="fileselector" style="margin-left: 4em; width: 10em; 
      font-weight: bold; color: #FFFF00;">Video_Files</label> 
     <select id="fileSelector" onchange="playAnotherVideo()" size="10em" 
     style="margin-left: 0em; color: #FFFF00; background-color: #000000; 
     border-color: #FFFFFF"> 
<?php 
     if ($handle = opendir('c:/users/admin/videos/')) { 

      while (false !== ($entry = readdir($handle))) { 

       if ($entry != "." && $entry != ".." && 
        strtolower(substr($entry, strrpos($entry, '.') + 1)) == 
         'mp4'){  
        echo "<option value='$entry'>" .$entry. "</option>"; 
       } 
      } 

      closedir($handle); 
     } 
?> 
</select> 
</div> 
<span id="divplayer" style="margin-left: 20em;"> 
<?php 

echo VideoJsWidget::widget([ 
    'options' => [ 
     'class' => '', 
     'id' => 'videoPlayer', 
     'poster' => "GreenX.png", 
     'controls' => true, 
     'preload' => 'none', 
     'width' => '800', 
     'height' => '450', 
    ], 
    'tags' => [ 
     'source' => [ 
      ['src' => '', 'type' => 'video/mp4'], 
     ], 
     'track' => [ 
      ['kind' => 'captions', 'src' => 
'http://vjs.zencdn.net/vtt/captions.vtt', 'srclang' => 'en', 'label' => 
'English'] 
     ] 
    ] 
]); 

?> 
     </span> 
    </div> 
</div> 
</br> 

getVideo.phpコード:?も奇妙である何 VideoStream

されています。私は現在、アウトしようとしています

<?php 
include_once "videoStream.php"; 
$filename = $_GET['filename']; 
if($filename == '') 
    return; 
$file = "c:\\users\\admin\\videos\\" .$filename; 

$stream = new VideoStream($file); 
$stream->start(); 

>

VideoStream.phpクラスでありますプレーヤーの一番下にあるバーは、ビデオがバッファされていることを示しているように見えますが、プレーヤーはまだ乱雑です。それが何を意味するかわからない。

+0

サンプルコードを含め、これまでに試したことを分かち合うと助けになります。 – iangetz

+0

http://nginx.org/en/docs/http/ngx_http_mp4_module.htmlとhttps://github.com/arut/nginx-rtmp-moduleを見てきましたが、PHPはあなたが望むものにはあまり適していませんが、オーバーヘッドが大きくなります。 – hdezela

答えて

0

説明する動作は、低または断続的な帯域幅接続でのビデオ配信の典型です。

これを解決するためのアプローチは、一般的に、非常に洗練されているが、容易に利用可能なストリーミングサーバに内蔵され、サーバー側で、例えば:https://gstreamer.freedesktop.org

また、クラウドの前面またはAkamiなどのようなCDNを使用してから利益を得ることができる - これらは基本的にありユーザーの応答時間を短縮するために、ネットワークの端にコンテンツのコピーを作成するように設計されています。

関連する問題