Page 1 of 1

Failed to set video format: Invalid argument VIDIOCGMBUF

Posted: Mon Jan 11, 2010 5:54 am
by kekehuoshan
zmc exit status 255[error in zm_local_camera.cpp ] this issue fixed, new problem in reply post

zmc exited abnormally, exit status 255,Error in LocalCamera::Initialise() in DEBUG log

native uvcvideo drive seems works fine, I can use mplayer to view and mencoder to record.

Code: Select all

mplayer -fps 15 tv:// -tv driver=v4l2:device=/dev/video0
mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -nosound -ovc lavc -o wcrecording.avi [driver=v4l1 not work]

Code: Select all

01/08/2010 14:22:44.069577 zmdc[20697].INF [Starting pending process, zmc -d /dev/video]
01/08/2010 14:22:44.074258 zmdc[20697].INF ['zmc -d /dev/video' starting at 10/01/08 14:22:44, pid = 28157]
01/08/2010 14:22:44.159869 zmdc[20697].ERR ['zmc -d /dev/video' exited abnormally, exit status 255]
DEBUG mode, messages are different when using V4L1/V4L2.
[V4L1 to captrure]

Code: Select all

01/08/10 14:22:44.102250 zmc_dvideo[28157].INF-zm_debug.c/292 [New Debug Level = 4, New Debug Log = /tmp/zm_debug.log]
01/08/10 14:22:44.103669 zmc_dvideo[28157].DB1-zm_monitor.cpp/1712 [Got 1 monitors]
01/08/10 14:22:44.103898 zmc_dvideo[28157].DB2-zm_local_camera.cpp/286 [V4L2 support enabled, using V4L1 api]
01/08/10 14:22:44.104177 zmc_dvideo[28157].DB1-zm_monitor.cpp/338 [monitor purpose=1]
01/08/10 14:22:44.104242 zmc_dvideo[28157].DB1-zm_monitor.cpp/345 [mem.size=769192]
01/08/10 14:22:44.106260 zmc_dvideo[28157].DB1-zm_zone.cpp/50 [Initialised zone 0/All - 1 - 160x120 - Rgb:ff0000, CM:3, MnAT:15, MxAT:0, MnAP:50, MxAP:75000, FB:3x3, MnFP:50, MxFP:50000, MnBS:10, MxBS:0, MnB:0, MxB:0, OF: 0]
01/08/10 14:22:44.107180 zmc_dvideo[28157].DB1-zm_monitor.cpp/458 [Monitor Home has function 2]
01/08/10 14:22:44.107241 zmc_dvideo[28157].DB1-zm_monitor.cpp/459 [Monitor Home LBF = '%N - %y/%m/%d %H:%M:%S', LBX = 0, LBY = 0]
01/08/10 14:22:44.107285 zmc_dvideo[28157].DB1-zm_monitor.cpp/460 [Monitor Home IBC = 40, WUC = 25, pEC = 10, PEC = 10, EAF = 1, FRI = 1000, RBP = 7, FM = 0]
01/08/10 14:22:44.108264 zmc_dvideo[28157].DB1-zm_zone.cpp/889 [Got 1 zones for monitor Home]
01/08/10 14:22:44.108370 zmc_dvideo[28157].DB3-zm_zone.cpp/758 [Parsing polygon string '0,0 159,0 159,119 0,119']
01/08/10 14:22:44.108434 zmc_dvideo[28157].DB3-zm_zone.cpp/796 [Got coordinate 0,0 from polygon string]
01/08/10 14:22:44.108473 zmc_dvideo[28157].DB3-zm_zone.cpp/796 [Got coordinate 159,0 from polygon string]
01/08/10 14:22:44.108502 zmc_dvideo[28157].DB3-zm_zone.cpp/796 [Got coordinate 159,119 from polygon string]
01/08/10 14:22:44.108529 zmc_dvideo[28157].DB3-zm_zone.cpp/796 [Got coordinate 0,119 from polygon string]
01/08/10 14:22:44.108566 zmc_dvideo[28157].DB3-zm_zone.cpp/816 [Successfully parsed polygon string]
01/08/10 14:22:44.108604 zmc_dvideo[28157].DB1-zm_zone.cpp/50 [Initialised zone 1/All - 1 - 160x120 - Rgb:ff0000, CM:3, MnAT:25, MxAT:0, MnAP:576, MxAP:14400, FB:3x3, MnFP:576, MxFP:14400, MnBS:384, MxBS:0, MnB:1, MxB:0, OF: 0]
01/08/10 14:22:44.109449 zmc_dvideo[28157].DB1-zm_monitor.cpp/1814 [Loaded monitor 1(Home), 1 zones]
01/08/10 14:22:44.109519 zmc_dvideo[28157].INF-zmc.cpp/188 [Starting Capture]
01/08/10 14:22:44.109744 zmc_dvideo[28157].DB3-zm_local_camera.cpp/349 [Opening video device /dev/video]
01/08/10 14:22:44.109857 zmc_dvideo[28157].DB2-zm_local_camera.cpp/355 [V4L2 support enabled, using V4L1 api]
01/08/10 14:22:44.109900 zmc_dvideo[28157].DB3-zm_local_camera.cpp/502 [Configuring picture attributes]
01/08/10 14:22:44.131478 zmc_dvideo[28157].DB4-zm_local_camera.cpp/509 [Old P:0]
01/08/10 14:22:44.131564 zmc_dvideo[28157].DB4-zm_local_camera.cpp/510 [Old D:0]
01/08/10 14:22:44.131594 zmc_dvideo[28157].DB4-zm_local_camera.cpp/511 [Old B:32768]
01/08/10 14:22:44.131619 zmc_dvideo[28157].DB4-zm_local_camera.cpp/512 [Old h:32768]
01/08/10 14:22:44.131656 zmc_dvideo[28157].DB4-zm_local_camera.cpp/513 [Old Cl:20695]
01/08/10 14:22:44.131694 zmc_dvideo[28157].DB4-zm_local_camera.cpp/514 [Old Cn:31710]
01/08/10 14:22:44.156522 zmc_dvideo[28157].ERR-zm_local_camera.cpp/546 [Failed to set picture attributes: Invalid argument]
[V4L2 to captrure]

Code: Select all

01/08/10 13:38:47.120380 zmc_dvideo[27699].INF-zm_debug.c/292 [New Debug Level = 4, New Debug Log = /tmp/zm_debug.log]
01/08/10 13:38:47.122409 zmc_dvideo[27699].DB1-zm_monitor.cpp/1712 [Got 1 monitors]
01/08/10 13:38:47.122651 zmc_dvideo[27699].DB2-zm_local_camera.cpp/286 [V4L2 support enabled, using V4L2 api]
01/08/10 13:38:47.122930 zmc_dvideo[27699].DB1-zm_monitor.cpp/338 [monitor purpose=1]
01/08/10 13:38:47.122990 zmc_dvideo[27699].DB1-zm_monitor.cpp/345 [mem.size=769192]
01/08/10 13:38:47.125067 zmc_dvideo[27699].DB1-zm_zone.cpp/50 [Initialised zone 0/All - 1 - 160x120 - Rgb:ff0000, CM:3, MnAT:15, MxAT:0, MnAP:50, MxAP:       75000, FB:3x3, MnFP:50, MxFP:50000, MnBS:10, MxBS:0, MnB:0, MxB:0, OF: 0]
01/08/10 13:38:47.126114 zmc_dvideo[27699].DB1-zm_monitor.cpp/458 [Monitor Home has function 2]
01/08/10 13:38:47.126184 zmc_dvideo[27699].DB1-zm_monitor.cpp/459 [Monitor Home LBF = '%N - %y/%m/%d %H:%M:%S', LBX = 0, LBY = 0]
01/08/10 13:38:47.126233 zmc_dvideo[27699].DB1-zm_monitor.cpp/460 [Monitor Home IBC = 40, WUC = 25, pEC = 10, PEC = 10, EAF = 1, FRI = 1000, RBP = 7, FM      = 0]
01/08/10 13:38:47.127858 zmc_dvideo[27699].DB1-zm_zone.cpp/889 [Got 1 zones for monitor Home]
01/08/10 13:38:47.127961 zmc_dvideo[27699].DB3-zm_zone.cpp/758 [Parsing polygon string '0,0 159,0 159,119 0,119']
01/08/10 13:38:47.128047 zmc_dvideo[27699].DB3-zm_zone.cpp/796 [Got coordinate 0,0 from polygon string]
01/08/10 13:38:47.128093 zmc_dvideo[27699].DB3-zm_zone.cpp/796 [Got coordinate 159,0 from polygon string]
01/08/10 13:38:47.128130 zmc_dvideo[27699].DB3-zm_zone.cpp/796 [Got coordinate 159,119 from polygon string]
01/08/10 13:38:47.128167 zmc_dvideo[27699].DB3-zm_zone.cpp/796 [Got coordinate 0,119 from polygon string]
01/08/10 13:38:47.128213 zmc_dvideo[27699].DB3-zm_zone.cpp/816 [Successfully parsed polygon string]
01/08/10 13:38:47.128257 zmc_dvideo[27699].DB1-zm_zone.cpp/50 [Initialised zone 1/All - 1 - 160x120 - Rgb:ff0000, CM:3, MnAT:25, MxAT:0, MnAP:576, MxAP:      14400, FB:3x3, MnFP:576, MxFP:14400, MnBS:384, MxBS:0, MnB:1, MxB:0, OF: 0]
01/08/10 13:38:47.129094 zmc_dvideo[27699].DB1-zm_monitor.cpp/1814 [Loaded monitor 1(Home), 1 zones]
01/08/10 13:38:47.129166 zmc_dvideo[27699].INF-zmc.cpp/188 [Starting Capture]
01/08/10 13:38:47.129818 zmc_dvideo[27699].DB3-zm_local_camera.cpp/349 [Opening video device /dev/video]
01/08/10 13:38:47.129949 zmc_dvideo[27699].DB2-zm_local_camera.cpp/355 [V4L2 support enabled, using V4L2 api]
01/08/10 13:38:47.129995 zmc_dvideo[27699].DB3-zm_local_camera.cpp/360 [Checking video device capabilities]
01/08/10 13:38:47.130107 zmc_dvideo[27699].DB3-zm_local_camera.cpp/370 [Setting up video format]
01/08/10 13:38:47.130216 zmc_dvideo[27699].FAT-zm_local_camera.cpp/386 [Failed to set video format: Invalid argument]
zmu works only at V4L V1.

Code: Select all

[root@CentOS1 ~]#  /usr/bin/zmu -d /dev/video0  -q -v
Error, failed to query crop /dev/video0: Invalid argument
[root@CentOS1 ~]# /usr/bin/zmu -d /dev/video0 -V 1 -q -v
Video Device: /dev/video0
Video Capabilities
  Name: Saturn USB 2.0 Camera.
  Type: 1
    Can capture
  Video Channels: 1
  Audio Channels: 0
  Maximum Width: 640
  Maximum Height: 480
  Minimum Width: 48
  Minimum Height: 32
Window Attributes
  X Offset: 0
  Y Offset: 0
  Width: 320
  Height: 240
Picture Attributes
  Palette: 0 - Unknown
  Colour Depth: 0
  Brightness: 32768
  Hue: 32768
  Colour :20695
  Contrast: 31710
  Whiteness: 43690
Channel 0 Attributes
  Name: Camera 1
  Channel: 0
  Flags: 0
  Type: 2 - Camera
  Format: 0 - PAL
[root@CentOS1 ~]# /usr/bin/zmu -d /dev/video0 -V 2 -q -v
Error, failed to query crop /dev/video0: Invalid argument
v4lctl show the detail error message, that caused by ioctl: VIDIOC_G_STD

Code: Select all

[root@CentOS1 ~]# v4lctl -c /dev/video0 list
ioctl: VIDIOC_G_STD(std=0x18c4b0bfa49978 [PAL_H,PAL_I,PAL_D,PAL_D1,PAL_M,PAL_60,NTSC_M,?,SECAM_G,SECAM_K1,?ATSC_8_VSB,ATSC_16_VSB,(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)]): Invalid argument
attribute  | type   | current | default | comment
-----------+--------+---------+---------+-------------------------------------
norm       | choice | (null)  | (null)  |
input      | choice | Camera  | Camera  | Camera 1
bright     | int    |       0 |       0 | range is -16 => 16
contrast   | int    |      16 |      16 | range is 1 => 32
color      | int    |       6 |       6 | range is 0 => 19
hue        | int    |       0 |       0 | range is -45 => 45
White Bala | bool   | on      | on      |
Gamma      | int    |     160 |     160 | range is 100 => 190
Gain       | int    |     192 |      96 | range is 64 => 192
Power Line | choice | 50 Hz   | 50 Hz   | Disabled 50 Hz 60 Hz
White Bala | int    |    6500 |    6500 | range is 2800 => 6500
Sharpness  | int    |       2 |       2 | range is 0 => 15
Backlight  | int    |       1 |       0 | range is 0 => 1

Some zm error messages

Code: Select all

[zmu]
Error, failed to query crop /dev/video: Invalid argument
[zmc v4l2]
Failed to set picture attributes: Invalid argument
[zmc v4l1]
Failed to set video format: Invalid argument

My webcam not support above v4l set operation.
mplayer seems notice these ioctl fail errors and try to fixed it following get/set way. And can I modify ZM to act this way?

Code: Select all

[root@CentOS1 ~]# mplayer -fps 15 tv:// -tv driver=v4l2:device=/dev/video0
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: Saturn USB 2.0 Camera.
Capabilites:  video capture  streaming
supported norms:
inputs: 0 = Camera 1;
Current input: 0
Current format: MJPEG

mplayer/stream/tvi_v4l2.c [mlayer source code]

Code: Select all

/*
 ** Get current video capture standard.
 */
 static int getstd(priv_t *priv)
 {
     v4l2_std_id id;
     int i=0;

     if (ioctl(priv->video_fd, VIDIOC_G_STD, &id) < 0) {
         struct v4l2_streamparm      parm;

         parm.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
         if(ioctl(priv->video_fd, VIDIOC_G_PARM, &parm) >= 0) {
             mp_msg(MSGT_TV, MSGL_WARN, "%s: your device driver does not support VIDIOC_G_STD ioctl,"
                    " VIDIOC_G_PARM was used instead.\n", info.short_name);
             priv->standard.index=0;
             priv->standard.id=0;
             priv->standard.frameperiod=parm.parm.capture.timeperframe;
             return 0;
         }

         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get standard failed: %s\n",
                info.short_name, strerror(errno));
         return -1;
     }
     do {
         priv->standard.index = i++;
         if (ioctl(priv->video_fd, VIDIOC_ENUMSTD, &priv->standard) < 0) {
             return -1;
         }
     } while (priv->standard.id != id);
     return 0;
 }

Above Issue fix, new problem here

Posted: Thu Aug 05, 2010 1:11 pm
by kekehuoshan
skip the VIDIOC_G_CROP problem by follow modify.

Code: Select all

[user@/opt/programfiles/ZoneMinder/src (0)]$ diff zm_local_camera.cpp zm_local_camera.cpp.backup20100804
911,913c911
<             //if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 )
<             int crop_rc = vidioctl( vid_fd, VIDIOC_G_CROP, &crop );
<             if ((crop_rc  <0>             if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 )
922,923c920,921
<             //if ( verbose )
</sprintf>             if ( verbose )
>                 sprintf( output+strlen(output), "  Current: %d x %d\n", crop.c.width, crop.c.height );
925,931d922
<      if ( verbose ) {
<if>= 0) {
<              sprintf( output+strlen(output), "  Current: %d x %d\n", crop.c.width, crop.c.height );
<          } else {
<              sprintf( output+strlen(output), "  Current: Cropping is not supported\n");
<          }
<      }
Now zmu works

Code: Select all

[!root@/tmp]# /usr/bin/zmu -d /dev/video0  -q -v
Video Device: /dev/video0
General Capabilities
  Driver: uvcvideo
  Card: Saturn USB 2.0 Camera.
  Bus: 0000:00:1f.4
  Version: 0.1.0
  Type: 0x4000001
    Supports video capture (X)
    Does not support video output
    Does not support frame buffer overlay
    Does not support VBI capture
    Does not support VBI output
    Does not support sliced VBI capture
    Does not support sliced VBI output
    Does not have tuner
    Does not have audio in and/or out
    Does not have radio
    Does not support read/write i/o (X)
    Does not support async i/o
    Supports streaming i/o (X)
    Standards:
  Formats:
    MJPEG (MJPG)
Crop Capabilities
  Bounds: 640 x 480
  Default: 640 x 480
  Current: Cropping is not supported
Inputs: 1
  Input 0
    Name: Camera 1
    Type: Camera
    Audioset: 00000000
    Standards: 0x0
    Power on  (X)
    Signal detected  (X)
    Colour Signal detected
    Horizontal Lock detected
xawtv -hwscan

Code: Select all

This is xawtv-3.95, running on Linux/i686 (2.6.18-194.8.1.el5)
looking for available devices
/dev/video0: OK                         [ -device /dev/video0 ]
    type : v4l2
    name : Saturn USB 2.0 Camera.
    flags:  capture
dmesg part:

Code: Select all

usb 2-1: new full speed USB device using uhci_hcd and address 2
usb 2-1: configuration #1 chosen from 1 choice
Linux video capture interface: v2.00
uvcvideo: Found UVC 1.00 device Saturn USB 2.0 Camera. (0ac8:3313)
input: Saturn USB 2.0 Camera. as /class/input/input3
usbcore: registered new driver uvcvideo
USB Video Class driver (v0.1.0)
Kernel:

Code: Select all

2.6.18-194.8.1.el5
viedo kernel module:

Code: Select all

[!root@~]# lsmod | grep video
uvcvideo               53833  0
compat_ioctl32          5569  1 uvcvideo
videodev               25793  1 uvcvideo
v4l1_compat            16069  2 uvcvideo,videodev
v4l2_common            24385  2 uvcvideo,videodev
video                  21193  0
backlight              10049  1 video

Now the error message is:

Code: Select all

08/05/10 20:53:17.630131 zmc_dvideo[26500].DB3-zm_local_camera.cpp/349 [Opening video device /dev/video]
08/05/10 20:53:17.630252 zmc_dvideo[26500].DB2-zm_local_camera.cpp/355 [V4L2 support enabled, using V4L2 api]
08/05/10 20:53:17.630317 zmc_dvideo[26500].DB3-zm_local_camera.cpp/360 [Checking video device capabilities]
08/05/10 20:53:17.630407 zmc_dvideo[26500].DB3-zm_local_camera.cpp/370 [Setting up video format]
08/05/10 20:53:17.630529 zmc_dvideo[26500].FAT-zm_local_camera.cpp/386 [Failed to set video format: Invalid argument]
08/05/10 20:53:17.630829 zmc_dvideo[26500].INF-zm_signal.cpp/64 [Got signal 6 (Aborted), exiting and forcing backtrace]
08/05/10 20:53:17.630984 zmc_dvideo[26500].ERR-zm_signal.cpp/84 [Signal address is (nil), from 0x20a402]

Error occur at source code:

Code: Select all

 578         Debug( 3, "Setting up request buffers" );
 579         if ( ioctl( vid_fd, VIDIOCGMBUF, &v4l1_data.frames ) < 0 )
 580             Fatal( "Failed to setup memory: %s", strerror(errno) );

I'm not familiar with web cam programming, plz help me~
or which part should I look into? video 4 linux?