View Single Post
  #2  
Old 05-03-2010, 04:14 AM
Stream Recorder
 
Posts: n/a
Default

Re: zmu -d /dev/video0 -q -v: Error, failed to query crop /dev/video0: Invalid argume


A USB camera that doesn't support cropping will produce an error message
Code:
Error, failed to query crop: /dev/video0: Invalid argument
from
Code:
zmu -d /dev/video0 -q -v

Fix for the problem:
Quote:
Failures are exhibited in zmu, and other places that rely on LocalCamera::GetCurrentSettings.

The fault is in LocalCamera::GetCurrentSettings.

The error arises from the fact that ioctl VIDIOC_G_CROP returns -1 and errno = EINVAL to indicate that cropping is not supported. LocalCamera::GetCurrentSettings treats any negative rc from ioctl VIDIOC_G_CROP as grounds for abnormal termination.

The fix is straightforward and short. All changes are in zm_local_camera.cpp as follows:
Code:
911,912c911 
<        int crop_rc = vidioctl( vid_fd, VIDIOC_G_CROP, &crop ); 
<             if ((crop_rc  < 0 ) && (errno != EINVAL)) 
--- 
>             if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 ) 
921,928c920,921 
<             if ( verbose ) { 
<       if (crop_rc >= 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"); 
<       } 
<        } 
--- 
>             if ( verbose ) 
>                 sprintf( output+strlen(output), "  Current: %d x %d\n", crop.c.width, crop.c.height );
Reply With Quote