1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-23 01:39:27 +02:00
dockerfiles/rtmp/README.md

101 lines
2.3 KiB
Markdown
Raw Normal View History

2016-02-24 07:48:14 +02:00
rtmp
====
- NGINX-based Media Streaming Server.
- FFMPGE-based Media Streaming Client.
## Directory Tree
```
~/fig/rtmp/
├── data/
│ └── video.mp4
2016-07-03 18:07:38 +02:00
└── docker-compose.yml
2016-02-24 07:48:14 +02:00
```
## docker-compose.yml
```yaml
server:
2016-07-03 18:07:38 +02:00
image: vimagick/rtmp-server
2016-02-24 07:48:14 +02:00
ports:
- "1935:1935"
2016-02-25 06:33:13 +02:00
- "9999:80"
2016-02-24 07:48:14 +02:00
volumes:
- ./data:/data
restart: always
client:
2016-07-03 18:52:24 +02:00
image: easypi/rtmp-client-arm
2016-07-04 05:37:59 +02:00
# command: ffmpeg -i /dev/video0 -video_size 640x480 -vf "hflip,vflip" -f flv rtmp://cctv.easypi.info/live/webcam
2016-02-24 07:48:14 +02:00
devices:
- /dev/video0:/dev/video0
environment:
2016-07-03 18:52:24 +02:00
# - RTMP_DEV=rtsp://192.168.42.1/live
2016-05-01 03:06:20 +02:00
- RTMP_URI=rtmp://easypi.info/live/webcam
2016-02-24 07:48:14 +02:00
restart: always
```
2016-07-03 18:52:24 +02:00
> - You can run customized `ffmpeg` command.
> - Input can be stream instead of device. (It works as a relay!)
2016-03-05 13:47:20 +02:00
2016-02-24 07:48:14 +02:00
## 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)
2016-05-01 03:06:20 +02:00
$ vlc rtmp://easypi.info/vod/video.mp4
2016-02-24 07:48:14 +02:00
# play local video (local -> remote -> local)
2016-05-01 03:06:20 +02:00
$ ffmpeg -re -i video.mp4 -f flv rtmp://easypi.info/live/video
2016-07-03 18:07:38 +02:00
$ vlc rtmp://easypi.info/live/video
2016-02-24 07:48:14 +02:00
# capture desktop (local -> remote)
2016-05-01 03:06:20 +02:00
$ ffmpeg -f avfoundation -pixel_format bgr0 -i 1:0 -f flv rtmp://easypi.info/live/webcam
2016-02-24 07:48:14 +02:00
# record webcam (local -> remote)
2016-05-01 03:06:20 +02:00
$ ffmpeg -f qtkit -i 0 -f flv rtmp://easypi.info/live/webcam
2016-02-24 07:48:14 +02:00
# record pi camera (pi -> remote)
2016-05-01 03:06:20 +02:00
$ ffmpeg -f video4linux2 -r 24 -i /dev/video0 -f flv rtmp://easypi.info/live/webcam
2016-02-24 07:48:14 +02:00
# record pi camera (pi -> remote)
2016-05-01 03:06:20 +02:00
$ /opt/vc/bin/raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | ffmpeg -i - -f flv rtmp://easypi.info/live/webcam
2016-02-24 07:48:14 +02:00
# watch webcam (remote -> local)
2016-05-01 03:06:20 +02:00
$ vlc rtmp://easypi.info/live/webcam
2016-07-03 18:07:38 +02:00
# watch webcam (remote -> local)
$ firefox http://easypi.info:9999/
2016-02-24 07:48:14 +02:00
```
Optinally, you can run a docker container as RTMP client on raspberry pi.
```
$ cd ~/fig/rtmp/
$ docker-compose up -d client
```
2016-07-04 05:37:59 +02:00
## OBS
```yaml
Stream Type: Custom Streaming Server
URL: rtmp://192.168.31.254/live/
Streaming key: webcam
```
2016-02-24 07:48:14 +02:00
## References
- https://github.com/arut/nginx-rtmp-module/wiki/Directives
- https://trac.ffmpeg.org/wiki/StreamingGuide
- https://trac.ffmpeg.org/wiki/Capture/Webcam
2016-07-04 05:37:59 +02:00
- https://trac.ffmpeg.org/wiki/EncodingForStreamingSites
2016-02-25 06:33:13 +02:00
- http://apk-dl.com/vlc-for-android/org.videolan.vlc/