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

111 lines
2.5 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 06:27:24 +02:00
# command:
# - ffmpeg -i $$RTMP_DEV -video_size 800x600 -vf "hflip,vflip" -f flv $$RTMP_URI
2016-07-08 13:53:48 +02:00
# - ffmpeg -f alsa -ac 1 -ar 22050 -i hw:1 -i $$RTMP_DEV -c:a aac -c:v flv1 -f flv $$RTMP_URI
2016-02-24 07:48:14 +02:00
devices:
2016-07-06 11:04:44 +02:00
# - /dev/snd
- /dev/video0
2016-02-24 07:48:14 +02:00
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-04 06:27:24 +02:00
> - You can run customized command. (It should be single item list!)
> - Input can be a stream instead of device. (It works as a relay!)
2016-03-05 13:47:20 +02:00
2016-07-04 06:27:24 +02:00
## Server Setup
2016-02-24 07:48:14 +02:00
```
$ cd ~/fig/rtmp/
$ docker-compose up -d server
$ youtube-dl 'https://www.youtube.com/watch?v=lJZlz-WnXzU' -o data/video.mp4
```
2016-07-04 06:27:24 +02:00
## Client Setup
2016-02-24 07:48:14 +02:00
```
# 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 06:27:24 +02:00
## OBS Setup
2016-07-04 05:37:59 +02:00
```yaml
Stream Type: Custom Streaming Server
URL: rtmp://192.168.31.254/live/
Streaming key: webcam
```
2016-07-08 13:53:48 +02:00
## Player Setup
- vlc
- ffplay
- [online](https://www.hlsplayer.net/rtmp-player)
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-08 13:53:48 +02:00
- https://trac.ffmpeg.org/wiki/Capture/ALSA
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/