From ca60c46b4cdd0a479b5e81fc21c13ff4a0d61f0f Mon Sep 17 00:00:00 2001 From: fpaupier Date: Mon, 21 Feb 2022 19:56:25 +0100 Subject: [PATCH 1/2] add: support for docker-compose Copy the .env.example into a .env file, update with your variable run `docker-compose up` https://github.com/horgh/videostreamer/issues/22 --- .env.example | 6 ++++++ .gitignore | 2 ++ docker-compose.yaml | 30 ++++++++++++++++++++++++++++++ videostreamer.go | 8 ++++---- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 .env.example create mode 100644 docker-compose.yaml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..51f3f3f --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +HOST=0.0.0.0 +PORT=8080 +FORMAT=rtsp +FCGI=false +SOURCE_RTSP=rtsp://rtsp.stream/pattern +VERBOSE=true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3caacd5..eb5311d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.idea +.env *.swp cmd/remux_example/remux_example videostreamer diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..b5fee37 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,30 @@ +version: "2.3" + +services: + rtsp2mp4: + container_name: videostreamer + image: popszer/rtsp2mp4:v0.0.1 + build: . + env_file: + - .env + environment: + - HOST=${HOST} + - PORT=${PORT} + - FCGI=${FCGI} + - VERBOSE=${VERBOSE} + - FORMAT=${FORMAT} + - SOURCE_RTSP=${SOURCE_RTSP} + ports: + - "${PORT}:${PORT}" + command: + - /bin/bash + - -c + - | + /videostreamer -host ${HOST} \ + -port ${PORT} \ + -input ${SOURCE_RTSP} \ + -verbose ${VERBOSE} \ + -fcgi ${FCGI} \ + -format ${FORMAT} + + diff --git a/videostreamer.go b/videostreamer.go index c4ced74..2ab6795 100644 --- a/videostreamer.go +++ b/videostreamer.go @@ -108,10 +108,10 @@ func main() { func getArgs() (Args, error) { listenHost := flag.String("host", "0.0.0.0", "Host to listen on.") listenPort := flag.Int("port", 8080, "Port to listen on.") - format := flag.String("format", "pulse", "Input format. Example: rtsp for RTSP.") - input := flag.String("input", "", "Input URL valid for the given format. For RTSP you can provide a rtsp:// URL.") + format := flag.String("format", "rtsp", "Input format. Example: rtsp for RTSP.") + input := flag.String("input", "rtsp://rtsp.stream/pattern", "Input URL valid for the given format. For RTSP you can provide a rtsp:// URL.") verbose := flag.Bool("verbose", false, "Enable verbose logging output.") - fcgi := flag.Bool("fcgi", true, "Serve using FastCGI (true) or as a regular HTTP server.") + fcgiVar := flag.Bool("fcgi", false, "Serve using FastCGI (true) or as a regular HTTP server.") flag.Parse() @@ -136,7 +136,7 @@ func getArgs() (Args, error) { InputFormat: *format, InputURL: *input, Verbose: *verbose, - FCGI: *fcgi, + FCGI: *fcgiVar, }, nil } From 49213878489feefe19e76dffd5e0429e37ee620b Mon Sep 17 00:00:00 2001 From: fpaupier Date: Mon, 21 Feb 2022 20:03:14 +0100 Subject: [PATCH 2/2] update: getting started doc to support docker usage https://github.com/horgh/videostreamer/issues/22 --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 3bdf0ec..d2b241a 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,21 @@ website. * Run the daemon. Its usage output shows the possible flags. There is no configuration file. +## Running with docker-compose + +1. Copy the provided example environment file `.env.example` +```shell +cp .env.example .env +``` +2. Edit the `.env` environment file with your config, especially the path towards your source input. + +3. Run the app with docker-compose +```shell +docker-compose up +# docker-compose up --build # if you wish to rebuild the docker image +``` + +4. Use your favorite browser to open the `index.html` and you're good! ## Components * `videostreamer`: The daemon.