Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream audio + video #3

Open
wants to merge 8 commits into
base: streaming_poc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ RUN $SCRIPTS_PATH/janus.sh
COPY scripts/config.sh $SCRIPTS_PATH/
RUN $SCRIPTS_PATH/config.sh

EXPOSE 8188 8189 6000/udp
EXPOSE 8188 8189 5002/udp 5004/udp

CMD ["/root/janus/bin/janus"]
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
TEMPLATE_NAME ?= janus

run: image
@docker run -it -p 8188:8188 -p 8189:8189 -p 6000:6000/udp -p 6001:6001/udp -p 6002:6002/udp $(TEMPLATE_NAME)

shell: image
@docker run -it -p 8188:8188 -p 8189:8189 -p 6000:6000/udp -p 6001:6001/udp -p 6002:6002/udp $(TEMPLATE_NAME) /bin/bash

image:
@docker build -t $(TEMPLATE_NAME) .
run-demo:
docker-compose up
@echo "open brower at http://localhost:8000 port"
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# docker-janus

Run up a [janus-gateway](https://github.com/meetecho/janus-gateway) instance using docker.
Run up a [janus-gateway](https://github.com/meetecho/janus-gateway) instance using docker,

## Streaming test
## Demonstration of streaming camera audio + video to web browser

1. Install docker and GStreamer 1.0.
1. install docker-compose
2. run `VIDEO_DEVICE=/dev/video0 ALSA_DEVICE=plughw:2,0 docker-compose up`
assuming that your camera has `/dev/video0` device and your recording audio source is
at plughw:2,0
3. open browser at http://localhost:8000

2. Build this image with `make image`
you should see a view of camera and hear sounds from your microphone

3. Run the Janus server with `make run`. This will forward some ports: 8088/tcp (HTTP), 8188/tcp (WebSocket), 6000/udp (RTP)

4. Run `./gst_test.sh` to start sending RTP to Janus.

5. Start an HTTP server in `webapps/` and browse to the index. You should see a test pattern.
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.1'
services:
webapp:
image: python:3.9
ports:
- "8000:8000"
command: python3 -m http.server --directory=/webapp
volumes:
- ./webapp:/webapp
janus:
build: .
ports:
- "8188:8188"
- "8189:8189"
- "5002:5002/udp"
- "5004:5004/udp"
videosrc:
build: gst_test
volumes:
- /dev/video0:/dev/video0
- /dev/snd:/dev/snd
environment:
JANUS_SERVER: janus
VIDEO_DEVICE:
ALSA_DEVICE:
privileged: true
13 changes: 0 additions & 13 deletions gst_test.sh

This file was deleted.

12 changes: 12 additions & 0 deletions gst_test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:20.04


RUN apt-get update -y && \
apt-get install -y gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-plugins-rtp \
gstreamer1.0-tools gstreamer1.0-alsa && \
apt-get clean -y


ADD run.sh /run.sh

CMD /run.sh
20 changes: 20 additions & 0 deletions gst_test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

WIDTH=320
HEIGHT=240
SERVER=${JANUS_SERVER:-localhost}
VIDEO_DEVICE=${VIDEO_DEVICE:-/dev/video0}
ALSA_DEVICE=${ALSA_DEVICE:-plughw:1,0}


gst-launch-1.0 \
alsasrc device=${ALSA_DEVICE} ! \
audioresample ! audio/x-raw,channels=1,rate=16000 ! \
opusenc bitrate=20000 ! \
rtpopuspay ! udpsink host=$SERVER port=5002 \
\
v4l2src device=${VIDEO_DEVICE} ! \
video/x-raw,width=$WIDTH,height=$HEIGHT,framerate=15/1 ! \
videoscale ! videorate ! videoconvert ! timeoverlay ! \
vp8enc error-resilient=1 ! \
rtpvp8pay ! udpsink host=$SERVER port=5004
15 changes: 10 additions & 5 deletions scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@ cert_key = $DEPS_HOME/certs/janus.key
EOF

cat << EOF > $DEPS_HOME/etc/janus/janus.plugin.streaming.cfg
[stream0]

[gstreamer-sample]
type = rtp
id = 1
description = stream
audio = no
description = Opus/VP8 live stream coming from gstreamer
audio = yes
video = yes
videoport = 6000
videopt = 96
audioport = 5002
audiopt = 111
audiortpmap = opus/48000/2
videoport = 5004
videopt = 100
videortpmap = VP8/90000
secret = adminpwd
EOF