diff --git a/rtmp/README.md b/rtmp/README.md index d17e281..304d42f 100644 --- a/rtmp/README.md +++ b/rtmp/README.md @@ -10,29 +10,18 @@ rtmp ~/fig/rtmp/ ├── data/ │ └── video.mp4 -├── docker-compose.yml -├── html -│   ├── img -│   │   └── cctv.jpg -│   ├── index.html -│   └── js -│   ├── jquery.min.js -│   ├── jwplayer.flash.swf -│   └── jwplayer.js -└── nginx/ - └── nginx.conf +└── docker-compose.yml ``` ## docker-compose.yml ```yaml server: - image: vimagick/nginx + image: vimagick/rtmp-server ports: - "1935:1935" - "9999:80" volumes: - - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./data:/data restart: always @@ -64,7 +53,7 @@ $ vlc rtmp://easypi.info/vod/video.mp4 # play local video (local -> remote -> local) $ ffmpeg -re -i video.mp4 -f flv rtmp://easypi.info/live/video -$ vlc rtmp://easypi.info/live/video.mp4 +$ vlc rtmp://easypi.info/live/video # capture desktop (local -> remote) $ ffmpeg -f avfoundation -pixel_format bgr0 -i 1:0 -f flv rtmp://easypi.info/live/webcam @@ -80,6 +69,9 @@ $ /opt/vc/bin/raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | ffmpeg -i - -f flv # watch webcam (remote -> local) $ vlc rtmp://easypi.info/live/webcam + +# watch webcam (remote -> local) +$ firefox http://easypi.info:9999/ ``` Optinally, you can run a docker container as RTMP client on raspberry pi. diff --git a/rtmp/server/Dockerfile b/rtmp/server/Dockerfile new file mode 100644 index 0000000..85a9434 --- /dev/null +++ b/rtmp/server/Dockerfile @@ -0,0 +1,15 @@ +# +# Dockerfile for rtmp-server +# + +FROM alpine +MAINTAINER kev + +RUN apk add --no-cache nginx-rtmp + +COPY nginx.conf /etc/nginx/nginx.conf +COPY html /var/lib/nginx/html + +EXPOSE 80 1935 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/rtmp/server/data/README.md b/rtmp/server/data/README.md index 0c68e77..4e0e7d6 100644 --- a/rtmp/server/data/README.md +++ b/rtmp/server/data/README.md @@ -1 +1,2 @@ -PLEASE PUT VIDEO FILES HERE +PUT VIDEO FILES HERE +==================== diff --git a/rtmp/server/docker-compose.yml b/rtmp/server/docker-compose.yml index ef44006..fe0f67c 100644 --- a/rtmp/server/docker-compose.yml +++ b/rtmp/server/docker-compose.yml @@ -1,10 +1,8 @@ server: - image: vimagick/nginx + image: vimagick/rtmp-server ports: - "1935:1935" - "9999:80" volumes: - - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./data:/data - - ./html:/usr/share/nginx/html restart: always diff --git a/rtmp/server/nginx.conf b/rtmp/server/nginx.conf new file mode 100644 index 0000000..3a6257d --- /dev/null +++ b/rtmp/server/nginx.conf @@ -0,0 +1,38 @@ +user nginx; +worker_processes 1; +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + server { + listen 80; + server_name localhost; + location / { + root html; + index index.html index.htm; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +} + +rtmp { + server { + listen 1935; + application live { + live on; + } + application vod { + play /data; + } + } +} diff --git a/rtmp/server/nginx/nginx.conf b/rtmp/server/nginx/nginx.conf deleted file mode 100644 index 90f69a4..0000000 --- a/rtmp/server/nginx/nginx.conf +++ /dev/null @@ -1,129 +0,0 @@ - -#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 80; - 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; - } - - # proxy the PHP scripts to Apache listening on 127.0.0.1:80 - # - #location ~ \.php$ { - # proxy_pass http://127.0.0.1; - #} - - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 - # - #location ~ \.php$ { - # root html; - # fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; - # include fastcgi_params; - #} - - # deny access to .htaccess files, if Apache's document root - # concurs with nginx's one - # - #location ~ /\.ht { - # deny all; - #} - } - - - # another virtual host using mix of IP-, name-, and port-based configuration - # - #server { - # listen 8000; - # listen somename:8080; - # server_name somename alias another.alias; - - # location / { - # root html; - # index index.html index.htm; - # } - #} - - - # HTTPS server - # - #server { - # listen 443 ssl; - # server_name localhost; - - # ssl_certificate cert.pem; - # ssl_certificate_key cert.key; - - # ssl_session_cache shared:SSL:1m; - # ssl_session_timeout 5m; - - # ssl_ciphers HIGH:!aNULL:!MD5; - # ssl_prefer_server_ciphers on; - - # location / { - # root html; - # index index.html index.htm; - # } - #} - -} - -rtmp { - server { - listen 1935; - application live { - live on; - } - application vod { - play /data; - } - } -}