Revision | 7d98aa7e9f360169e62c957460ef177822fb7303 (tree) |
---|---|
Time | 2017-03-30 21:02:02 |
Author | dyknon <dyknon@user...> |
Commiter | dyknon |
再生速度で同期する気がする
@@ -111,6 +111,8 @@ if(!$ENV{QUERY_STRING}){ | ||
111 | 111 | } |
112 | 112 | this.sindex = resp.key; |
113 | 113 | this.cindex = resp.key; |
114 | + this.cache_len = resp.buflen / 1000; | |
115 | + this.skip_delay = this.cache_len*2; | |
114 | 116 | this.nexcb = this.datacb; |
115 | 117 | this.request("head", null); |
116 | 118 | this.statbox.textContent = "loading video header"; |
@@ -279,19 +281,19 @@ if($con){ | ||
279 | 281 | $num = $args{n}; |
280 | 282 | } |
281 | 283 | $con->send("i".pack("Q", $num), 0); |
282 | - $con->recv($buf, 8*4+1, 0); | |
283 | - my ($cnum, $size, $pos, $cpos, $flags) = unpack("QQQQC", $buf); | |
284 | + $con->recv($buf, 8*4+4+1, 0); | |
285 | + my ($cnum, $size, $pos, $cpos, $buf_len, $flags) = unpack("QQQQLC", $buf); | |
284 | 286 | send_json({status=>"ok", num=>$cnum, size=>$size, |
285 | - pos=>$pos, cpos=>$cpos, flags=>$flags}); | |
287 | + pos=>$pos, cpos=>$cpos, buflen=>$buf_len, flags=>$flags}); | |
286 | 288 | }elsif($args{req} eq "key"){ |
287 | 289 | $con->send("k", 0); |
288 | 290 | $con->recv($buf, 8, 0); |
289 | 291 | my $num = unpack("Q", $buf); |
290 | 292 | $con->send("i".pack("Q", $num), 0); |
291 | - $con->recv($buf, 8*4+1, 0); | |
292 | - my ($cnum, $size, $pos, $cpos, $flags) = unpack("QQQQC", $buf); | |
293 | + $con->recv($buf, 8*4+4+1, 0); | |
294 | + my ($cnum, $size, $pos, $cpos, $buf_len, $flags) = unpack("QQQQLC", $buf); | |
293 | 295 | send_json({status=>"ok", key=>$num, num=>$cnum, size=>$size, |
294 | - pos=>$pos, cpos=>$cpos, flags=>$flags}); | |
296 | + pos=>$pos, cpos=>$cpos, buflen=>$buf_len, flags=>$flags}); | |
295 | 297 | }elsif($args{req} eq "head"){ |
296 | 298 | if(defined($args{n})){ |
297 | 299 | if($args{n} =~ /^[0-9]+$/){ |
@@ -340,8 +342,8 @@ if($con){ | ||
340 | 342 | }elsif($args{n} =~ /^[0-9]+$/){ |
341 | 343 | $num = $args{n}; |
342 | 344 | $con->send("i".pack("Q", $num), 0); |
343 | - $con->recv($buf, 8*4+1, 0); | |
344 | - my ($cnum, $size, $pos, $cpos, $flags) = unpack("QQQQC", $buf); | |
345 | + $con->recv($buf, 8*4+4+1, 0); | |
346 | + my ($cnum, $size, $pos, $cpos, $buf_len, $flags) = unpack("QQQQLC", $buf); | |
345 | 347 | if(!($flags & 0x01)){ |
346 | 348 | goto IF_BAD_REQ; |
347 | 349 | } |
@@ -33,6 +33,7 @@ use IO::Socket::UNIX; | ||
33 | 33 | use IO::Select; |
34 | 34 | |
35 | 35 | my $sockpath = $ENV{HOME}."/socks/media_server.sock"; |
36 | +our $buf_len = 5000; | |
36 | 37 | |
37 | 38 | $| = 1; |
38 | 39 | $SIG{PIPE} = "IGNORE"; |
@@ -573,8 +574,8 @@ sub read{ | ||
573 | 574 | if($cluster_num){ |
574 | 575 | $cpos = int($clusters{$cluster_num-1}{time} * 1000); |
575 | 576 | } |
576 | - $self->{wbuf} = pack("QQQQC", | |
577 | - $cluster_num, $sum, $pos, $cpos, $flags); | |
577 | + $self->{wbuf} = pack("QQQQLC", | |
578 | + $cluster_num, $sum, $pos, $cpos, $buf_len, $flags); | |
578 | 579 | } |
579 | 580 | } |
580 | 581 | }else{ |
@@ -662,7 +663,7 @@ my $in_handle = new IO::Pipe; | ||
662 | 663 | #$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 -}); |
663 | 664 | #$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 -}); |
664 | 665 | 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 -ac 2 -ar 44.1k -b:a 64k -cluster_size_limit 10000000 -cluster_time_limit 1000000 -s wvga -f webm -}); | |
666 | +$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 24 -qmax:v 28 -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 -}); | |
666 | 667 | binmode($in_handle, ":raw"); |
667 | 668 | StreamInHandler->new($in_handle); |
668 | 669 |