expand and improve rtmp streaming

This commit is contained in:
Alfonso Gamboa 2022-06-04 04:25:37 -07:00
parent 7a108fc734
commit 80df3561e9
4 changed files with 67 additions and 39 deletions

View File

@ -17,27 +17,26 @@ Using this project can potentially expose your device to the open internet depen
* No modification is done to the device filesystem. **_Zero!_**
* Custom kernel loads all required files from micro-sd card at boot time
* Easy uninstall, just remove files from micro-sd card, or don't use a micro-sd card at all!
* Works on ANY firmware release (so far!)
* Update to the latest stable or beta firmware, this mod should still work!
* Block remote or app initiated firmware updates
* DNS Spoofing or Telnet mod are *not* required prior to installation
* Wireguard and IPv6 support enabled
* Supports the following USB Ethernet adapters:
* ASIX AX88xxx Based USB 2.0 Ethernet Adapters
* ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet
* Realtek RTL8152 Based USB 2.0 Ethernet Adapters
* USB gadget support, connect the camera directly to a supported router to get an internet connection, no USB Ethernet Adapter required, using USB CDC_NCM.
* Easy uninstall, just remove files from micro-sd card, or don't use a micro-sd card at all!
* Add your own changes to run at boot into the script on the micro sd card located at /media/mmc/run_mmc.sh, mount nfs, run ping, whatever you want
* Ability to update to the latest stable or beta firmware, this mod should survive updates as long as the bootloader remains the same
* Ability to block remote AND app initiated firmware updates
* Works on ANY firmware release (so far!)
* DNS Spoofing or Telnet mod are *not* required prior to installation
* Custom script support included
* RTSP Server included, stream video and or audio over LAN
* Tethering to android phones via RNDIS
* Tether your camera directly to android phones using USB via RNDIS support
* USB Mass storage enabled, mount USB SSD/HDD/flash drives
* CIFS Supported
* Play .WAV files using "aplay <file> <vol>" command
* iptables included
* Use your camera as a spare UVC USB Web Camera on your PC!
* Inspired by HclX, bakueikozo, and mnakada!
* Play .wav audio files using "cmd aplay <file> <vol>" command
* WebCam Mode - Use your camera as a spare UVC USB Web Camera on your PC!
* RTMP Streaming - Stream live video from the camera to your favorite service, youtube, twitch, or facebook live.
## Coming Soon
* onvif - maybe
@ -247,19 +246,26 @@ RTSP_LOW_RES_TARGET_BITRATE=""
RTSP_LOW_RES_ENC_PARAMETER=""
RTSP_LOW_RES_FPS=""
ENABLE_MP4_WRITE="false"
```
the singular stream will be located at ```rtsp://login:password@IP_ADDRESS:8554/unicast```
multiple streams are located at ```rtsp://login:password@IP_ADDRESS:8554/video1_unicast``` and ```rtsp://login:password@IP_ADDRESS:8554/video2_unicast```
Note: If you don't set the password, the password will be set to the unique MAC address of the camera, in all uppercase, including the colons... for example:. AA:BB:CC:00:11:22. It's typically printed on the camera. Higher video bitrates may overload your Wi-Fi connection, so a wired connection is recommended.
MP4_WRITE: experimental feature. forces camera to write temporary xx.mp4 files directly to /media/mmc/record/tmp. Normally they are written to /tmp then moved, which can overload camera and or remote network connections. Useful for NFS/CIFS remote video storage.
Huge credit to @mnakada for his libcallback library: [https://github.com/mnakada/atomcam_tools](https://github.com/mnakada/atomcam_tools)
---
mp4_write:
```
ENABLE_MP4_WRITE="false"
```
Forces the camera to skip writing files to /tmp, and write them directly to your storage medium or network mount, prevents trashing. Normally videos are written to /tmp then moved using `mv`, which can overload camera and or remote network connections. Useful for NFS/CIFS remote video storage.
---
Use as a USB Video Class (UVC) Web Camera for your PC is supported. I have tested with Windows 10 and Linux, and it appears as a Generic HD Camera. Audio is supported. This mode disables all other functionality, and only works as a USB Web Camera for your PC. Experimental. Note that the cables typically included with the camera do not data, use a known working micro-usb cable which supports data.
Supported modes: MJPG 360p/720p/1080p, Video 360p/720p/1080p
@ -280,15 +286,26 @@ CUSTOM_SCRIPT_PATH=""
---
Live stream DIRECTLY from the camera's local RTSP server to youtube/twitch/facebook live.
RTMP Streaming:
Edit the file `wz_mini/bin/rtmp-stream.sh` with your stream keys and then run `rtsmp-stream.sh <service>` to begin streaming to your favorite service.
```
RTMP_STREAM_ENABLED="true"
RTMP_STREAM_FEED="video1_unicast"
RMTP_STREAM_SERVICE="youtube"
RTMP_STREAM_DISABLE_AUDIO="false"
RTMP_STREAM_YOUTUBE_KEY="xxx-xxx-xxx-xxx"
RTMP_STREAM_TWITCH_KEY=""
RTMP_STREAM_FACEBOOK_KEY=""
```
Live stream DIRECTLY from the camera's local RTSP server to: `youtube` / `twitch` / `facebook` live. Audio must be enabled in the RTSP section of the configuration for this to work.
---
## Latest Updates
* 06-04-22: updated v2 kernel with fix for webcam mode on v2 camera's, working well now.
* 06-04-22: updated v2 kernel with fix for webcam mode on v2 camera's, working well now. Updated RTMP streaming.
* 05-31-22: added kernel and initramfs configs to src dir, fixed old logs deleted on boot, save dmesg to log folder, upgrade script fixes, user selectable usb ethernet kernel modules in config.
* 05-27-22: update `rtmp-stream.sh`, update various system binaries.
* 05-25-22: usb direct mode and rndis are now supported on the v2 camera
@ -346,6 +363,9 @@ DO NOT USE THIS SOFTWARE IF YOU ARE NOT CONFIDENT IN RESTORING YOUR DEVICE FROM
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## Thank You
Inspired by HclX, bakueikozo, and mnakada!
Thank you to everyone who is passionate about Wyze products for making the devices popular, and thank you to Wyze for producing them. Sign up for CamPlus, show some love and support to the company.
Thanks for HclX for WyzeHacks! [https://github.com/HclX/WyzeHacks/](https://github.com/HclX/WyzeHacks/)

View File

@ -14,22 +14,9 @@ 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=""
#######################################
#######################################
VIDEO_SOURCE="rtsp://"$RTSP_LOGIN":"$RTSP_PASSWORD"@0.0.0.0:"$RTSP_PORT"/$RTMP_STREAM_FEED"
#V3: 1080p=video1 360p=video2
#V2: 1080p=video6 360p=video7
RTSP_STREAM="video1_unicast"
VIDEO_SOURCE="rtsp://"$RTSP_LOGIN":"$RTSP_PASSWORD"@0.0.0.0:"$RTSP_PORT"/$RTSP_STREAM"
AUDIO_OPTIONS="-c:a libfdk_aac -afterburner 1 -channels 1 -b:a 256k -profile:a aac_he -ar 16000 -strict experimental"
AUDIO_OPTIONS="-c:a libfdk_aac -afterburner 1 -channels 1 -b:a 128k -profile:a aac_he -ar 16000 -strict experimental"
VIDEO_OPTIONS="-c:v copy -coder 1 -pix_fmt yuv420p -g 30 -bf 0"
if [[ "$2" == "no_audio" ]]; then
@ -40,15 +27,15 @@ fi
if [[ "$1" == "youtube" ]]; then
echo "RTMP Streaming to: YouTube"
STREAM_PROVIDER="$YOUTUBE_URL"
KEY="$YOUTUBE_KEY"
KEY="$RTMP_STREAM_YOUTUBE_KEY"
elif [[ "$1" == "twitch" ]]; then
echo "RTMP Streaming to: twitch"
STREAM_PROVIDER="$TWITCH_URL"
KEY="$TWITCH_KEY"
KEY="$RTMP_STREAM_TWITCH_KEY"
elif [[ "$1" == "facebook" ]]; then
echo "RTMP Streaming to: facebook"
STREAM_PROVIDER="$FACEBOOK_URL"
KEY="$FACEBOOK_KEY"
KEY="$RTMP_STREAM_FACEBOOK_KEY"
else
echo "Usage: rtmp-stream.sh <service> <no_audio>"
echo ""

View File

@ -33,7 +33,7 @@ hostname_set() {
}
first_run_check() {
if [[ -e /opt/wz_mini/tmp/.run_mmc_firstrun ]]; then
if [[ -e /opt/wz_mini/tmp/.wz_user_firstrun ]]; then
echo "run_mmc.sh already run once, exit."
exit 0
fi
@ -537,11 +537,22 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
fi
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
echo "wait for iCamera"
sleep 5
LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_PORT $DEVICE1 $DEVICE2 &
fi
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]] && [[ "$RTMP_STREAM_ENABLED" == "true" ]] && [[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]] || [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]; then
if [[ "$RTMP_STREAM_DISABLE_AUDIO" == "true" ]]; then
RMTP_AUDIO="no_audio"
fi
echo "wait for RTSP server"
sleep 5
/opt/wz_mini/bin/rtmp-stream.sh $RMTP_STREAM_SERVICE $RTMP_AUDIO
fi
hostname_set
touch /opt/wz_mini/tmp/.run_mmc_firstrun
touch /opt/wz_mini/tmp/.wz_user_firstrun
pkill -f dumpload #Kill dumpload so it won't waste cpu or ram gathering cores when something crashes
sysctl -w kernel.core_pattern='|/bin/false'
dmesg_log

View File

@ -55,7 +55,16 @@ RTSP_LOW_RES_MAX_BITRATE=""
RTSP_LOW_RES_TARGET_BITRATE=""
RTSP_LOW_RES_ENC_PARAMETER=""
ENABLE_MP4_WRITE="false"
#####RTMP STREAMING#####
#### REQUIRES RTSP ####
### AND RTSP AUDIO ###
RTMP_STREAM_ENABLED="false"
RTMP_STREAM_FEED="video1_unicast"
RMTP_STREAM_SERVICE="youtube"
RTMP_STREAM_DISABLE_AUDIO="false"
RTMP_STREAM_YOUTUBE_KEY=""
RTMP_STREAM_TWITCH_KEY=""
RTMP_STREAM_FACEBOOK_KEY=""
#####GENERAL#####
ENABLE_SWAP="true"
@ -63,7 +72,8 @@ ENABLE_USB_STORAGE="false"
ENABLE_EXT4="false"
ENABLE_CIFS="false"
DISABLE_FW_UPGRADE="false"
SILENT_PROMPTS="false"
AUDIO_PROMPT_VOLUME="50"
ENABLE_MP4_WRITE="false"
#####DEBUG#####
#drops you to a shell via serial, doesn't load app_init.sh