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

jpeg: read: camera: invalid JPEG format: uninitialized Huffman table #20

Open
Fmstrat opened this issue Oct 5, 2019 · 13 comments
Open

Comments

@Fmstrat
Copy link

Fmstrat commented Oct 5, 2019

Using a Logitech webcam I'm getting:

2019/10/05 14:23:49 jpeg: read: camera: invalid JPEG format: uninitialized Huffman table

I'm guessing this is a similar problem to this fix:

blackjack/webcam#7 (comment)

@gen2brain
Copy link
Owner

It looks like it is valid for MJPEG frames to omit the Huffman table and expect some default to be used. Browsers do that, they will load such an image even if not valid, probably by adding some default table.

I am guessing you are on Linux and don't use provided binaries but you compiled with native image/jpeg support and with native V4L, right? It will probably work with OpenCV build, with libjpegturbo it will probably be a different error.

Problem is, it is not correct to just add tables as in your link, will need to detect first if that is the issue, my cam, for example, returns valid JPEG with Huffman tables from MJPEG. One way is to match if the error string contains Huffman I guess, but that is ugly. Something like this would be great golang/go#10447 but it is not implemented.

@Fmstrat
Copy link
Author

Fmstrat commented Oct 5, 2019

Ubuntu 18.04, using the latest Docker HUB release. Camera works as expected in cheese and with motion. Hope that helps!

@gen2brain
Copy link
Owner

Yes, docker image is built without CGO, and uses native image/jpeg and native V4L.

Can you try with binaries from releases, and paste error messages, this one https://github.com/gen2brain/cam2ip/releases/download/1.5/cam2ip-1.5-64bit.tar.gz uses libjpegturbo and V4L, and this one https://github.com/gen2brain/cam2ip/releases/download/1.5/cam2ip-1.5-64bit-cv2.tar.gz libjpegturbo and OpenCV.

@carlos-sarmiento
Copy link

Is there any reason not to include the solution to this issue in the docker image release?

@gen2brain
Copy link
Owner

@carlos-sarmiento the solution should not be included unconditionally, it should probably check error string for Huffman table, a little ugly, but if nothing else possible I agree. I don't have the webcam that behaves like that or time to work on this now. PRs are welcome.

@davralin
Copy link

I have a RPI3 with a Logitech C310, and docker-image gave me uninitialized Huffman table.

I used cam2ip-1.6-RPi3.tar.gz and console is spammed with the following during a stream:

Corrupt JPEG data: 1 extraneous bytes before marker 0xd6
Corrupt JPEG data: 2 extraneous bytes before marker 0xd6
Corrupt JPEG data: 2 extraneous bytes before marker 0xd2
Corrupt JPEG data: 1 extraneous bytes before marker 0xd4
Corrupt JPEG data: 1 extraneous bytes before marker 0xd4
Corrupt JPEG data: 1 extraneous bytes before marker 0xd3
Corrupt JPEG data: 3 extraneous bytes before marker 0xd3
Corrupt JPEG data: 1 extraneous bytes before marker 0xd2
Corrupt JPEG data: 3 extraneous bytes before marker 0xd7
Corrupt JPEG data: 1 extraneous bytes before marker 0xd4
Corrupt JPEG data: 1 extraneous bytes before marker 0xd7
Corrupt JPEG data: 2 extraneous bytes before marker 0xd0
Corrupt JPEG data: 1 extraneous bytes before marker 0xd3
Corrupt JPEG data: 1 extraneous bytes before marker 0xd0
Corrupt JPEG data: 1 extraneous bytes before marker 0xd0
Corrupt JPEG data: 1 extraneous bytes before marker 0xd0
Corrupt JPEG data: 1 extraneous bytes before marker 0xd1
Corrupt JPEG data: 2 extraneous bytes before marker 0xd6
Corrupt JPEG data: 1 extraneous bytes before marker 0xd4

I can't really help any more than that, but errormessages aside, the camera does stream.

@davralin
Copy link

Same issue on amd64 with a Logitech C510.

Doesn't work with Docker, works just fine with the relevant release - I created davralin/cam2ip witch contains the amd64-build for now, as I have to use this in a container (deployed on k8s).

@gen2brain
Copy link
Owner

@davralin so you use OpenCV or native build?

@davralin
Copy link

@davralin so you use OpenCV or native build?

Native build I'd guess?

Source is here: https://github.com/davralin/cam2ip-docker/blob/main/run.sh

@T0MuX
Copy link

T0MuX commented Mar 6, 2021

Hi, same issue with https://github.com/gen2brain/cam2ip/releases/download/1.6/cam2ip-1.6-RPi.tar.gz

When I access to http://localhost:56000/html, I got this :
2021/03/06 22:48:20 socket: read: camera: invalid JPEG format: uninitialized Huffman table

When I access to http://localhost:56000/jpeg, I got this :
2021/03/06 22:50:23 jpeg: read: camera: invalid JPEG format: uninitialized Huffman table

And when I access to http://localhost:56000/mjpeg, I got this big one :

2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:28 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:29 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:29 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:29 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:29 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:29 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
2021/03/06 22:52:29 mjpeg: read: camera: invalid JPEG format: uninitialized Huffman table
...

@T0MuX
Copy link

T0MuX commented Mar 6, 2021

Okay, the "edit button" of Github doesn't work for me so I post again...

I forgot to specify : I'm using ArchlinuxARM on a Raspberry 1B. Also, I miswrote : I was using cam2ip-1.6-RPi-nocgo.tar.gz
But since, I "solved" this switching to cam2ip-1.6-RPi.tar.gz :)

@5vr
Copy link

5vr commented Feb 16, 2024

Something like this would be great golang/go#10447 but it is not implemented.

golang/go#10447 (comment)

How to use it now?

@gen2brain
Copy link
Owner

To use what, something that is not implemented? I guess you would have to implement it first. Look for alternative approach above and send PR if you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants