Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error="wrong boundary: " for MJPEG HTTP camera #545

Closed
briodan opened this issue Jul 25, 2023 · 21 comments
Closed

error="wrong boundary: " for MJPEG HTTP camera #545

briodan opened this issue Jul 25, 2023 · 21 comments
Labels
bug Something isn't working

Comments

@briodan
Copy link

briodan commented Jul 25, 2023

Hi i have a bunch of ESP32CAM providing an MJPEG http stream which work fairly well
this is the firmware they are running
https://github.com/easytarget/esp32-cam-webserver

The camera puts out a stream accessible at http://ip-address:81

I'm able to open that stream on a browser, in VLC, BlueIris etc.

Setup the camera stream in frigate (with gortc 1.2)
here is the config

go2rtc:
  streams:
    camera_egg:
      - http://ip-address:81/

getting the following recurring message in the logs and the stream screen is black and spinning

18:36:38.278 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:171 > error="wrong boundary: " url=http://ip-address:81/

I get the following once I stop the stream
18:36:43.910 WRN [streams] json locked

tried spinning a docker container with go2rtc latest and i'm getting the same behaviour

VLC reports the following codec info
image

@Sammy1Am
Copy link

I'm also running into this with a similar situation. If it's helpful, the URL is

And the stream itself looks like a large collection of these:

--data-boundary--
Content-Type: video/x-h264
Content-Length: 33602
X-UtcTime:1690526144
X-Timestamp: 295528.317000
X-Audio: 1
X-FrameType: 0
X-FrameRate: 15.0
X-Video-Detection: 0

<<data>>

--data-boundary--
Content-Length: 480
X-Timestamp: 295528.448000
Content-Type: audio/g711u

<<data>>

And the connection response from curl looks like:

*   Trying 192.168.0.127:19443...
* TCP_NODELAY set
* Connected to 192.168.0.127 (192.168.0.127) port 19443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=CN; CN=TP-Link
*  start date: Jul  6 01:31:43 2021 GMT
*  expire date: Jul  4 01:31:43 2031 GMT
*  issuer: C=CN; CN=TP-Link
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
* Server auth using Basic with user 'myemail@example.com'
> GET /https/stream/mixed HTTP/1.1
> Host: 192.168.21.127:19443
> Authorization: Basic hashyhashyhashy=
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Type: multipart/x-mixed-replace;boundary=data-boundary--
< X-Encrypt-Type: PLAIN
< Pragma: no-cache
< Cache-Control: no-cache
< Transfer-Encoding: chunked
* HTTP/1.0 connection set to keep alive!
< Connection: keep-alive

@AlexxIT AlexxIT added the bug Something isn't working label Jul 28, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Jul 28, 2023

@Sammy1Am never saw video/audio as data-boundary. What camera model you using?
It's better to have some raw TCP response from both of you. Few seconds of data. Starting from HTTP headers.
You can send it in private message to contacts from GitHub profile.

@Sammy1Am
Copy link

It's a TP-Link Kasa Spot KC401. I've been having a heck of a time figuring out how to get a stream out of it (see #551 too), but I've finally managed to get video-only if I pipe it through curl and then ffmpeg via the exec module. Ffmpeg just isn't detecting the audio stream at all, but I suspect it's because it's also not expecting to see video/audio as data-boundary, haha.

What command should I run for the raw TCP response / what format would you like it in?

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 28, 2023

10 seconds with header:

curl -m 10 -i https://mjpeg.sanford.io/count.mjpeg > out.txt

@briodan
Copy link
Author

briodan commented Jul 28, 2023

10 seconds log sent via telegram, hopefully to the correct account.

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 28, 2023

Yes. Correct. But can check it in two weeks

@Sammy1Am
Copy link

Tried to add you on Discord, but I'll just post it here too. The audio is likely to just be silence, but if you think you can find a way to split the two of them I can help test something with sound.
Sammy1Am-streamout.zip

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 31, 2023

@briodan looks like it's broken HTTP format. I'm wonder if ffplay can handle this link.

AlexxIT added a commit that referenced this issue Jul 31, 2023
AlexxIT added a commit that referenced this issue Jul 31, 2023
AlexxIT added a commit that referenced this issue Aug 2, 2023
@briodan
Copy link
Author

briodan commented Aug 7, 2023

sorry was on vacation myself for the last week or so, not sure it understand your comment but sounds like i should try the latest code from the commit trail when its available.

@AlexxIT
Copy link
Owner

AlexxIT commented Aug 7, 2023

You both can try latest master version. As docker or Hass add-on.

@briodan
Copy link
Author

briodan commented Aug 7, 2023

tried the docker container but getting this error in the logs followed by a crash and restart

03:10:02.749 INF go2rtc version 1.6.2 linux/amd64
03:10:02.749 INF [api] listen addr=0.0.0.0:1984
03:10:02.749 INF [rtsp] listen addr=0.0.0.0:8554
03:10:02.750 INF [webrtc] listen addr=0.0.0.0:8555/tcp
03:10:02.750 INF [srtp] listen addr=0.0.0.0:8443
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0xa5ab5d]
goroutine 13 [running]:
github.com/AlexxIT/go2rtc/pkg/multipart.(*Client).Stop(0xc000214c60)
	github.com/AlexxIT/go2rtc/pkg/multipart/producer.go:33 +0x5d
github.com/AlexxIT/go2rtc/internal/streams.(*Producer).stop(0xc000158360)
	github.com/AlexxIT/go2rtc/internal/streams/producer.go:260 +0x12d
github.com/AlexxIT/go2rtc/internal/streams.(*Stream).stopProducers(0xc000111ac0)
	github.com/AlexxIT/go2rtc/internal/streams/stream.go:187 +0xcd
github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc000111ac0, {0xced300, 0xc0001c7360})
	github.com/AlexxIT/go2rtc/internal/streams/stream.go:121 +0x22a
github.com/AlexxIT/go2rtc/internal/mp4.handlerWSMSE(0xc00020a550, 0xc0000d8040)
	github.com/AlexxIT/go2rtc/internal/mp4/ws.go:36 +0x2f0
github.com/AlexxIT/go2rtc/internal/api/ws.apiWS.func2()
	github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:128 +0x3f
created by github.com/AlexxIT/go2rtc/internal/api/ws.apiWS
	github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:127 +0x398
03:10:35.598 INF go2rtc version 1.6.2 linux/amd64
03:10:35.598 INF [api] listen addr=0.0.0.0:1984
03:10:35.598 INF [rtsp] listen addr=0.0.0.0:8554
03:10:35.598 INF [webrtc] listen addr=0.0.0.0:8555/tcp
03:10:35.599 INF [srtp] listen addr=0.0.0.0:8443

@AlexxIT
Copy link
Owner

AlexxIT commented Aug 23, 2023

You both can check latest master version
https://github.com/AlexxIT/go2rtc#go2rtc-dev-version

@briodan
Copy link
Author

briodan commented Aug 23, 2023

pulled the latest master docker image.

good news its not crashing anymore

bad news it errors out

clicking the streams link http://xx.xx.xx.xx:1984/stream.html?src=camera_egg
gives the following error message:
github.com/AlexxIT/go2rtc/internal/mjpeg/init.go:177 > error="can't get medias for stream"

@AlexxIT
Copy link
Owner

AlexxIT commented Aug 23, 2023

It will be easier if you give me access to stream:
https://github.com/AlexxIT/go2rtc/wiki/Tunnel-RTSP-camera-to-Intenet

@AlexxIT AlexxIT added this to the v1.7.0 milestone Sep 2, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Sep 2, 2023

Changes in latest release. I still doesn't know if they helps for you
https://github.com/AlexxIT/go2rtc/releases/tag/v1.7.0

@AlexxIT AlexxIT removed this from the v1.7.0 milestone Sep 2, 2023
@briodan
Copy link
Author

briodan commented Sep 5, 2023

sorry didn't get a chance to setup the stream via ngrok, it was on my to-do list for this week-end. but then i saw your post.

I pulled up the latest master docker image and the video is loading with no error messages.

Meant to post earlier but got distracted with trying to make it pull up the stream in BlueIris. Probably a BlueIris issue as vlc has no issues with the rtsp stream.

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 5, 2023

So there is no problems with ESP32CAM?

@briodan
Copy link
Author

briodan commented Sep 6, 2023

none yet, been running OK for the last few days.

the issue with blueiris is on their side, https://www.reddit.com/r/BlueIris/comments/157oic6/go2rtc_as_a_source_for_blue_iris/

let me know if you need anything more on this i can get you access to the camera if still needed.

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 6, 2023

This problem was fixed half year ago from go2rtc side

@briodan
Copy link
Author

briodan commented Sep 6, 2023

figures, but at least now i can chose weather to setup these cameras in go2rtc or blueiris.

most likely they will all go into go2rtc and homeassistant/frigate because it don't really need recordings for them.

Thanks for getting this fixed.

@AlexxIT AlexxIT closed this as completed Sep 6, 2023
felipecrs pushed a commit to felipecrs/go2rtc that referenced this issue Oct 20, 2023
felipecrs pushed a commit to felipecrs/go2rtc that referenced this issue Oct 20, 2023
felipecrs pushed a commit to felipecrs/go2rtc that referenced this issue Oct 20, 2023
@lorumic
Copy link

lorumic commented Sep 6, 2024

Hi there! Sorry to bring bad news, but I encountered the same issue today with Linux/amd64 binary, version 1.9.4. Looks like the changes in this commit were going to the right direction, but I see they were immediately reverted, so I'm confused.

Here's the log and version output:

lorumic@lorumic:~/go2rtc$ ./go2rtc 
20:36:28.564 INF go2rtc platform=linux/amd64 revision=a4885c2 version=1.9.4
20:36:28.565 INF config path=/home/lorumic/go2rtc/go2rtc.yaml
20:36:28.565 INF [rtsp] listen addr=:8554
20:36:28.565 INF [api] listen addr=:1984
20:36:28.566 INF [webrtc] listen addr=:8555
20:36:35.155 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:170 > error="multipart: wrong boundary: Content-Type: image/jpeg\r\n" url=http://192.168.1.106:81/stream
20:36:45.883 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:170 > error="multipart: wrong boundary: Content-Type: image/jpeg\r\n" url=http://192.168.1.106:81/stream
^Cexit with signal: interrupt
lorumic@lorumic:~/go2rtc$ ./go2rtc --version
go2rtc version 1.9.4 (a4885c2) linux/amd64

And this is the relevant part of the config file go2rtc.yaml (WebRTC config is omitted as I think it's not relevant in this case):

streams:
  my_esp32_cam:
    - http://192.168.1.106:81/stream

Needless to say, as OP also stated, the stream loads with no problems when opening http://192.168.1.106:81/stream in the browser, as well as when running ffplay -f mjpeg -i http://192.168.1.106:81/stream.

Can we make sure the correct boundary is provided for these pesky esp32 cameras please? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants