Revisão | 61dd9835f0a99ff4fe3dc2b5a61f8bbae516387a (tree) |
---|---|
Hora | 2017-03-06 21:57:02 |
Autor | dyknon <dyknon@user...> |
Commiter | dyknon |
Javascript:配信待追加, server:引数で動画指定, socket:home以下に
@@ -31,10 +31,13 @@ use utf8; | ||
31 | 31 | use IO::Socket::UNIX; |
32 | 32 | use JSON; |
33 | 33 | use Encode; |
34 | +use Cwd; | |
34 | 35 | |
35 | 36 | $| = 1; |
36 | 37 | |
37 | -my $sockpath = "/tmp/media_server.sock"; | |
38 | +my $home = Cwd::getcwd(); | |
39 | +$home =~ s!/public_html/.*!/!; | |
40 | +my $sockpath = $home."socks/media_server.sock"; | |
38 | 41 | |
39 | 42 | if(!$ENV{QUERY_STRING}){ |
40 | 43 | binmode(STDOUT, ":utf8"); |
@@ -90,8 +93,12 @@ if(!$ENV{QUERY_STRING}){ | ||
90 | 93 | this.cont.appendChild(this.fs_button); |
91 | 94 | } |
92 | 95 | live_streamer.prototype.keycb = function(resp){ |
93 | - if(resp === null || resp.status == "nostreams"){ | |
96 | + if(resp === null){ | |
97 | + this.statbox.textContent = "通信エラー(再読込してね)"; | |
98 | + return; | |
99 | + }else if(resp.status == "nostreams"){ | |
94 | 100 | this.statbox.textContent = "配信なしだよ。"; |
101 | + window.setTimeout(function(t){t.keyretrycb()}, 300, this); | |
95 | 102 | return; |
96 | 103 | } |
97 | 104 | this.sindex = resp.key; |
@@ -101,10 +108,17 @@ if(!$ENV{QUERY_STRING}){ | ||
101 | 108 | this.statbox.textContent = "loading video header"; |
102 | 109 | //this.cindex++; |
103 | 110 | }; |
111 | + live_streamer.prototype.keyretrycb = function(){ | |
112 | + this.nexcb = this.keycb; | |
113 | + this.request("key", null); | |
114 | + }; | |
104 | 115 | live_streamer.prototype.datacb = function(resp){ |
105 | 116 | if(resp === null){ |
106 | 117 | this.statbox.textContent = "放送終了かな。"; |
107 | 118 | this.ms.endOfStream(); |
119 | + window.setTimeout(function(t){ | |
120 | + new live_streamer(t.velm, t.cont, t.statbox, t.serv); | |
121 | + }, (1000*this.bufremain()+1)|0, this); | |
108 | 122 | return; |
109 | 123 | }else if(resp.status == "nostreams"){ |
110 | 124 | this.statbox.textContent = "配信なしだよ。"; |
@@ -113,7 +127,6 @@ if(!$ENV{QUERY_STRING}){ | ||
113 | 127 | this.nexcb = this.updatecb; |
114 | 128 | this.sb.addEventListener("updateend", this); |
115 | 129 | this.sb.appendBuffer(resp); |
116 | - this.statbox.textContent = "video data appended"; | |
117 | 130 | }; |
118 | 131 | live_streamer.prototype.updatecb = function(ev){ |
119 | 132 | this.nexcb = this.datacb; |
@@ -32,7 +32,7 @@ use IO::Pipe; | ||
32 | 32 | use IO::Socket::UNIX; |
33 | 33 | use IO::Select; |
34 | 34 | |
35 | -my $sockpath = "/tmp/media_server.sock"; | |
35 | +my $sockpath = $ENV{HOME}."/socks/media_server.sock"; | |
36 | 36 | |
37 | 37 | $| = 1; |
38 | 38 | $SIG{PIPE} = "IGNORE"; |
@@ -658,9 +658,11 @@ $readsel = IO::Select->new(); | ||
658 | 658 | $writesel = IO::Select->new(); |
659 | 659 | |
660 | 660 | my $in_handle = new IO::Pipe; |
661 | -$in_handle->reader(qw{ffmpeg -loglevel panic -i video2stream -map 0:v -map 0:a -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 -b:a 64k -cluster_size_limit 10000000 -cluster_time_limit 1000000 -s hd720 -f webm -}); | |
661 | +#$in_handle->reader(qw{ffmpeg -loglevel panic -i video2stream -map 0:v:0 -map 0:a:0 -c:v vp8 -deadline:v realtime -cpu-used:v 8 -g:v 20 -q:v 30 -qmax:v 32 -live 1 -vf realtime -c:a libvorbis -b:a 64k -cluster_size_limit 10000000 -cluster_time_limit 1000000 -s wvga -f webm -}); | |
662 | 662 | #$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 | 663 | #$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 | +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 -}); | |
664 | 666 | binmode($in_handle, ":raw"); |
665 | 667 | StreamInHandler->new($in_handle); |
666 | 668 |