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

Fix complex Content-Type for image/jpeg #278

Closed
efaden opened this issue Mar 3, 2023 · 5 comments
Closed

Fix complex Content-Type for image/jpeg #278

efaden opened this issue Mar 3, 2023 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@efaden
Copy link

efaden commented Mar 3, 2023

I have an old hikvision cube (2432) I have been trying to get to work correctly with go2rtc, but I am having issues with the snapshots. Currently the camera is providing 2 streams (20481536 H264 audio and video, and 704480 H264 audio and video). I have two streams setup, one for main and one for the sub. As follows

  camera.garage:
    - rtsp://user:password@IP:554/Streaming/Channels/101?transportmode=unicast

  camera.garage_substream:
    - rtsp://user:password@IP:554/Streaming/Channels/102?transportmode=unicast

I tried adding the JPEG as an HTTP which can be found at - http://user:password@IP:554/Streaming/Channels/101/picture ... the 102 channel doesn't support JPEG.

The issue is that when I do that I get the following error.

WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:133 > error="wrong Content-Type: image/jpeg; charset=\"UTF-8\"" url=http://user:password@IP/Streaming/Channels/101/picture?snapShotImageType=JPEG

When I manually look at the headers in chrome, I noticed that the Content-Type inculdes the the charset.... "image/jpeg; charset="UTF-8""

Which I am guessing is causing the issue.

Is there a way around this? I was thinking about setting up a nginx proxy to strip the headers, but that just seemed crazy....

@efaden
Copy link
Author

efaden commented Mar 3, 2023

Of note in the mpeg producer line 36 is:

	if ct == "image/jpeg" {
		return c.startJPEG()
	}

So the charset is breaking that I assume. Considering charset= blah is a valid value within content type seems like this should be modified to allow for that.

@efaden
Copy link
Author

efaden commented Mar 3, 2023

I think making the if statement

if _, s, ok := strings.Cut(ct, "image/jpeg"); ok {

Would fix it.

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

AlexxIT commented Mar 3, 2023

Stupid content type. JPEG can't have any charset setting. It's a binary format. Will be fixed in next release.

@efaden
Copy link
Author

efaden commented Mar 6, 2023

Thanks.

@AlexxIT AlexxIT changed the title HikVision Cube Issues Fix complex Content-Type for image/jpeg Jul 11, 2023
@AlexxIT AlexxIT added this to the v1.6.1 milestone Jul 20, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Jul 20, 2023

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

2 participants