• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision7bc6626b5a35369008ae9d1194ac808d44739c65 (tree)
Time2017-03-14 21:59:20
Authordyknon <dyknon@user...>
Commiterdyknon

Log Message

主に、再生同期をマシにした。他にも小変更

解像度デフォをwvgaに
次の配信開始待機の開始までの時間を伸ばした
プレイヤーがブラウザ窓の幅より大きくならないように
ボリュームが毎回100%になるのをどうにかした

Change Summary

Incremental Difference

--- a/live.pl
+++ b/live.pl
@@ -51,11 +51,14 @@ if(!$ENV{QUERY_STRING}){
5151 <script>
5252 function live_streamer(videoelm, controlbox, statbox, url){
5353 this.velm = videoelm;
54+ var defvol = this.velm.volume;
5455 this.cont = controlbox;
5556 this.statbox = statbox;
5657 this.serv = url;
5758 this.media_mime = "video/webm; codecs=\\\"vp8, vorbis\\\"";
5859 this.started = false;
60+ this.cache_len = 5;
61+ this.skip_delay = 10;
5962
6063 if(!MediaSource
6164 || !MediaSource.isTypeSupported(this.media_mime)){
@@ -64,6 +67,7 @@ if(!$ENV{QUERY_STRING}){
6467 }
6568 this.ms = new MediaSource();
6669 this.velm.src = URL.createObjectURL(this.ms);
70+ this.velm.volume = defvol;
6771 this.nexcb = null;
6872 var lsobj = this;
6973 this.ms.addEventListener("sourceopen", function(){
@@ -79,7 +83,7 @@ if(!$ENV{QUERY_STRING}){
7983 this.vol_bar.max = 1;
8084 this.vol_bar.min = 0;
8185 this.vol_bar.step = 0.01;
82- this.vol_bar.value = 1;
86+ this.vol_bar.value = defvol;
8387 this.velm.volume = this.vol_bar.value;
8488 this.vol_bar.addEventListener("change", this);
8589 this.cont.innerHTML = "volume: ";
@@ -100,6 +104,10 @@ if(!$ENV{QUERY_STRING}){
100104 this.statbox.textContent = "配信なしだよ。";
101105 window.setTimeout(function(t){t.keyretrycb()}, 300, this);
102106 return;
107+ }else if(resp.flags & 2){
108+ this.statbox.textContent = "配信終了だよ";
109+ window.setTimeout(function(t){t.keyretrycb()}, 300, this);
110+ return;
103111 }
104112 this.sindex = resp.key;
105113 this.cindex = resp.key;
@@ -118,7 +126,7 @@ if(!$ENV{QUERY_STRING}){
118126 this.ms.endOfStream();
119127 window.setTimeout(function(t){
120128 new live_streamer(t.velm, t.cont, t.statbox, t.serv);
121- }, (1000*this.bufremain()+1)|0, this);
129+ }, (1000*this.bufremain()+500)|0, this);
122130 return;
123131 }else if(resp.status == "nostreams"){
124132 this.statbox.textContent = "配信なしだよ。";
@@ -131,7 +139,7 @@ if(!$ENV{QUERY_STRING}){
131139 live_streamer.prototype.updatecb = function(ev){
132140 this.nexcb = this.datacb;
133141 this.request("dat", this.cindex);
134- if(!this.started && this.buftail() > 4){
142+ if(!this.started && this.buftail() >= this.cache_len){
135143 this.started = true;
136144 this.velm.play();
137145 }
@@ -139,10 +147,22 @@ if(!$ENV{QUERY_STRING}){
139147 stat += "time:"+this.velm.currentTime+"<br>";
140148 stat += "buffered:"+this.bufremain()+"<br>";
141149 this.statbox.innerHTML = stat;
142- if(this.bufremain() > 5){
143- this.cindex += 2;
144- }else{
145- this.cindex++;
150+ this.cindex++;
151+ if(this.bufremain() > this.skip_delay){
152+ this.velm.currentTime += this.bufremain() - this.cache_len;
153+ }else if(this.bufremain() > this.cache_len + 1.5){
154+ this.velm.playbackRate = 1
155+ + (this.bufremain() - this.cache_len) / 10;
156+ }else if(this.bufremain() < this.cache_len - 1.5){
157+ this.velm.playbackRate = 1
158+ - (this.cache_len - this.bufremain())
159+ / (this.cache_len * 2);
160+ }else if(this.velm.playbackRate > 1 &&
161+ this.bufremain() <= this.cache_len){
162+ this.velm.playbackRate = 1;
163+ }else if(this.velm.playbackRate < 1 &&
164+ this.bufremain() >= this.cache_len){
165+ this.velm.playbackRate = 1;
146166 }
147167 };
148168 live_streamer.prototype.request = function(com, n){
@@ -224,7 +244,7 @@ if(!$ENV{QUERY_STRING}){
224244 </script>
225245 </head>
226246 <body>
227- <video id="mainvideo"></video>
247+ <video id="mainvideo" style="max-width:100%;max-height:100%"></video>
228248 <div id="controls"></div>
229249 <div id="statbox"></div>
230250 </body>
--- a/unixsock_mediaserver.pl
+++ b/unixsock_mediaserver.pl
@@ -662,7 +662,7 @@ my $in_handle = new IO::Pipe;
662662 #$in_handle->reader(qw{ffmpeg -loglevel panic -f video4linux2 -r:v 10 -s vga -i /dev/video0 -map 0:v -c:v vp8 -deadline:v good -cpu-used:v 16 -g:v 10 -q:v 25 -qmax:v 28 -pix_fmt yuv420p -live 1 -vf realtime -cluster_size_limit 10000000 -cluster_time_limit 1000000 -f webm -});
663663 #$in_handle->reader(qw{ffmpeg -loglevel panic -s 1366x768 -r:v 20 -f x11grab -i :0+1080,880 -map 0:v -c:v vp8 -deadline:v good -cpu-used:v 8 -g:v 10 -q:v 25 -qmax:v 28 -pix_fmt yuv420p -live 1 -cluster_size_limit 10000000 -cluster_time_limit 1000000 -s wvga -vf realtime -f webm -});
664664 defined($ARGV[0]) || die;
665-$in_handle->reader(qw{ffmpeg -loglevel panic -i}, $ARGV[0], qw{-map 0:v:0 -map 0:a:0 -c:v vp8 -deadline:v realtime -cpu-used:v 8 -g:v 20 -q:v 28 -qmax:v 30 -live 1 -vf realtime -c:a libvorbis -b:a 64k -cluster_size_limit 10000000 -cluster_time_limit 1000000 -s hd720 -f webm -});
665+$in_handle->reader(qw{ffmpeg -loglevel panic -i}, $ARGV[0], qw{-map 0:v:0 -map 0:a:0 -c:v vp8 -deadline:v realtime -cpu-used:v 8 -g:v 20 -q:v 28 -qmax:v 30 -live 1 -vf realtime -c:a libvorbis -ac 2 -ar 44.1k -b:a 64k -cluster_size_limit 10000000 -cluster_time_limit 1000000 -s wvga -f webm -});
666666 binmode($in_handle, ":raw");
667667 StreamInHandler->new($in_handle);
668668