possible race with 2 stk1160 USB devices
Question
Hi, I have 2 stk1160 based USB capture cards, and I think I'm encountering some sort of race condition somewhere between them and Motion. If I unload and re-load the module enough times, I can get either camera to work, but only one camera ever works at a time, the other shows "unable to open device" in the video stream, and logs as below:
[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Processing config file /etc/motion/thread1.conf
[0] Processing config file /etc/motion/thread2.conf
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785
[0] Thread 1 is from /etc/motion/thread1.conf
[0] Thread 2 is from /etc/motion/thread2.conf
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[2] Thread 2 started
[2] cap.driver: "stk1160"
[2] cap.card: "stk1160"
[2] cap.bus_info: "usb-0000:00:1d.7-6"
[2] cap.capabilities=0x85000001
[2] - VIDEO_CAPTURE
[2] - READWRITE
[2] - STREAMING
[1] Thread 1 started
[2] Config palette index 7 (422P) doesn't work.
[2] Supported palettes:
[2] 0: UYVY (16 bpp YUY2, 4:2:2, packed)
[2] Selected palette UYVY
[2] Test palette UYVY (720x480)
[2] Using palette UYVY (720x480) bytesperlines 1440 sizeimage 691200 colorspace 00000001
[2] found control 0x00980900, "Brightness", range 0,255
[2] "Brightness", default 128, current 128
[2] found control 0x00980901, "Contrast", range 0,127
[2] "Contrast", default 64, current 64
[2] found control 0x00980902, "Saturation", range 0,127
[2] "Saturation", default 64, current 64
[2] found control 0x00980903, "Hue", range -128,127
[2] "Hue", default 0, current 0
[2] mmap information:
[2] frames=8
[2] 0 length=691200
[2] 1 length=691200
[2] 2 length=691200
[2] 3 length=691200
[2] 4 length=691200
[2] 5 length=691200
[2] 6 length=691200
[2] 7 length=691200
[2] Error starting stream VIDIOC_STREAMON: Message too long
[2] ioctl (VIDIOCGCAP): Inappropriate ioctl for device
[2] Could not fetch initial image from camera
[2] Motion continues using width and height from config file(s)
[1] cap.driver: "stk1160"
[2] Resizing pre_capture buffer to 1 items
[1] cap.card: "stk1160"
[1] cap.bus_info: "usb-0000:00:1d.7-1"
[1] cap.capabilities=0x85000001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Config palette index 7 (422P) doesn't work.
[1] Supported palettes:
[1] 0: UYVY (16 bpp YUY2, 4:2:2, packed)
[1] Selected palette UYVY
[1] Test palette UYVY (720x480)
[1] Using palette UYVY (720x480) bytesperlines 1440 sizeimage 691200 colorspace 00000001
[1] found control 0x00980900, "Brightness", range 0,255
[1] "Brightness", default 128, current 128
[1] found control 0x00980901, "Contrast", range 0,127
[1] "Contrast", default 64, current 64
[1] found control 0x00980902, "Saturation", range 0,127
[1] "Saturation", default 64, current 64
[2] Started stream webcam server in port 8082
[2] Resizing pre_capture buffer to 7 items
[1] found control 0x00980903, "Hue", range -128,127
[1] "Hue", default 0, current 0
[1] mmap information:
[1] frames=8
[1] 0 length=691200
[1] 1 length=691200
[1] 2 length=691200
[1] 3 length=691200
[1] 4 length=691200
[1] 5 length=691200
[1] 6 length=691200
[1] 7 length=691200
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081
[1] Resizing pre_capture buffer to 7 items
[2] Retrying until successful connection with camera
[2] cap.driver: "stk1160"
[2] cap.card: "stk1160"
[2] cap.bus_info: "usb-0000:00:1d.7-6"
[2] cap.capabilities=0x85000001
[2] - VIDEO_CAPTURE
[2] - READWRITE
[2] - STREAMING
[2] Config palette index 7 (422P) doesn't work.
[2] Supported palettes:
[2] 0: UYVY (16 bpp YUY2, 4:2:2, packed)
[2] Selected palette UYVY
[2] Test palette UYVY (720x480)
[2] Error setting pixel format VIDIOC_S_FMT: Device or resource busy
[2] VIDIOC_TRY_FMT failed for format UYVY: Device or resource busy
[2] Unable to find a compatible palette format.
[2] ioctl (VIDIOCGCAP): Inappropriate ioctl for device
[2] Retrying until successful connection with camera
[2] cap.driver: "stk1160"
[2] cap.card: "stk1160"
[2] cap.bus_info: "usb-0000:00:1d.7-6"
[2] cap.capabilities=0x85000001
[2] - VIDEO_CAPTURE
[2] - READWRITE
[2] - STREAMING
[2] Config palette index 7 (422P) doesn't work.
[2] Supported palettes:
[2] 0: UYVY (16 bpp YUY2, 4:2:2, packed)
[2] Selected palette UYVY
[2] Test palette UYVY (720x480)
[2] Error setting pixel format VIDIOC_S_FMT: Device or resource busy
[2] VIDIOC_TRY_FMT failed for format UYVY: Device or resource busy
[2] Unable to find a compatible palette format.
[2] ioctl (VIDIOCGCAP): Inappropriate ioctl for device
Environment
Motion version: |
3.2.12-3.4 |
ffmpeg version: |
6:0.8.10-1 |
Libraries: |
ffmpeg |
Server OS: |
debian wheezy |
--
PratFall - 11 Mar 2014
Answer