Failed to get picture attributes in zm_local_camera.cpp

Forum for questions and support relating to the 1.24.x releases only.
Locked
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Failed to get picture attributes in zm_local_camera.cpp

Post by carteriii »

Short version: What might be the cause of, 'Failed to get picture attributes: Invalid argument' in zm_local_camera.cpp on line 507, just after 'Configuring Pictures Attributes' on line 502?

Longer story, I upgraded to Ubuntu 11.10. I kept ZM at 1.24.2 rather than upgrading zm at the same time just to reduce my variables in debugging something like this. My video capture can still be seen just fine by xawtv. zmfix -a is doing its job and setting permissions on my video devices.

I turned on the extra debugging and manually ran one capture process as suggested in the troubleshooting guide

Code: Select all

sudo /usr/bin/zmc -d /dev/video6 -m 1
which failed immediately giving the errors I mentioned above.

I don't know if it's a cause or an effect, but when I try to fully start ZM, zmwatch gives me an error in the logs of, 'Shared data size conflict in shared_data for monitor <monitor name>'. I don't see that when running zmc manually, so I suspect that could be a function of zmc exiting abnormally and then zmwatch sees the shared memory problem. I do have shmall and shmmax set in /etc/sysctl.conf exact as it has been for years now. No changes there, so I wouldn't expect there to be a problem with those values.

The troubleshooting guide suggests runnnig 'ipcs -m' to check that the shared memory segment has been created, but honestly I don't know what to look for in that output. At a minimum I do not see the SHM_KEY (0x7a6d2000) listed as a key in the output of 'ipcs -m', but it seems to me that zmc is never getting to the point of creating the shared memory segment because it's failing before that point. I feel the right thing is to focus on finding out what causes the failure "to get picture attributes".

Additionally, I don't know if this is relevant or not, but when running xawtv, I get a few warnings to the console as well as ioctl messages. Since a call to ioctl() seems to be the function that is failing in zm_local_camera.cpp, perhaps this is relevant. Here is what I see:

Code: Select all

> xawtv -device /dev/video6
This is xawtv-3.95.dfsg.1, running on Linux/i686 (3.0.0-14-generic)
xinerama 0: 1600x1200+0+0
WARNING: No DGA direct video mode for this display.
WARNING: couldn't find framebuffer base address, try manual
         configuration ("v4l-conf -a <addr>")
v4l2: WARNING: framebuffer base address mismatch
v4l2: me=(nil) v4l=(nil)
Warning: Cannot convert string "-*-ledfixed-medium-r-*--39-*-*-*-c-*-*-*" to type FontStruct
ioctl: VIDIOC_S_CTRL(id=9963785;value=0): Invalid argument
ioctl: VIDIOC_S_CTRL(id=9963778;value=32768): Invalid argument
ioctl: VIDIOC_S_CTRL(id=9963776;value=32768): Invalid argument
ioctl: VIDIOC_S_CTRL(id=9963779;value=32768): Invalid argument
ioctl: VIDIOC_S_CTRL(id=9963777;value=32768): Invalid argument
Xlib:  extension "GLX" missing on display ":0".
ioctl: VIDIOC_S_CTRL(id=9963785;value=1): Invalid argument
Please help me. I'm at a loss for what to do or check next.
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Re: Failed to get picture attributes in zm_local_camera.cpp

Post by carteriii »

More information. The specific lines that generate the error are:

Code: Select all

 if ( ioctl( vid_fd, VIDIOCGPICT, &vid_pic) < 0 )
            Fatal( "Failed to get picture attributes: %s", strerror(errno) );
Since the specific error came back with 'Failed to get picture attributes: Invalid argument', I'm asking myself which argument. The third argument is simply a memory address so I don't see how it can be wrong. The vid_fd is tested after it is opened (on line #351 in LocalCamera::Initialise)...

Code: Select all

if ( (vid_fd = open( device.c_str(), O_RDWR, 0 )) < 0 )
		Fatal( "Failed to open video device %s: %s", device.c_str(), strerror(errno) );
so you'd think that it is ok (I'm assuming that LocalCamera::Initialise() is called).

That leaves VIDIOCGPICT. When I search the web for "ioctl VIDIOCGPICT", Google comes back and asks if I meant to say, 'VIDIOCSPICT' (note the 'S' rather than the 'G'). Could there be any chance that VIDIOCGPICT is wrong, or no longer valid in Ubuntu 11.10? Seem unlikely for a constant to be wrong, which sends me back to vid_fd, and whether it is right.

I'm still stumped. I have lots of data, but I'm just stumped. Can anyone shed any light on why that call above to ioctl would fail with 'Invalid argument'?
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Re: Failed to get picture attributes in zm_local_camera.cpp

Post by carteriii »

More detail from the extra debugging...

Code: Select all

12/20/11 22:30:39.409729 zmc_dvideo6[3233].INF-zmc.cpp/188 [Starting Capture]
12/20/11 22:30:39.409797 zmc_dvideo6[3233].DB3-zm_local_camera.cpp/349 [Opening video device /dev/video6]
12/20/11 22:30:39.409862 zmc_dvideo6[3233].DB2-zm_local_camera.cpp/355 [V4L2 support enabled, using V4L1 api]
12/20/11 22:30:39.409878 zmc_dvideo6[3233].DB3-zm_local_camera.cpp/502 [Configuring picture attributes]
12/20/11 22:30:39.409909 zmc_dvideo6[3233].FAT-zm_local_camera.cpp/507 [Failed to get picture attributes: Invalid argument]
12/20/11 22:30:39.409968 zmc_dvideo6[3233].INF-zm_signal.cpp/64 [Got signal 6 (Aborted), exiting and forcing backtrace]
Here it is clear that the device is getting opened, but the subsequent line has me confused. The debug line says that V4L2 support is enabled, but it's using the V4L1 api. Naively I would have expected to be running V4L2 on Ubuntu 11.10, so could that be something I can manipulate to fix things?

I see that the code in zm_local_camera.cpp determines whether or not to use V4L2 based on the p_method parameter passed to the constructor, but I haven't figured out how that gets set upstream.

Should I be running video for linux 2?
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Re: Failed to get picture attributes in zm_local_camera.cpp

Post by carteriii »

I'm back. Are you sick of me yet?
The V4L1 vs. V4L2 issue seems irrelevant. I tracked the source back to find the V4L1 vs. V4L2 is set in the monitor configuration. Mine was simply still V4L1 because that's what it was when I first configured my monitors several years ago. I did try changing it to V4L2 and still got an error. This time, with extra debug, I see

Code: Select all

12/21/11 10:27:37.321525 zmc_dvideo6[16026].INF-zmc.cpp/188 [Starting Capture]
12/21/11 10:27:37.321593 zmc_dvideo6[16026].DB3-zm_local_camera.cpp/349 [Opening video device /dev/video6]
12/21/11 10:27:37.321651 zmc_dvideo6[16026].DB2-zm_local_camera.cpp/355 [V4L2 support enabled, using V4L2 api]
12/21/11 10:27:37.321663 zmc_dvideo6[16026].DB3-zm_local_camera.cpp/360 [Checking video device capabilities]
12/21/11 10:27:37.321682 zmc_dvideo6[16026].DB3-zm_local_camera.cpp/370 [Setting up video format]
12/21/11 10:27:37.321714 zmc_dvideo6[16026].FAT-zm_local_camera.cpp/386 [Failed to set video format: Invalid argument]
12/21/11 10:27:37.321843 zmc_dvideo6[16026].INF-zm_signal.cpp/64 [Got signal 6 (Aborted), exiting and forcing backtrace]
The lines which cause this error are now:

Code: Select all

 if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 )
            Fatal( "Failed to set video format: %s", strerror(errno) );
I'm still lost. Someone please jump in here and help me out.
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Re: Failed to get picture attributes in zm_local_camera.cpp

Post by carteriii »

OK, now we're getting somewhere. I found a discussion in another thread about the use of RGB24 vs. BRG24 (http://www.zoneminder.com/forums/viewto ... 21&t=18497) and that RGB24 isn't supported by BT878 chips on little endian machines. Sure enough, running zmu -d -q -v shows that I have BT878

Code: Select all

sudo zmu -d /dev/video6 -q -v
Video Device: /dev/video6
General Capabilities
  Driver: bttv
  Card: BT878 video (IVC-200)
  Bus: PCI:0000:08:0e.0
  Version: 0.9.18
  Type: 0x5000015
    Supports video capture (X)
    Does not support video output
    Supports frame buffer overlay
    Supports VBI capture
    Does not support VBI output
    Does not support sliced VBI capture
    Does not support sliced VBI output
    Does not support video output overlay
    Does not have tuner
    Does not have audio in and/or out
    Does not have radio
    Supports read/write i/o (X)
    Does not support async i/o
    Supports streaming i/o (X)
    Standards:
      NTSC
      NTSC-M
      NTSC-M-JP
      NTSC-M-KR
      PAL
      PAL-BG
      PAL-H
      PAL-I
      PAL-DK
      PAL-M
      PAL-N
      PAL-Nc
      PAL-60
      SECAM
      SECAM-B
      SECAM-G
      SECAM-H
      SECAM-DK
      SECAM-L
      SECAM-Lc
  Formats:
    8 bpp, gray (GREY)
    8 bpp, dithered color (HI24)
    15 bpp RGB, le (RGBO)
    15 bpp RGB, be (RGBQ)
    16 bpp RGB, le (RGBP)
    16 bpp RGB, be (RGBR)
    24 bpp RGB, le (BGR3)
    32 bpp RGB, le (BGR4)
    32 bpp RGB, be (RGB4)
    4:2:2, packed, YUYV (YUYV)
    4:2:2, packed, YUYV (YUYV)
    4:2:2, packed, UYVY (UYVY)
    4:2:2, planar, Y-Cb-Cr (422P)
    4:2:0, planar, Y-Cb-Cr (YU12)
    4:2:0, planar, Y-Cr-Cb (YV12)
    4:1:1, planar, Y-Cb-Cr (411P)
    4:1:0, planar, Y-Cb-Cr (YUV9)
    4:1:0, planar, Y-Cr-Cb (YVU9)
Crop Capabilities
  Bounds: 838 x 504
  Default: 768 x 480
  Current: 768 x 480
Inputs: 1
  Input 0
    Name: Composite0
    Type: Camera
    Audioset: 00000001
    Standards: 0xffbfff
    Power on  (X)
    Signal detected  (X)
    Colour Signal detected 
    Horizontal Lock detected
So I don't fully understand or appreciate the difference, but I changed my monitor configuration to use V4L2 and BRG24. Now I have most of my cameras working again. One camera (the one listed above), still hooked to the same capture card, isn't working, so I'll keep working on that for now.
Locked