This is streamer used to stream anime on madoka.whs.in.th. It use videojs as the backend.
curl moduleStreamer now comes with Dockerfile. To install with Docker,
docker run -p 80:80 -e FB_ID=<FBID> -e FB_SECRET=<FBSECRET> willwill/streaming
Replace <FBID> and <FBSECRET> by Facebook App ID and secret respectively (read the app setup section on how to register). You can add -v "<datafolder>:/var/www/html/data/:ro" to mount a data folder (eg. video files) to serve at /data.
Note that this will assume that you're running behind reverse proxy. You can use without one, but it is a security risk. Make sure your reverse proxy can forward websocket.
In the same vhost that host the PHP pages, set
location /privpub/master {
push_stream_publisher;
push_stream_channels_path animestream_master;
push_stream_store_messages on;
}
location /privpub/chat {
push_stream_publisher;
push_stream_channels_path animestream_chat;
}
location /pub/online {
push_stream_publisher;
push_stream_channels_path animestream_online;
}
location ~ /sub/(.*) {
push_stream_subscriber;
push_stream_channels_path $1;
push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":~text~}";
push_stream_ping_message_interval 10s;
}
location ~ /ev/(.*) {
push_stream_subscriber eventsource;
push_stream_channels_path $1;
push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":~text~}";
push_stream_ping_message_interval 10s;
}
location ~ /lp/(.*) {
push_stream_subscriber long-polling;
push_stream_channels_path $1;
push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":~text~}";
push_stream_longpolling_connection_ttl 30s;
}
location ~ /ws/(.*) {
push_stream_subscriber websocket;
push_stream_channels_path $1;
push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":~text~}";
push_stream_ping_message_interval 10s;
}
FB_ID and FB_SECRET.http://yoururl/path/to/streaming/?master=1. If required, log in and retry the URL.Streamer use a very similar technique from Noke to keep client updated.
The master sends a "keyframe" every 3 seconds. The keyframe tells that what second in the video is now playing and also the file name and other state.
A client after connecting to the push server will wait for a keyframe which is if missing for 3 seconds will throw an error that master is missing. After receiving a keyframe, it loads the media and seeks to the specified time.
When the keyframe time and current video time of a client is over 3 seconds apart, the client corrects this by skipping to the keyframe time. (This also creates the loop effect as noted in the notes section, and also use to implement seeking)
In clients, there're "lag" and "ping" meters. Lag show how much that client's video time is apart from the server. Positive indicates lag behind. Ping show how long does keyframe stopped appearing at expected time. The ping meter starts counting 3 seconds after last keyframe arrived.
A keyframe may contains a "force" flag. Forced keyframes appear when server have manually changed media. Clients encoutering force flag will try to reload the media.
Licensed under StealItPl 1.1 or AGPLv3. You can use this only for non commercial use with under 100 active users in a month and retain this license term in your derivatives or you can use it under the terms of AGPLv3.
Content type
Image
Digest
Size
18.5 MB
Last updated
about 9 years ago
docker pull willwill/streaming