Procházet zdrojové kódy

add rtmp streaming

Alfonso Gamboa před 3 roky
rodič
revize
3ec1d1f822

+ 4 - 0
README.md

@@ -281,8 +281,12 @@ CUSTOM_SCRIPT_PATH=""
 
 ---
 
+Live stream from the local built-in RTSP server to youtube/twitch/facebook live.  edit the file `wz_mini/usr/bin/rtmp-stream.sh` with your stream keys and then run `rtsmp-stream.sh <service>` to begin streaming.  Experimental.
+---
+
 ## Latest Updates
 
+* 05-24-22:  add experimental youtube/twitch/facebook live steam rtmp support in `wz_mini/usr/bin/rtmp-stream.sh`
 * 05-24-22:  add `wz_mini.conf` to replace `run_mmc.sh`, all configuration variables are now stored in this file, scripting logic now in wz_user.sh inside init.d folder. add support for user to add a custom script to run on boot.
 * 05-23-22:  added simple wireguard startup configuration.
 * 05-22-22:  added fps variable for rtsp server, thanks @claudobahn.

binární
SD_ROOT/wz_mini/bin/ffmpeg


+ 1 - 1
SD_ROOT/wz_mini/etc/init.d/v3_post.sh

@@ -1,6 +1,6 @@
 #!/bin/sh
 
-### This file is called by /etc/init.d/rcS, run before app_init.sh
+### This file is called by /etc/init.d/rcS, and is run before app_init.sh
 
 exec 1> /opt/wz_mini/log/v3_post.log 2>&1
 

+ 66 - 0
SD_ROOT/wz_mini/usr/bin/rtmp-stream.sh

@@ -0,0 +1,66 @@
+#! /bin/sh
+
+source /opt/wz_mini/wz_mini.conf
+
+if [[ "$RTSP_PASSWORD" == "" ]]; then
+        RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
+fi
+
+FFMPEG_BINARY="/opt/wz_mini/bin/ffmpeg"
+
+TWITCH_URL="rtmp://live-ber.twitch.tv/app"
+YOUTUBE_URL="rtmp://b.rtmp.youtube.com/live2"
+FACEBOOK_URL="rtmps://live-api-s.facebook.com:443/rtmp"
+
+#######################################
+######ENTER YOUR STREAM KEYS HERE######
+YOUTUBE_KEY=""
+TWITCH_KEY=""
+FACEBOOK_KEY=""
+#######################################
+#######################################
+
+#V3: 1080p=video1 360p=video2
+#V2: 1080p=video6 360p=video7
+
+RTSP_STREAM="video6_unicast"
+
+VIDEO_SOURCE="rtsp://"$RTSP_LOGIN":"$RTSP_PASSWORD"@0.0.0.0:"$RTSP_PORT"/$RTSP_STREAM"
+
+
+if [[ "$1" == "youtube" ]]; then
+        echo "youtube"
+        STREAM_PROVIDER="$YOUTUBE_URL"
+        KEY="$YOUTUBE_KEY"
+elif [[ "$1" == "twitch" ]]; then
+        echo "twitch"
+        STREAM_PROVIDER="$TWITCH_URL"
+        KEY="$TWITCH_KEY"
+elif [[ "$1" == "facebook" ]]; then
+        echo "facebook"
+        STREAM_PROVIDER="$FACEBOOK_URL"
+        KEY="$FACEBOOK_KEY"
+else
+echo "Usage:"
+echo "rtmp facebook"
+echo "rtmp twitch"
+echo "rtmp youtube"
+echo "Update the script with your stream keys first"
+exit 0
+fi
+
+sync;echo 3 > /proc/sys/vm/drop_caches
+
+$FFMPEG_BINARY \
+-rtsp_transport udp -y \
+-i "$VIDEO_SOURCE" \
+-c:v copy -coder 1 -pix_fmt yuv420p -g 30 -bf 0 -b:a 16k -c:a aac -ar 11025 -strict experimental -aspect 16:9 -f flv "$STREAM_PROVIDER/$KEY"
+
+#-re
+#  -c:v copy -coder 1 -pix_fmt yuv420p -minrate 200k -maxrate 1500k -bufsize 1500k -b:v 1000 -r 30 -g 30 -keyint_min 60  \
+#  -s 1920x1080 -b:a 16k -c:a aac -ar 8000  -strict experimental -f flv "$YOUTUBE_URL/$KEY"
+#  -s 640x360 -b:a 16k -c:a aac -ar 8000  -strict experimental -f flv "$YOUTUBE_URL/$KEY"
+
+#-c:v copy -coder 1 -pix_fmt yuv420p -g 30 -bf 0 -c:a aac -ab 4k -strict experimental -aspect 16:9 -f flv "$YOUTUBE_URL/$KEY"
+# -c:v copy -coder 1 -pix_fmt yuv420p -g 30 -bf 2 -c:a aac -ar 11025 -strict 2 -aspect 16:9 -f flv "$YOUTUBE_URL/$KEY"
+#-c:v copy -profile:v high -coder 1 -pix_fmt yuv420p -g 30 -bf 2 -c:a aac  -ab 8k -strict experimental -aspect 16:9 -f flv "$YOUTUBE_URL/$KEY"

+ 2 - 1
v2_install/compile_image.sh

@@ -1,6 +1,7 @@
 #!/bin/bash
 
-DL_URL=$(wget --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" -qO- https://support.wyze.com/hc/en-us/articles/360024852172-Release-Notes-Firmware | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*" | grep /v2/ |   sort -t . -k2r,5 | grep demo | head -1)
+UA_STRING="Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"
+DL_URL=$(wget --header="Accept: text/html" --user-agent="$UA_STRING" -qO- https://support.wyze.com/hc/en-us/articles/360024852172-Release-Notes-Firmware | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*" | grep /v2/ |   sort -t . -k2r,5 | grep demo | head -1)
 
 echo "create work directory"
 mkdir v2_ro