e1ioan / rokuphp

32 stars 9 forks source link

IP Camera Viewer and Go2RTC api #37

Open tmjpugh opened 1 year ago

tmjpugh commented 1 year ago

Go2RtC api provides jpeg and mp4 camera snapshot or stream (mp4 only) through their api at

http://localserver:1984/api/frame.mp4?src=cameraname >>mp4 snapshot http://localserver:1984/api/stream.mp4?src=cameraname >>mp4 stream http://localserver:1984/api/frame.jpg?src=cameraname >> jpeg snapshot

When I configure for IP camera viewer it does not connect. When I check they show you as developer and I see this github repo and hope these are related and you may kindly assist with getting this connected. These look to be supported format and link. I verify they function in safari and should be accessible by the Roku device on my network

IP Camera Viewer Basic V 5.3 build 0

IP: server ip TCP Port: 1984 Stream URL: /api/frame.mp4?src=mycamera

I try all other links and same result

CoordSpace commented 6 months ago

I've been struggling with this on and off for a while myself.

The first thing to note, repeated many times by e1ioan/ioan in the roku forum thread, is that the Roku app APIs only support displaying streams in MJPEG format. H264, H265, and whatever transport format that encapsulates them like rtmp/rtsp/mp4/hls etc will not work. (Though that begs the question of just what video format is within the HLS stream this project creates)

That said, Go2RTC can transcode whatever stream format an "unsupported" camera has available into MJPEG but there are some issues if you even get that far.

Due to the concept of Go2RTC being built around a provider that responds to consumers, it's not constantly transcoding the IP Camera stream; only once the roku app starts and requests the Go2RTC MJPEG stream does Go2RTC connect to the IP Cam and start transcoding. This startup process takes a few seconds and leads to really weird behavior within IP Camera Viewer like 1Hz flashing of video frames and a black screen as it closes and opens the connection between the server and the consumer.

I've had more luck using the (sadly depreciated) ffserver. It's pretty much just a thin proxy wrapper around ffmpeg. It transcodes to MJPEG and is displayed by IP Camera Viewer but it has no reconnection logic. Every time my net hiccups, TPLink feels that some automatic cycling of wifi is needed, causing ffserver to lose connection till I do a manual restart. It's quite frustrating.

As a last note, I've been exploring MediaMTX as a replacement for this project and Go2RTC. I have a RTSP+MJPEG stream being generated that should be kosher but I'm hitting the ?-append issue defined in https://github.com/e1ioan/rokuphp/issues/39