Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dorfTV
ansible-role-nginx-rtmp
Commits
558e143d
Commit
558e143d
authored
May 16, 2020
by
hatsch
Browse files
update hls.
parent
191fb5a1
Changes
5
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
558e143d
...
...
@@ -38,7 +38,7 @@ Example Playbook
key: live
secret: mynewsecret
roles:
-
{ role:
username.rolename
}
-
{ role:
dorftv.nginx-rtmp
}
License
-------
...
...
tasks/site_rtmp_tasks.yml
View file @
558e143d
-
debug
:
var=rtmp
-
name
:
"
Create
HLS
directory
for
{{
rtmp.key
}}"
file
:
state
:
directory
path
:
"
/var/www/{{
site.key
}}/{{
item
}}/{{
rtmp.key
}}"
owner
:
www-data
group
:
www-data
with_items
:
-
hls
-
player
-
name
:
"
Template
rtmp
application
{{
rtmp.key
}}
for
{{
site.key
}}"
template
:
src
:
rtmp.j2
...
...
@@ -13,4 +23,9 @@
dest
:
"
/etc/nginx/rtmp-enabled/{{
site.key
}}_{{
rtmp.key
}}"
state
:
link
notify
:
-
reload nginx
-
reload nginx
-
name
:
"
Add
index.html"
template
:
src
:
index.html.j2
dest
:
"
/var/www/{{
site.key
}}/player/{{
rtmp.key
}}/index.html"
templates/index.html.j2
0 → 100644
View file @
558e143d
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
Clappr/Hls.js with P2P Media Loader
</title>
<meta
charset=
"utf-8"
>
<script
src=
"https://cdn.jsdelivr.net/npm/p2p-media-loader-core@latest/build/p2p-media-loader-core.min.js"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@latest/build/p2p-media-loader-hlsjs.min.js"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/clappr@latest"
></script>
</head>
<body>
<div
id=
"player"
></div>
</br></br></br>
<div
id=
"info"
>
RTMP Url: {{ site.key }}/{{rtmp.key}}
</br>
###### To be removed
</br>
KEY: {{ rtmp.value.key }}
</br>
Secret: {{ rtmp.value.secret }}
</br>
</div>
<script>
if
(
p2pml
.
hlsjs
.
Engine
.
isSupported
())
{
var
engine
=
new
p2pml
.
hlsjs
.
Engine
();
var
player
=
new
Clappr
.
Player
({
parentId
:
"
#player
"
,
source
:
"
http://{{ site.key }}/hls/{{rtmp.key}}/{{ rtmp.value.key }}/index.m3u8
"
,
actualLiveTime
:
true
,
mute
:
true
,
autoPlay
:
true
,
width
:
'
640
'
,
height
:
'
360
'
,
hideMediaControl
:
true
,
playback
:
{
hlsjsConfig
:
{
liveSyncDurationCount
:
7
,
loader
:
engine
.
createLoaderClass
()
}
}
});
p2pml
.
hlsjs
.
initClapprPlayer
(
player
);
}
else
{
document
.
write
(
"
Not supported :(
"
);
}
</script>
</body>
</html>
templates/rtmp.j2
View file @
558e143d
application {{ rtmp.key }} {
#GENERAL STREAM SETTING
wait_key on;
interleave on;
sync 10ms;
hls_cleanup on;
drop_idle_publisher 60s;
live on;
#ALLOW SETTINGS
allow publish all;
allow play all;
#HLS SETTINGS
hls on;
#hls_dvr on;
hls_
path /var/www/{{ site.key }}/data/{{rtmp.key}};
hls_
nested on
;
hls_
cleanup on;
hls_
path /var/www/{{ site.key }}/hls/{{rtmp.key}}/
;
hls_type live;
hls_fragment 5s;
hls_base_url https://{{ site.key }}/{{ rtmp.value.key }};
hls_variant _high BANDWIDTH=1200000;
hls_variant _mid BANDWIDTH=664000;
hls_variant _low BANDWIDTH=362000;
#RECORD SETTINGS
record all;
record_path /var/www/{{ site.key }}/data/record;
record_suffix -%d-%b-%y-%T.flv;
hls_nested on;
hls_base_url http://{{ site.key }}/hls/{{ rtmp.key }}/;
hls_fragment_naming system;
hls_fragment_slicing plain;
hls_playlist_length 180m;
hls_continuous on;
hls_continuous on;
hls_playlist_length 10s;
hls_fragment 1s;
#ALLOW SETTINGS
allow publish all;
allow play all;
#RECORD SETTINGS
#record all;
#record_path /var/www/{{ site.key }}/data/record;
#record_suffix -%d-%b-%y-%T.flv;
meta off;
#hls_allow_client_cache enabled;
...
...
templates/sites.j2
View file @
558e143d
...
...
@@ -8,8 +8,30 @@ server {
index index.html;
{% for key, value in site.value.endpoints.items() %}
############## {{ value.key }} #######################
location /{{ key }}/ {
alias /var/www/{{ site.key }}/player/{{ key }}/;
}
location /hls/{{ key }} {
alias /var/www/{{ site.key }}/hls/{{ key }};
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers accept;
try_files $uri $uri/ =404;
}
location /auth/{{ key }}/{{ value.key }} {
if ($arg_psk = '{{ value.secret }}') {
return 201;
...
...
@@ -17,6 +39,8 @@ server {
return 404;
}
############## END {{ value.key }} #######################
{% endfor %}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment