Last active
January 19, 2020 19:56
-
-
Save YooWaan/fc5cf27f884e72ad88e0b4b86ac54be6 to your computer and use it in GitHub Desktop.
nginx hls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" > | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<link href="http://vjs.zencdn.net/5.19.0/video-js.css" rel="stylesheet"> | |
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script> | |
</head> | |
<body> | |
<video id="my-live" class="video-js" controls preload="auto" width="640" height="400" data-setup='{}'> | |
<source src="rtmp://192.168.0.2/live/test" type='video/mp4'> | |
<source src="http://192.168.0.2:3000/hls/live/test.m3u8" type='application/x-mpegURL'> | |
<p class="vjs-no-js"> | |
To view this video please enable JavaScript, and consider upgrading to a web browser | |
that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a> | |
</p> | |
</video> | |
<!-- | |
--> | |
<script src="http://vjs.zencdn.net/5.19.0/video.js"></script> | |
<video width="640" height="400" controls id="video"></video> | |
<script> | |
if(Hls.isSupported()) { | |
var video = document.getElementById('video'); | |
var hls = new Hls(); | |
hls.loadSource('http://192.168.0.2:3000/hls/live/test.m3u8'); | |
hls.attachMedia(video); | |
hls.on(Hls.Events.MANIFEST_PARSED,function() { | |
video.play(); | |
}); | |
} | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#user nobody; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
# '$status $body_bytes_sent "$http_referer" ' | |
# '"$http_user_agent" "$http_x_forwarded_for"'; | |
#access_log logs/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
#gzip on; | |
server { | |
listen 3000; | |
server_name localhost; | |
#charset koi8-r; | |
#access_log logs/host.access.log main; | |
location / { | |
root html; | |
index index.html index.htm; | |
} | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
location /stat { | |
rtmp_stat all; | |
rtmp_stat_stylesheet stat.xsl; | |
} | |
location /stat.xsl { | |
root /home/develop/hls/stats; | |
} | |
location /control { | |
rtmp_control all; | |
} | |
location /hls { | |
types { | |
application/vnd.apple.mpegurl m3u8; | |
} | |
alias /home/develop/hls/html/hls; | |
add_header Cache-Control no-cache; | |
} | |
} | |
} | |
rtmp { | |
server { | |
listen 1935; | |
access_log logs/rtmp_access.log; | |
application live { | |
live on; | |
record off; | |
wait_video on; | |
hls on; | |
hls_path /home/develop/hls/html/hls/live; | |
hls_fragment 8; | |
hls_playlist_length 16; | |
hls_cleanup on; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#ngx_ver=nginx-1.10.3 | |
ngx_ver=nginx-1.11.12 | |
rtmp_mod=nginx-rtmp-module-master | |
ossl_mod=openssl-master | |
#http://nginx.org/download/nginx-1.11.12.tar.gz | |
nginx_src="http://nginx.org/download/${ngx_ver}.tar.gz" | |
rtmp_src="https://github.com/arut/nginx-rtmp-module/archive/master.zip" | |
ossl_src="https://github.com/openssl/openssl/archive/master.zip" | |
work_dir=`pwd`/hls | |
prefix_dir="${HOME}/hls" | |
info() | |
{ | |
echo "********************* $1 **************************" | |
} | |
initenv() | |
{ | |
info "init env" | |
rm -rf $work_dir | |
mkdir -p $work_dir | |
cat <<EOF | |
WORK DIR: $work_dir | |
INSTALL DIR: $prefix_dir | |
EOF | |
} | |
dl() | |
{ | |
info "dl" | |
cd $work_dir | |
wget $nginx_src | |
wget -O rtmp.zip $rtmp_src | |
wget -O ssl.zip $ossl_src | |
tar zxf ${ngx_ver}.tar.gz | |
unzip rtmp.zip | |
unzip ssl.zip | |
} | |
buildinstall() | |
{ | |
info "build" | |
# --with-openssl=$(brew --prefix openssl) \ | |
# --with-http_ssl_module \ | |
# --with-cc-opt=-m64 --with-ld-opt=-m64 \ | |
cd $work_dir/$ngx_ver | |
./configure --prefix=$prefix_dir \ | |
--with-http_ssl_module \ | |
--with-openssl=../$ossl_mod \ | |
--add-module=../$rtmp_mod | |
make | |
info "install" | |
#make install | |
} | |
initenv | |
dl | |
buildinstall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install build-essential | |
sudo apt-get install libpcre3-dev | |
sudo apt-get install libssl-dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment