1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-11-28 09:08:36 +02:00
dockerfiles/rtmp/README.md

90 lines
2.0 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:
image: vimagick/rtmp-client-arm
2016-05-01 03:06:20 +02:00
# command: ffmpeg -i /dev/video0 -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-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-03-05 13:47:20 +02:00
> You can run customized `ffmpeg` command.
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
```
## References
- https://github.com/arut/nginx-rtmp-module/wiki/Directives
- https://trac.ffmpeg.org/wiki/StreamingGuide
- https://trac.ffmpeg.org/wiki/Capture/Webcam
2016-02-25 06:33:13 +02:00
- http://apk-dl.com/vlc-for-android/org.videolan.vlc/