Motion-Project / motion

Motion, a software motion detector. Home page: https://motion-project.github.io/
GNU General Public License v2.0
3.62k stars 545 forks source link

USB Camera problem #276

Closed championc closed 7 years ago

championc commented 7 years ago

Hi all,

I hope that someone can assist. I am using a CCTV application called MotionEye which uses Motion , which is installed on a Linux Mint installation using a Local USB V4L2 camera. While this USB camera works perfectly within Cheese, it won't work with Motion.

With version 3.2.12, I got the following errors repeatedly over and over "[1] [WRN] [VID] v4l2_select_input: Device doesn't support VIDIOC_G_STD".

I downloaded and installed Motion 4.0.1 (I used Xenial_Motion version - is this correct for Mint 18 ?). It seemed to install OK, but I now get the errors [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue

Mr-Dave commented 7 years ago

Can you post the full log at the NTC(6) log level to gist and maybe we can get a better sense of what is happening.

championc commented 7 years ago

Is there a command line switch to set this ? If so, what is is or otherwise, how do I do this ?

Mr-Dave commented 7 years ago

The log level can be specified using this or within the configuration file here. The NTC level is usually the default. Unfortunately, you are caught between two applications on how to do this within Motioneye. We don't use Motioneye and only use the Motion application standalone so our responses will be framed in the context of Motion rather than MotionEye.

championc commented 7 years ago

The log level is already set to 6 (in motion.conf)

I have the file /var/log/motion.log with this [code] [0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motioneye/motion.conf [0:motion] [WRN] [ALL] thread config option deprecated use camera [0:motion] [NTC] [ALL] config_camera: Processing camera config file thread-1.conf [0:motion] [NTC] [ALL] motion_startup: Motion 4.0.1 Started [0:motion] [NTC] [ALL] motion_startup: Logging to syslog [0:motion] [NTC] [ALL] motion_startup: Using default log type (ALL) [0:motion] [NTC] [ALL] motion_startup: Using log type (ALL) log level (WRN) [1:ml1] [WRN] [VID] v4l2_select_input: Device doesn't support VIDIOC_G_STD [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] motion_init: Error capturing first image [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue etc ....... [/code]

and in syslog [code] Dec 21 15:51:47 WebCam-Server rsyslogd: [origin software="rsyslogd" swVersion="8.16.0" x-pid="642" x-info="http://www.rsyslog.com"] rsyslogd was HUPed Dec 21 15:51:47 WebCam-Server motion: [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined Dec 21 15:51:47 WebCam-Server motion: [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue Dec 21 15:51:47 WebCam-Server motion: [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined Dec 21 15:51:47 WebCam-Server motion: [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue Dec 21 15:51:48 WebCam-Server motion: [1:ml1] [ERR] [ALL] my_error_exit: Quantization table 0x00 was not defined Dec 21 15:51:48 WebCam-Server motion: [1:ml1] [CRT] [VID] mjpegtoyuv420p: Corrupt image ... continue [/code]

tosiara commented 7 years ago

Your motion logs into syslog. Can you please extract and provide full log from startup to see camera details?

Mr-Dave commented 7 years ago

It would probably be best to specify a different file for logging instead of the sys log. Do this via the log file option. The important parts are all the things before the error messages start being reported.

championc commented 7 years ago

Sorry. I set the level and other settings in the wrong config file. Sorted now - see below

[0:motion] [NTC] [ALL] [Dec 22 15:43:35] motion_startup: Using log type (ALL) log level (ALL)
[0:motion] [NTC] [ENC] [Dec 22 15:43:35] ffmpeg_init: ffmpeg libavcodec version 56.60.100 libavformat version 56.40.101
[0:motion] [NTC] [ALL] [Dec 22 15:43:35] main: Camera 1 is from thread-1.conf
[0:motion] [NTC] [ALL] [Dec 22 15:43:35] main: Camera 1 is device: /dev/v4l/by-id/usb-093a_2620-video-index0 input -1
[0:motion] [NTC] [ALL] [Dec 22 15:43:35] main: Stream port 8081
[0:motion] [NTC] [ALL] [Dec 22 15:43:35] main: Waiting for threads to finish, pid: 1101
[0:web_control] [NTC] [STR] [Dec 22 15:43:35] http_bindsock: listening on 127.0.0.1 port 7999
[0:web_control] [NTC] [STR] [Dec 22 15:43:35] httpd_run: Started motion-httpd server on port 7999 (auth Disabled)
[1:ml1] [NTC] [ALL] [Dec 22 15:43:35] motion_init: Camera 1 started: motion detection Enabled
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] vid_v4lx_start: Using videodevice /dev/v4l/by-id/usb-093a_2620-video-index0 and input -1
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_get_capability: 
------------------------
cap.driver: "gspca_pac7302"
cap.card: "USB Camera (093a:2620)"
cap.bus_info: "usb-0000:00:13.0-3"
cap.capabilities=0x85200001
------------------------
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_get_capability: - VIDEO_CAPTURE
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_get_capability: - READWRITE
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_get_capability: - STREAMING
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_select_input: name = "gspca_pac7302", type 0x00000002, status 00000000
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_select_input: - CAMERA
[1:ml1] [WRN] [VID] [Dec 22 15:43:35] v4l2_select_input: Device doesn't support VIDIOC_G_STD
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_set_pix_format: Config palette index 17 (YU12) doesn't work.
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_set_pix_format: Supported palettes:
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_set_pix_format: (0) PJPG (GSPCA PJPG)
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_set_pix_format: 0 - GSPCA PJPG (compressed : 1) (0x47504a50)
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_set_pix_format Selected palette PJPG
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_do_set_pix_format: Testing palette PJPG (640x480)
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_do_set_pix_format: Using palette PJPG (640x480) bytesperlines 640 sizeimage 115790 colorspace 00000007
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x00980900, "Brightness", range 0,32 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Brightness", default 16, current 16
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x00980901, "Contrast", range 0,255 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Contrast", default 127, current 127
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x00980902, "Saturation", range 0,255 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Saturation", default 127, current 127
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x0098090e, "Red Balance", range 0,200 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Red Balance", default 100, current 100
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x0098090f, "Blue Balance", range 0,200 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Blue Balance", default 100, current 100
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x00980911, "Exposure", range 0,1023 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Exposure", default 66, current 66
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x00980912, "Gain, Automatic", range 0,1 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Gain, Automatic", default 1, current 1
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls: found control 0x00980913, "Gain", range 0,62 
[1:ml1] [NTC] [VID] [Dec 22 15:43:35] v4l2_scan_controls:   "Gain", default 15, current 15
[1:ml1] [DBG] [VID] [Dec 22 15:43:35] v4l2_set_mmap: mmap information: frames=4
[1:ml1] [DBG] [VID] [Dec 22 15:43:35] v4l2_set_mmap: 0 length=118784 Address (f76cb000)
[1:ml1] [DBG] [VID] [Dec 22 15:43:35] v4l2_set_mmap: 1 length=118784 Address (f0e67000)
[1:ml1] [DBG] [VID] [Dec 22 15:43:35] v4l2_set_mmap: 2 length=118784 Address (f0e4a000)
[1:ml1] [DBG] [VID] [Dec 22 15:43:35] v4l2_set_mmap: 3 length=118784 Address (f0e2d000)
[1:ml1] [NTC] [VID] [Dec 22 15:43:36] vid_v4lx_start: Using V4L2
[1:ml1] [NTC] [ALL] [Dec 22 15:43:36] image_ring_resize: Resizing pre_capture buffer to 1 items
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] v4l2_next: 1) vid_source->pframe -1
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] v4l2_next: 2) vid_source->pframe -1
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] v4l2_next: 3) vid_source->pframe 0 vid_source->buf.index 0
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] v4l2_next: vid_source->buf.bytesused 8472
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] v4l2_next: the_buffer index 0 Address (f76cb000)
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1, Start of Image
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1, Start Of Frame 0xc0: width=480, height=640, components=3
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1,     Component 1: 2hx1v q=0
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1,     Component 2: 1hx1v q=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1,     Component 3: 1hx1v q=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1, Start Of Scan: 3 components
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1,     Component 1: dc=0 ac=0
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1,     Component 2: dc=1 ac=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1,     Component 3: dc=1 ac=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:36] my_emit_message: msg_level: 1,   Ss=0, Se=63, Ah=0, Al=0
[1:ml1] [ERR] [ALL] [Dec 22 15:43:36] my_error_exit: Quantization table 0x00 was not defined
[1:ml1] [CRT] [VID] [Dec 22 15:43:36] mjpegtoyuv420p: Corrupt image ... continue
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] v4l2_next: 1) vid_source->pframe 0
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] v4l2_next: 2) vid_source->pframe 0
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] v4l2_next: 3) vid_source->pframe 1 vid_source->buf.index 1
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] v4l2_next: vid_source->buf.bytesused 8472
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] v4l2_next: the_buffer index 1 Address (f0e67000)
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1, Start of Image
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1, Start Of Frame 0xc0: width=480, height=640, components=3
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1,     Component 1: 2hx1v q=0
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1,     Component 2: 1hx1v q=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1,     Component 3: 1hx1v q=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1, Start Of Scan: 3 components
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1,     Component 1: dc=0 ac=0
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1,     Component 2: dc=1 ac=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1,     Component 3: dc=1 ac=1
[1:ml1] [DBG] [VID] [Dec 22 15:43:38] my_emit_message: msg_level: 1,   Ss=0, Se=63, Ah=0, Al=0
[1:ml1] [ERR] [ALL] [Dec 22 15:43:38] my_error_exit: Quantization table 0x00 was not defined
[1:ml1] [CRT] [VID] [Dec 22 15:43:38] mjpegtoyuv420p: Corrupt image ... continue
[1:ml1] [DBG] [VID] [Dec 22 15:43:40] v4l2_next: 1) vid_source->pframe 1

Last about 18 lines seem to be repeated over and over after this

tosiara commented 7 years ago

Can you try to plug this camera into usb 2.0 port?

championc commented 7 years ago

Unfortunately it IS connected to a 2.0 port already

Mr-Dave commented 7 years ago

Thanks for the log, it helps identify the issue. The log reports a Pixart variant of JPG (PJPG) as the only format for the camera. Motion uses a external library to decode the pictures into a format that we can process. The error being reported is from that external library not being able to decode the PJPG image. Web searches of that format did not provide many results at all so I am guessing it is a really old camera. Generally, I think the best option is to try a different camera. The only other option would be to build the Motion code from source and try specifying different JPG libraries hoping one of them can decode the PJPG.

championc commented 7 years ago

Thanks for the replies. The webcam isn't too old I would have thought. I had another which is very old and which I could never get to work in Windows since it never found a compatible driver - but both webcams worked in Cheese.

Unfortunately, I'm already pushing the boundaries of my knowledge and re-compiling something by selecting different libraries is well beyond my skill level.

Thanks anyway.

tosiara commented 7 years ago

Can you capture a sample frame and share it? Clone v4l benchmark repo:

git clone https://github.com/tosiara/v4l-capture-bench

Run:

cd v4l-capture-bench
make
./v4l-capture -c 1 -o 1> test.jpg

Upload somewhere test.jpg file for analysis

tosiara commented 7 years ago

I also recommend to zip the file before attaching here or uploading. Just to prevent any changes or corruptions

Mr-Dave commented 7 years ago

I am closing this issue that is particular to this camera format and have opened issue #279 that addresses the larger issue of cameras with unusual pixel formats. That issue will be tracking whether Motion can use the same libraries that Cheese uses in order to process images from the camera.