AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
4.21k stars 344 forks source link

Fix mjpeg source for Foscam G2 camera #1258

Open gambalaya opened 1 month ago

gambalaya commented 1 month ago

I have a Foscam G2 camera configured to supply an mjpeg secondary stream from url http://x.x.x.x/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=xxx&pwd=xxx , which works directly in Chrome browser and VLC. When attempting to use as a go2rtc source there is continuous logging of malformed MIME header: missing colon messages (and no output). The camera is indeed producing a malformed MIME header as seen with curl -i response:

HTTP/1.1 200 OK
Content-type:multipart/x-mixed-replace;boundary=ThisString

--ThisString
--ThisString
Content-type:image/jpeg
Content-Length:32514

Since other apps like Chrome and VLC can handle the camera stream, any chance go2rtc can ignore malformed lines? I can see the error is coming from "mustHaveFieldNameColon" function in golang source - https://github.com/golang/go/blob/master/src/net/textproto/reader.go per RFC 7230. Thanks.

AlexxIT commented 1 month ago

I don't know if it's difficult to give me access to the stream. It would make it a lot easier to fix.

gambalaya commented 1 month ago

Thanks, I have made the stream available, will DM the url to you via discord.

gambalaya commented 1 month ago

I rebuilt from the latest master and can confirm the camera fix works from my end - thanks for such an amazing quick response! Closing the issue as fixed in v1.9.5.

AlexxIT commented 1 month ago

You don't needs to rebuild anything manually https://github.com/AlexxIT/go2rtc?tab=readme-ov-file#go2rtc-dev-version