FiveLeavesLeft / WyzeCameraLiveStream

Hack to allow live streaming from wyze cameras to vlc or mpv on your desktop.
MIT License
100 stars 7 forks source link

RTSP stream #15

Open dsarel10 opened 3 years ago

dsarel10 commented 3 years ago

Is it possible to get a straight RTSP stream directly from the camera?

I'm able to view the stream with VLC, but cannot consume it on my NVR.

FiveLeavesLeft commented 3 years ago

No, I looked at that and it seemed pretty complicated. Maybe if I had a very simple generic RTSP sever written in C but I looked around and couldn't find one.

dsarel10 commented 3 years ago

Fair enough :)

nijhawank commented 3 years ago

Don’t know if this helps but have you looked at https://github.com/aler9/rtsp-simple-server

gtxaspec commented 3 years ago

take a look at what's used natively on other xiaomi based cameras (DaFang, Wyze, etc) https://github.com/EliasKotlyar/Xiaomi-Dafang-Software/tree/master/v4l2rtspserver-master

FiveLeavesLeft commented 3 years ago

@gtxaspec , does that code compile and run on the wyze cam out of the box? Or is somehow incompatable with the wyze firmware?

gtxaspec commented 3 years ago

@FiveLeavesLeft from what I looked at, it does compile and run, but no video or audio on stock on the wyze cams (v2), due to the fact that:

  1. on stock, /dev/video can not be used by multiple programs (the iCamera app takes over the interface)

  2. on the rtsp firmware (v2) you can kill the included rtsp server and use this one if I remember correctly. video and audio located in /tmp using unix sockets.

on the v3 cams, haven't tried yet, but will assume no. 1 is the issue again. edit: v3 uses /dev/dsp, /dev/framechan[0,1,or 2]

juched78 commented 3 years ago

Wyze also shares their RTSP server from V2 cameras as open source code bundle.

Which file or device does this hack use to get access to the camera feed? I cannot find the source which opens the camera in this repo.

FiveLeavesLeft commented 3 years ago

No device or file, there's a function that returns each h264 frame, IMP_Encoder_GetStream, which iCamera loads from libimp.so. The hack wraps this function. The code that wraps it is in src/common.c IMP_Encoder_GetStream().

juched78 commented 3 years ago

Ahh, I see that now. What I didn't realize is that iCamera uses libimp.so.

So, the RTSP server which wyze shares via GPL (https://s3-us-west-2.amazonaws.com/download.wyzecam.com/firmware/gpl/live-ini.zip) seems to read from a /tmp/ file:

char const streamName = "live"; char const inputFileName = "/tmp/"; char const* descriptionString = "Session streamed by \"wyze\"";

So, if libimp.so hack used could stream to that file, then the wyze package RTSP could be used as an option.