1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-25 02:04:06 +02:00
This commit is contained in:
kev 2016-02-24 13:48:14 +08:00
parent b0724f785e
commit 4333ce1239
7 changed files with 242 additions and 0 deletions

View File

@ -82,6 +82,7 @@ dockerfiles
- [x] redis-arm
- [x] revive
- [x] rsyncd
- [x] rtmp
- [x] samba :beetle:
- [x] scrapyd :+1:
- [x] shadowsocks

84
rtmp/README.md Normal file
View File

@ -0,0 +1,84 @@
rtmp
====
- NGINX-based Media Streaming Server.
- FFMPGE-based Media Streaming Client.
## Directory Tree
```
~/fig/rtmp/
├── data/
│ └── video.mp4
├── docker-compose.yml
└── nginx/
└── nginx.conf
```
## docker-compose.yml
```yaml
server:
image: vimagick/nginx
ports:
- "1935:1935"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./data:/data
restart: always
client:
image: vimagick/rtmp-client-arm
devices:
- /dev/video0:/dev/video0
environment:
- RTMP_URI=rtmp://datageek.info/live/webcam
restart: always
```
## Server
```
$ cd ~/fig/rtmp/
$ docker-compose up -d server
$ youtube-dl 'https://www.youtube.com/watch?v=lJZlz-WnXzU' -o data/video.mp4
```
## Client
```
# play remote video (remote -> local)
$ vlc rtmp://datageek.info/vod/video.mp4
# play local video (local -> remote -> local)
$ ffmpeg -re -i video.mp4 -f flv rtmp://datageek.info/live/video
$ vlc rtmp://datageek.info/live/video.mp4
# capture desktop (local -> remote)
$ ffmpeg -f avfoundation -pixel_format bgr0 -i 1:0 -f flv rtmp://datageek.info/live/webcam
# record webcam (local -> remote)
$ ffmpeg -f qtkit -i 0 -f flv rtmp://datageek.info/live/webcam
# record pi camera (pi -> remote)
$ ffmpeg -f video4linux2 -r 24 -i /dev/video0 -f flv rtmp://datageek.info/live/webcam
# record pi camera (pi -> remote)
$ /opt/vc/bin/raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | ffmpeg -i - -f flv rtmp://datageek.info/live/webcam
# watch webcam (remote -> local)
$ vlc rtmp://datageek.info/live/webcam
```
Optinally, you can run a docker container as RTMP client on raspberry pi.
```
$ cd ~/fig/rtmp/
$ docker-compose up -d client
```
## References
- https://github.com/arut/nginx-rtmp-module/wiki/Directives
- https://trac.ffmpeg.org/wiki/StreamingGuide
- https://trac.ffmpeg.org/wiki/Capture/Webcam

12
rtmp/client/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
#
# Dockerfile for rtmp-client-arm
#
FROM vimagick/alpine-arm
MAINTAINER kev <noreply@datageek.info>
RUN set -xe \
&& apk add -U ffmpeg \
&& rm -rf /var/cache/apk/*
CMD ffmpeg -f video4linux2 -r 24 -i /dev/video0 -f flv $RTMP_URI

View File

@ -0,0 +1,7 @@
client:
image: vimagick/rtmp-client-arm
devices:
- /dev/video0:/dev/video0
environment:
- RTMP_URI=rtmp://boss.datageek.info/live/webcam
restart: always

View File

@ -0,0 +1 @@
PLEASE PUT VIDEO FILES HERE

View File

@ -0,0 +1,8 @@
server:
image: vimagick/nginx
ports:
- "1935:1935"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./data:/data
restart: always

View File

@ -0,0 +1,129 @@
#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;
}
}
}