From 87be6b8740b099e715f040470a3f21313923abcd Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Wed, 27 Dec 2023 20:29:55 -0800 Subject: [PATCH 1/6] add sync to s3 script for recordings --- nginx.conf | 6 ++++++ sync_to_s3.sh | 4 ++++ 2 files changed, 10 insertions(+) create mode 100755 sync_to_s3.sh diff --git a/nginx.conf b/nginx.conf index aed3ba5..f2dde81 100644 --- a/nginx.conf +++ b/nginx.conf @@ -133,6 +133,12 @@ rtmp { record all; record_path /home/www/video_recordings; record_suffix -%d-%b-%y-%T.flv; + + # on_record_done http://example.com/recorded; + + # convert recorded file to mp4 format + # exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4; + exec_record_done ./sync_to_s3.sh $path } application vj { diff --git a/sync_to_s3.sh b/sync_to_s3.sh new file mode 100755 index 0000000..42d93f0 --- /dev/null +++ b/sync_to_s3.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +PATH=ARGV[1] +aws s3 cp $PATH s3://datafruitsvizdumps From 89c74a970f2f4bbe4413cc855cb3a0dcaf78afc8 Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Mon, 10 Jun 2024 20:54:16 -0700 Subject: [PATCH 2/6] delete recording after upload --- sync_to_s3.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sync_to_s3.sh b/sync_to_s3.sh index 42d93f0..2c7237f 100755 --- a/sync_to_s3.sh +++ b/sync_to_s3.sh @@ -2,3 +2,4 @@ PATH=ARGV[1] aws s3 cp $PATH s3://datafruitsvizdumps +rm $PATH From c935fe2cf6cf0ad5bc9c3be1bba1dc391635f18f Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Mon, 10 Jun 2024 20:56:25 -0700 Subject: [PATCH 3/6] add aws cli to dockerfile --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e4a2978..d68b9ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:18.04 RUN apt-get update RUN apt-get upgrade -y -RUN apt-get install -y build-essential libpcre3 libpcre3-dev libssl-dev unzip ffmpeg wget zlib1g zlib1g-dev libssl-dev sudo +RUN apt-get install -y build-essential libpcre3 libpcre3-dev libssl-dev unzip ffmpeg wget zlib1g zlib1g-dev libssl-dev sudo curl RUN useradd --create-home -s /bin/bash www ;\ adduser www sudo @@ -29,6 +29,11 @@ ADD crossdomain.xml /usr/local/nginx/html/crossdomain.xml ADD nginx.conf /home/www RUN sudo chown -R www:www /usr/local/nginx +# aws cli +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" +RUN unzip -u awscliv2.zip +RUN sudo ./aws/install + EXPOSE 80 443 1935 CMD ["/usr/local/nginx/sbin/nginx", "-c", "/home/www/nginx.conf"] From 110813fa87d3a876d025572edae93c35288df381 Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Fri, 29 May 2026 12:11:15 -0700 Subject: [PATCH 4/6] login to streampusher w stream key and publish to icecast --- README.md | 5 +++++ nginx.conf | 59 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 35f1781..429b5f6 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,8 @@ Then stop the container and start it again with the same command. ``` docker run -p 1935:1935 -p 8080:8080 -p 16666:4443 -v /home/deploy/viz/fullchain.pem:/etc/letsencrypt/live/viz.streampusher.com/fullchain.pem -v /home/deploy/viz/privkey.pem:/etc/letsencrypt/live/viz.streampusher.com/privkey.pem datafruits/viz:latest ``` + +## Building new image: +``` +docker build -t datafruits/viz:latest . +``` diff --git a/nginx.conf b/nginx.conf index f2dde81..e1f811d 100644 --- a/nginx.conf +++ b/nginx.conf @@ -11,36 +11,36 @@ events { http { server { listen 8080; - listen 4443 ssl; - server_name viz.streampusher.com; - ssl_certificate /etc/letsencrypt/live/viz.streampusher.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/viz.streampusher.com/privkey.pem; + # listen 4443 ssl; + # server_name viz.streampusher.com; + # ssl_certificate /etc/letsencrypt/live/viz.streampusher.com/fullchain.pem; + # ssl_certificate_key /etc/letsencrypt/live/viz.streampusher.com/privkey.pem; server_name vjstream.streampusher.com localhost; location /hls { - # Serve HLS fragments - - # CORS setup - add_header 'Access-Control-Allow-Origin' '*' always; - add_header 'Access-Control-Expose-Headers' 'Content-Length'; - - # allow CORS preflight requests - if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Max-Age' 1728000; - add_header 'Content-Type' 'text/plain charset=UTF-8'; - add_header 'Content-Length' 0; - return 204; - } + # Serve HLS fragments + # CORS setup + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length'; - types { - application/vnd.apple.mpegurl m3u8; - video/mp2t ts; - } - root /tmp; - add_header Cache-Control no-cache; + # allow CORS preflight requests + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + + + types { + application/vnd.apple.mpegurl m3u8; + video/mp2t ts; + } + root /tmp; + add_header Cache-Control no-cache; } location /vj { @@ -69,13 +69,13 @@ http { } location /vj2 { -# Serve HLS fragments + # Serve HLS fragments -# CORS setup + # CORS setup add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Expose-Headers' 'Content-Length'; -# allow CORS preflight requests + # allow CORS preflight requests if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Max-Age' 1728000; @@ -138,7 +138,10 @@ rtmp { # convert recorded file to mp4 format # exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4; - exec_record_done ./sync_to_s3.sh $path + # exec_record_done ./sync_to_s3.sh $path + on_publish http://streampusher-rails-1:3000/dj_login.json; + + exec_push ffmpeg -i rtmp://localhost/$app/$name -vn -c:a libmp3lame -f mp3 icecast://rtmp_source:pricemaster9876@datafruits_liquidsoap:9001/datafruits_rtmp; } application vj { From 569d909fd8223f3bf7dcd21a70d11af2e2a429e9 Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Mon, 1 Jun 2026 15:40:57 -0700 Subject: [PATCH 5/6] output to icecast and input.rtmp with one ffmpeg command --- nginx.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index e1f811d..534b64d 100644 --- a/nginx.conf +++ b/nginx.conf @@ -141,7 +141,9 @@ rtmp { # exec_record_done ./sync_to_s3.sh $path on_publish http://streampusher-rails-1:3000/dj_login.json; - exec_push ffmpeg -i rtmp://localhost/$app/$name -vn -c:a libmp3lame -f mp3 icecast://rtmp_source:pricemaster9876@datafruits_liquidsoap:9001/datafruits_rtmp; + # send to icecast and rtmp listener in one ffmpeg command + exec_push ffmpeg -i rtmp://localhost/$app/$name -map 0:a -c:a libmp3lame -f mp3 icecast://rtmp_source:pricemaster9876@datafruits_liquidsoap:9001/datafruits_rtmp -map 0:v -map 0:a -c copy -f flv rtmp://datafruits_liquidsoap:1936/live/$name; + } application vj { From 204595c485446d3d317c65fb857f4712a214d1a5 Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Tue, 2 Jun 2026 09:39:36 -0700 Subject: [PATCH 6/6] add new datafruits_hls endpoint --- nginx.conf | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/nginx.conf b/nginx.conf index 534b64d..5a3b0b0 100644 --- a/nginx.conf +++ b/nginx.conf @@ -92,6 +92,31 @@ http { root /tmp; add_header Cache-Control no-cache; } + location /datafruits_hls { + # Serve HLS fragments from liquidsoap output + + # CORS setup + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length'; + + # allow CORS preflight requests + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + + types { + application/vnd.apple.mpegurl m3u8; + video/mp2t ts; + } + + root /tmp; + add_header Cache-Control no-cache; + } + location /live { # Serve HLS fragments