add files, update roots

This commit is contained in:
Jonatan Nilsson 2024-02-07 19:43:58 +00:00
parent 106f0a8232
commit 00f1dffb15
11 changed files with 644 additions and 0 deletions

206
conf/nginx.conf Normal file
View file

@ -0,0 +1,206 @@
worker_processes auto;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
# ssl_prefer_server_ciphers on;
##
# Logging Settings
##
# access_log /var/log/nginx/access.log;
# error_log /var/log/nginx/error.log;
log_format main '$remote_addr $remote_user [$time_local] "$request" '
'$status "$http_referer" "$http_user_agent"';
access_log /dev/stdout main;
error_log stderr debug;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
server {
listen 80 default_server;
listen [::]:80 default_server;
root /srv/nginx/www;
index index.html index.htm index.nginx-debian.html;
server_name filadelfia.nfp.is;
add_header Access-Control-Allow-Headers "*";
add_header Access-Control-Expose-Headers "*";
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
add_header Access-Control-Allow-Origin "*";
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
#try_files $uri /notfound.mp4;
#if (!-e $request_filename) {
# rewrite . /notfound.mp4 break;
#}
}
location /kennsluraudio {
root /srv/filo_web;
}
location /posters {
root /srv/filo_web;
}
location /kennslurraw {
alias /srv/filo_web/kennslur;
autoindex on;
}
#VOD MODULE TEST
open_file_cache max=1000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
location /vod-status/ {
vod_status;
}
location /kennslur/ {
vod hls;
vod_mode local;
vod_metadata_cache metadata_cache 512m 6h;
vod_response_cache response_cache 64m 6h;
vod_performance_counters perf_counters;
vod_align_segments_to_key_frames on;
vod_manifest_segment_durations_mode accurate;
vod_hls_absolute_master_urls off;
vod_hls_absolute_index_urls off;
vod_hls_absolute_iframe_urls off;
root /srv/filo_web;
gzip on;
gzip_types application/vnd.apple.mpegurl;
expires 100d;
add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
add_header Access-Control-Allow-Headers "*";
add_header Access-Control-Expose-Headers "*";
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
add_header Access-Control-Allow-Origin "*";
}
#VOD TEST ENDS
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 500 501 502 503 504 505 506 507 508 509 510 511 /index.html;
location /index.html {
alias /srv/nginx/www/index.html;
}
location /crossdomain.xml {
alias /srv/nginx/www/crossdomain.xml;
}
location /start_the_recording.php {
content_by_lua_file /srv/nginx/www/start_the_recording.lua;
}
location /stop_recording.php {
content_by_lua_file /srv/nginx/www/stop_recording.lua;
}
location /samkomur.html {
content_by_lua_file /srv/nginx/www/samkomur.lua;
}
location /samkomur.json {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
content_by_lua_file /srv/nginx/www/samkomur_json.lua;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
}

16
conf/supervisord.conf Normal file
View file

@ -0,0 +1,16 @@
[supervisord]
loglevel=info
nodaemon=true
user=root
[program:nginx]
command=/usr/local/nginx/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

7
www/crossdomain.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all" />
<allow-access-from domain="*" to-ports="*" />
<allow-http-request-headers-from domain="*" headers="*" />
</cross-domain-policy>

145
www/index.html Normal file
View file

@ -0,0 +1,145 @@
<!doctype html>
<html lang="is" dir="ltr" data-cast-api-enabled="true">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Filadelfia</title>
<style>
* {-webkit-box-sizing: border-box;Box-Sizing:border-box;}
HTML, BODY, #main {
Margin:0;
Padding:0;
Width:100%;
Height:100%;
Overflow:hidden;
Background:#000;
}
#player {
Margin:0 auto;
Overflow:hidden;
}
</style>
</head>
<body>
<main>
<div id="player">
<div id="playerdiv">
</div>
</div>
</main>
<script src="//content.jwplatform.com/libraries/Xl6C9H3O.js"></script>
<script>
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function resizePlayer(player) {
var D = document;
var player=D.getElementById('player');
var srcWidth=1280;
var srcHeight=720;
var maxWidth=Math.max( Math.max(D.body.scrollWidth, D.documentElement.scrollWidth), Math.max(D.body.offsetWidth, D.documentElement.offsetWidth), Math.max(D.body.clientWidth, D.documentElement.clientWidth) );
var maxHeight=Math.min( Math.min(D.body.scrollHeight, D.documentElement.scrollHeight), Math.min(D.body.offsetHeight, D.documentElement.offsetHeight), Math.min(D.body.clientHeight, D.documentElement.clientHeight) );
var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
player.style.width=Math.round(srcWidth*ratio)+'px';
player.style.height=Math.round(srcHeight*ratio)+'px';
}
window.onload=function() {
resizePlayer('player');
var clip='';
var clipStart=0;
if(getParameterByName("start") != '' && parseInt(getParameterByName("start")) > 0) {
clip+='clipFrom/'+(getParameterByName("start")*1000)+'/';
clipStart=getParameterByName("start");
}
if(getParameterByName("duration") != '' && parseInt(getParameterByName("duration")) > 0) {
clip+='clipTo/'+((parseInt(clipStart)+parseInt(getParameterByName("duration")))*1000)+'/';
}
if(getParameterByName("video") != '') {
stream='https://filadelfia.nfp.is/kennslur/'+getParameterByName("video")+'/'+clip+'master.m3u8';
console.log('file');
} else if(getParameterByName("audio") != '') {
stream='https://filadelfia.nfp.is/kennsluraudio/'+getParameterByName("audio");
console.log('audio');
} else if(getParameterByName("audioonly") != '') {
stream='https://filadelfia.nfp.is/kennslur/'+getParameterByName("audioonly")+'/tracks/a1/master.m3u8';
console.log('audio-only');
} else {
stream='https://filadelfia.nfp.is/notfound.mp4';
console.log('none');
}
if(getParameterByName("poster") != '') {
poster='/posters/'+getParameterByName("poster");
} else if(getParameterByName("posterurl") != '') {
poster=getParameterByName("posterurl");
} else {
poster='https://filadelfia.nfp.is/b.png';
}
console.log(stream);
jwplayer('playerdiv').setup({
/*
sources: [{
file: stream,
//},{file: 'http://filadelfia.rcx.is/notfound.mp4',
}],
*/
playlist: [/*{
file: 'https://filadelfia.nfp.is/intro.mp4',
image: poster,
},*/
{
file: stream,
image: poster,
}],
image: poster,
width: '100%',
height: '100%',
autostart: true,
aspectratio: '16:9',
stretching: 'exactfit',
androidhls: 'true',
fallback: 'false',
primary: 'flash'
});
var playerInstance = jwplayer('playerdiv');
playerInstance.onError( function(e) {
console.log(e);
playerInstance.load({file:'https://filadelfia.nfp.is/notfound.mp4'});
playerInstance.play(true);
});
}
window.onresize=function() {resizePlayer('player');};</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-68293245-1', 'auto');
ga('send', 'pageview');
</script>
</body></html>

BIN
www/intro.mp4 Normal file

Binary file not shown.

BIN
www/notfound.mp4 Normal file

Binary file not shown.

View file

@ -0,0 +1,12 @@
<html>
<head>
<title>Upptokustyring</title>
<body>
<form action="/start_the_recording.php">
<br />
Taka upp sem: <input name="output" id="output" type="text" value=""> <input type="submit" id="submit-button" value="Hefja upptoku"> <input type="button" value="Stodva upptoku" onclick="window.location='stop_recording.php';return false;">
</form>
</body>
</html>

135
www/samkomur.lua Normal file
View file

@ -0,0 +1,135 @@
local files = {}
local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending
end
local p = io.popen('ls -a "/content/kennslur"')
for file in p:lines() do
if ends_with(file, '.mp4') and not ends_with(file, 'klippt.mp4') then
table.insert(files, file)
end
end
table.sort(files, function(a, b) return b < a end)
local total = 6
if total > #files then
total = #files
end
ngx.say([[
<!doctype html>
<html lang="is" dir="ltr" data-cast-api-enabled="true">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Filadelfia</title>
<style>
* {
-webkit-box-sizing: border-box;
Box-Sizing: border-box;
}
HTML,
BODY,
#main {
Margin: 0;
Padding: 0;
Width: 100%;
Height: 100%;
Overflow: hidden;
Background: #000;
}
#player {
Margin: 0 auto;
Overflow: hidden;
}
</style>
</head>
<body>
<main>
<div id="player">
<div id="playerdiv">
</div>
</div>
</main>
<script src="//content.jwplatform.com/libraries/Xl6C9H3O.js"></script>
<script>
function resizePlayer(player) {
var D = document;
var player = D.getElementById('player');
var srcWidth = 1280;
var srcHeight = 720;
var maxWidth = Math.max(Math.max(D.body.scrollWidth, D.documentElement.scrollWidth), Math.max(D.body.offsetWidth, D.documentElement.offsetWidth), Math.max(D.body.clientWidth, D.documentElement.clientWidth));
var maxHeight = Math.min(Math.min(D.body.scrollHeight, D.documentElement.scrollHeight), Math.min(D.body.offsetHeight, D.documentElement.offsetHeight), Math.min(D.body.clientHeight, D.documentElement.clientHeight));
var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
player.style.width = Math.round(srcWidth * ratio) + 'px';
player.style.height = Math.round(srcHeight * ratio) + 'px';
}
window.onload = function() {
resizePlayer('player');
jwplayer('playerdiv').setup({
/*
sources: [{
file: stream,
//},{file: 'http://filadelfia.rcx.is/notfound.mp4',
}],
*/
playlist: [
]])
for i = 1, total do
ngx.say(' { file: "https://filadelfia.nfp.is/kennslur/' .. files[i] .. '/master.m3u8", image: "https://filadelfia.nfp.is/kennslurraw/' .. files[i]:gsub('.mp4','.jpg') .. '", title: "' .. files[i]:gsub('.mp4','') .. '" }, ')
end
ngx.say([[
],
image: '',
width: '100%',
height: '100%',
autostart: true,
aspectratio: '16:9',
stretching: 'exactfit',
androidhls: 'true',
fallback: 'false',
primary: 'flash'
});
var playerInstance = jwplayer('playerdiv');
playerInstance.onError(function(e) {
playerInstance.load({ file: 'https://filadelfia.nfp.is//notfound.mp4' });
playerInstance.play(true);
});
}
window.onresize = function() { resizePlayer('player'); };
</script>
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-68293245-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
]])

85
www/samkomur_json.lua Normal file
View file

@ -0,0 +1,85 @@
local files = {}
local map = {}
--[[ function tprint (tbl, indent)
if not indent then indent = 0 end
for k, v in pairs(tbl) do
formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
print(formatting)
tprint(v, indent+1)
elseif type(v) == 'boolean' then
print(formatting .. tostring(v))
else
print(formatting .. v)
end
end
end ]]--
local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending
end
local p = io.popen('ls -a "/content/kennslur"')
for file in p:lines() do
if ends_with(file, '.mp4') and not ends_with(file, 'klippt.mp4') then
table.insert(files, file)
end
end
table.sort(files, function(a, b) return b < a end)
local created = 0
for i = 1, #files do
temp = {}
for s in string.gmatch(files[i], '([^_.]+)') do
temp[#temp + 1] = s
end
if string.match(temp[1], '^%d%d%d%d%-%d%d%-%d%d$') and string.match(temp[2], '^%d%d%d%d$') then
if not map[temp[1]] then
created = created + 1
if created > 6 then break end
map[temp[1]] = {}
end
table.insert(map[temp[1]], {
time = temp[2],
file = files[i],
})
end
end
local result = {}
for k,v in pairs(map) do
table.sort(v, function(a,b) return a['time'] < b['time'] end)
table.insert(result, {
date = k,
items = v,
})
end
table.sort(result, function(a,b) return a['date'] > b['date'] end)
ngx.say('[')
for k,v in pairs(result) do
ngx.say(' {')
ngx.say(' "data":"' .. v['date'] .. '",')
ngx.say(' "items": [')
for x,y in pairs(v['items']) do
if next(v['items'], x) == nil then
ngx.say(' { "time":"' .. y['time'] .. '", "file":"' .. y['file'] .. '" }')
else
ngx.say(' { "time":"' .. y['time'] .. '", "file":"' .. y['file'] .. '" },')
end
end
ngx.say(' ]')
if next(result, k) == nil then
ngx.say(' }')
else
ngx.say(' },')
end
end
ngx.say(']')

View file

@ -0,0 +1,24 @@
if not ngx.var.arg_output then
ngx.say("Missing query 'output'")
return
end
assert(io.popen("/usr/bin/ffmpeg -y -i 'rtmp://192.168.93.59:1935/live/ljosbrot live=1' -vcodec copy -acodec copy /content/kennslur/".. ngx.var.arg_output ..".mp4 </dev/null >/dev/null 2>/dev/null &"))
ngx.say([[
<br>
<input type="button" value="Stodva upptoku" onclick="window.location='stop_recording.php';return false;">
]])
--[[
<?php
error_reporting(E_ALL);
if(!isset($_REQUEST['output'])) { die('Missing output'); }
//$output = exec("/usr/bin/ffmpeg -y -i rtmp://157.157.65.93:443/filadelfia/stream1 -vcodec copy -acodec copy fftest15.mp4 </dev/null >/dev/null 2>/var/log/ffmpeg.log &");
//$output = exec("/usr/bin/ffmpeg -y -i rtmp://157.157.65.93:443/filadelfia/stream1 -vcodec copy -acodec copy /content/kennslur/".$_REQUEST['output'].".mp4 </dev/null >/dev/null 2>/dev/null &1");
$output = exec("/usr/bin/ffmpeg -y -i 'rtmp://82.221.112.178:1935/live/ljosbrot live=1' -vcodec copy -acodec copy /content/kennslur/".$_REQUEST['output'].".mp4 </dev/null >/dev/null 2>/dev/null &1");
print_r($output);
echo PHP_EOL.'OK START';
?>
<br>
<input type="button" value="Stodva upptoku" onclick="window.location='stop_recording.php';return false;">
--]]

14
www/stop_recording.lua Normal file
View file

@ -0,0 +1,14 @@
local f = assert(io.popen("/usr/bin/killall -INT ffmpeg", "r"))
os.execute("sleep 1")
local s = assert(f:read('*all'))
ngx.say(s:gsub("\n", "\n<br>"))
ngx.say([[
<br>
]])
--[[
<?php
$output = shell_exec("/usr/bin/killall -INT ffmpeg");
echo $output;
echo PHP_EOL.'OK';
?>
]]