Captured image has wrong colors (displacement of chrome data)
Question
I have a cheap usb 2.0 webcam (ID 0ac8:303b Z-Star Microelectronics Corp. ZC0303 Webcam), I'm using the latest drivers (gspca_main, gspca_zc3xx) and kernel 2.6.35-gentoo-r4.
The symptom is that snapshots, movies and live view in port 8081 all have wrong colors. They are not "ghost" images, as I have enabled them and they are different. I have tested with motion 3.2.11.1, motion-3.2.12 and latest daily snapshot motion-20101029-051001. VLC shows correct images. The only strange thing in my setup is that my camera only supports JPEG output.
The images I'm seeing is mostly desaturated, almost black and white with some translucent blobs of red and blue.
Image from motion (all versions outputs similar images)
Snapshot from VLC, correct colors.
Raw dump with ./svv -rg (
http://moinejf.free.fr/svv.c), white balance seems off, but mostly ok.
Now that I see, this is an error decoding the jpeg, the chroma info is displaced to the right. I'm using libjpeg.so.8, but the above images shows that the red blob in the middle of the image is the thing hanging from the door knob to the left, and the blue ones in the bottom seems to be the top part of the Ikea bag.
motion-20101029-051001 # ./motion -n -d 9 -c motion-dist.conf
[0] [NTC] [ALL] conf_load: Processing thread 0 - config file motion-dist.conf
[0] [NTC] [ALL] motion_startup: Motion trunkREV514 Started
[0] [NTC] [ALL] motion_startup: Logging to syslog
[0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (ALL)
[0] [NTC] [ENC] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3431424 LIBAVFORMAT_BUILD 3428352
[0] [NTC] [ALL] main: Thread 1 is from motion-dist.conf
[0] [NTC] [ALL] main: Thread 1 is device: /dev/video0 input 8
[0] [NTC] [ALL] main: Stream port 8081
[0] [NTC] [ALL] main: Waiting for threads to finish, pid: 791
[0] [NTC] [STR] httpd_run: motion-httpd testing : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] httpd_run: motion-httpd Bound : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] httpd_run: motion-httpd/trunkREV514 running, accepting connections
[0] [NTC] [STR] httpd_run: motion-httpd: waiting for data on 127.0.0.1 port TCP 8080
[1] [NTC] [ALL] motion_init: Thread 1 started
[1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input 8
[1] [NTC] [VID] v4l2_get_capability:
------------------------
cap.driver: "zc3xx"
cap.card: "PC Camera"
cap.bus_info: "usb-0000:00:02.1-3.4"
cap.capabilities=0x05000001
------------------------
[1] [NTC] [VID] v4l2_get_capability: - VIDEO_CAPTURE
[1] [NTC] [VID] v4l2_get_capability: - READWRITE
[1] [NTC] [VID] v4l2_get_capability: - STREAMING
[1] [NTC] [VID] v4l2_select_input: name = "zc3xx", type 0x00000002, status 00000000
[1] [NTC] [VID] v4l2_select_input: - CAMERA
[1] [NTC] [VID] v4l2_set_pix_format: Config palette index 17 (YU12) doesn't work.
[1] [NTC] [VID] v4l2_set_pix_format: Supported palettes:
[1] [NTC] [VID] v4l2_set_pix_format: (0) JPEG (JPEG)
[1] [NTC] [VID] v4l2_set_pix_format: 0 - JPEG (compressed : 1) (0x4745504a)
[1] [NTC] [VID] v4l2_set_pix_format Selected palette JPEG
[1] [NTC] [VID] v4l2_do_set_pix_format: Testing palette JPEG (320x240)
[1] [NTC] [VID] v4l2_do_set_pix_format: Using palette JPEG (320x240) bytesperlines 320 sizeimage 29390 colorspace 00000007
[1] [NTC] [VID] v4l2_scan_controls: found control 0x00980900, "Brightness", range 0,255
[1] [NTC] [VID] v4l2_scan_controls: "Brightness", default 128, current 128
[1] [NTC] [VID] v4l2_scan_controls: found control 0x00980901, "Contrast", range 0,255
[1] [NTC] [VID] v4l2_scan_controls: "Contrast", default 128, current 128
[1] [NTC] [VID] v4l2_scan_controls: found control 0x00980910, "Gamma", range 1,6
[1] [NTC] [VID] v4l2_scan_controls: "Gamma", default 4, current 4
[1] [NTC] [VID] v4l2_scan_controls: found control 0x00980912, "Auto Gain", range 0,1
[1] [NTC] [VID] v4l2_scan_controls: "Auto Gain", default 1, current 1
[1] [DBG] [VID] v4l2_set_mmap: mmap information: frames=4
[1] [DBG] [VID] v4l2_set_mmap: 0 length=32768 Address (b7800000)
[1] [DBG] [VID] v4l2_set_mmap: 1 length=32768 Address (b77f8000)
[1] [DBG] [VID] v4l2_set_mmap: 2 length=32768 Address (b77f0000)
[1] [DBG] [VID] v4l2_set_mmap: 3 length=32768 Address (b77e8000)
[0] [DBG] [ALL] main: DEBUG-2 threads_running 1 motion_threads_running 1 finish 0
[0] [DBG] [ALL] main: DEBUG-2 threads_running 1 motion_threads_running 1 finish 0
[1] [NTC] [VID] vid_v4lx_start: Using V4L2
[1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
[1] [DBG] [VID] v4l2_next: 1) vid_source->pframe -1
[1] [DBG] [VID] v4l2_next: 2) vid_source->pframe -1
[1] [DBG] [VID] v4l2_next: 3) vid_source->pframe 0 vid_source->buf.index 0
[1] [DBG] [VID] v4l2_next: vid_source->buf.bytesused 8366
[1] [DBG] [VID] v4l2_next: the_buffer index 0 Address (b7800000)
[1] [NTC] [STR] http_bindsock: motion-stream testing : IPV4 addr: 127.0.0.1 port: 8081
[1] [NTC] [STR] http_bindsock: motion-stream Bound : IPV4 addr: 127.0.0.1 port: 8081
[1] [NTC] [ALL] motion_init: Started motion-stream server in port 8081
[1] [DBG] [VID] v4l2_next: 1) vid_source->pframe 0
[1] [DBG] [VID] v4l2_next: 2) vid_source->pframe 0
[1] [DBG] [VID] v4l2_next: 3) vid_source->pframe 1 vid_source->buf.index 1
[1] [DBG] [VID] v4l2_next: vid_source->buf.bytesused 8736
[1] [DBG] [VID] v4l2_next: the_buffer index 1 Address (b77f8000)
[1] [DBG] [VID] v4l2_next: 1) vid_source->pframe 1
[1] [DBG] [VID] v4l2_next: 2) vid_source->pframe 1
[1] [DBG] [VID] v4l2_next: 3) vid_source->pframe 2 vid_source->buf.index 2
[1] [DBG] [VID] v4l2_next: vid_source->buf.bytesused 8726
[1] [DBG] [VID] v4l2_next: the_buffer index 2 Address (b77f0000)
[0] [DBG] [ALL] main: DEBUG-2 threads_running 1 motion_threads_running 1 finish 0
[1] [DBG] [VID] v4l2_next: 1) vid_source->pframe 2
[1] [DBG] [VID] v4l2_next: 2) vid_source->pframe 2
[1] [DBG] [VID] v4l2_next: 3) vid_source->pframe 3 vid_source->buf.index 3
[1] [DBG] [VID] v4l2_next: vid_source->buf.bytesused 8746
[1] [DBG] [VID] v4l2_next: the_buffer index 3 Address (b77e8000)
[1] [DBG] [VID] v4l2_next: 1) vid_source->pframe 3
[1] [DBG] [VID] v4l2_next: 2) vid_source->pframe 3
[1] [DBG] [VID] v4l2_next: 3) vid_source->pframe 0 vid_source->buf.index 0
[1] [DBG] [VID] v4l2_next: vid_source->buf.bytesused 8712
[1] [DBG] [VID] v4l2_next: the_buffer index 0 Address (b7800000)
[0] [DBG] [ALL] main: DEBUG-2 threads_running 1 motion_threads_running 1 finish 0
Environment
Motion version: |
3.2.12 |
ffmpeg version: |
0.6_p25423 |
Libraries: |
ffmpeg, mysql |
Server OS: |
Gentoo Linux kernel 2.6.35-gentoo-r4 |
--
JorgeNerin - 29 Oct 2010
Answer