question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feed Wyze stream into RTMP server

See original GitHub issue

I was trying to find a way to serv frames as an RTMP stream in pure Python but didn’t have any luck. So I decided to fire up my own RTMP server and then leverage ffmpeg to stream to this server.

So using this guide I spun up an RTMP server using Nginx and the RTMP module: https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50/

Then I wrote a program to pipe the raw Wyze frames into ffmpeg which then streams to my RTMP server. I’m not a Python developer so I’m open to suggestions on making it more robust but it’s working and seems to survive connection loss or a power cycle of the camera. I made a systemd service to run it as a service on my Debian server and it’s working well. I was then able to feed it into Frigate.

from wyzecam import get_camera_list, get_user_info, login
from wyzecam.iotc import WyzeIOTC
import getopt, sys, signal, subprocess
from time import sleep

def main():

    def handler(signum, frame):
        sys.exit()

    signal.signal(signal.SIGINT, handler)

    try:
        opts, args = getopt.getopt(sys.argv[1:], "", ["user=", "password=", "cameraname=", "url="])
    except getopt.GetoptError as err:
        print("--user=<wyzeuser> --password=<wyzepassword> --cameraname=<cameraname> --url=<rtmpServerUrl>")
        sys.exit(2)

    user = None
    password = None
    cameraname = None
    rtmpurl = None

    for opt, arg in opts:
        if opt == "--user":
            user = arg
        if opt == "--password":
            password = arg
        if opt == "--cameraname":
            cameraname = arg
        if opt == "--url":
            rtmpurl = arg
    if user == None or password == None or cameraname == None or rtmpurl == None:
        print("--user=<wyzeuser> --password=<wyzepassword> --cameraname=<cameraname> --url=<rtmpServerUrl>")
        sys.exit(2)
        
    auth_info = login(user, password)
    account = get_user_info(auth_info)
    cameras = get_camera_list(auth_info)

    cam = [camera for camera in cameras if camera.nickname == cameraname][0]

    ffmpeg = subprocess.Popen(['ffmpeg',
        '-f', 'h264',
        '-i', '-',
        '-vcodec', 'copy', 
        '-f','flv', rtmpurl], stdin=subprocess.PIPE)

    while True:
        with WyzeIOTC() as wyze_iotc:
            try:
                with wyze_iotc.connect_and_auth(account, cam) as sess:
                    session_info = sess.session_check()
                    for (frame, frame_info) in sess.recv_video_data():
                        ffmpeg.stdin.write(frame)
            except:
                print("Reconnect")
        sleep(1)

if __name__ == "__main__":
    main()

Example command line:

python rtmp.py --user joeblow@example.com --password blablabla --cameraname "Front Porch" --url rtmp://127.0.0.1/live/frountporch

Then playback using a URL like this: rtmp://myserver.example.com/live/frountporch

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:37 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
mrlt8commented, Jun 27, 2021

@SomebodySysop I updated my docker-compose.yml to use rtsp-simple-server, so you could run that to get an RTSP/RTMP/HLS stream for all your cameras.

1reaction
mrlt8commented, Jun 26, 2021

Speaking of docker, I actually made a quick docker-compose for @noelhibbard’s script. I uploaded it here if anyone wants it: https://github.com/mrlt8/docker-wyze-bridge

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wyze Cam RTSP
Use this for streaming through any RTSP compatible player on the same local network as the Wyze Cam. Note: Cam Plus is included...
Read more >
Setting up RTSP on Wyze to Use in Wirecast Live Stream
During @Telestream Wirecast Pros weekly show, I configure a @ Wyze camera for RTSP, then connect it to Wirecast for broadcast.
Read more >
tinyCam PRO app can now stream Wyze camera to any RTMP ...
tinyCam PRO app can now stream Wyze camera to any RTMP server (YouTube Live, Twitch.tv, Facebook Live). r/wyzecam - tinyCam PRO app can...
Read more >
tinyCam Pro Android App web server: Stream RTSP and Wyze ...
Note: If you are running tinyCam Server on the same tablet as your ActionTiles Panel(s), and do not need the feed on any...
Read more >
Has anyone been able to get the RTSP feed working in ...
I can view the rtsp stream in VLC at rtsp://login:password@ipaddress/live. When I setup the camera, it connects but then I never can see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found