Failed to set video format: Invalid argument "Man in middle"

Forum for questions and support relating to the 1.25.x releases only.
Locked
OH1KH
Posts: 13
Joined: Mon Dec 19, 2011 12:49 pm

Failed to set video format: Invalid argument "Man in middle"

Post by OH1KH »

Hi !
Didi not found similar problem with search as in subject.
This might be other than Zoneminder problem, but I'm interested to hear has someone found similar problem.

I start the PC (Fedora 15) and Zoneminder. It works ok some 10 hours. This time varies. I do have UPS, so no question
about short power failures.
After that time /dev/video1 starts to give error "Failed to set video format: Invalid argument". Only help is to power off (reboot
seems not always help) whole system.

lsusb
Bus 002 Device 002: ID 18ec:3299 Arkmicro Technologies Inc.

And now the interesting part when it is working with ZM it gives:

### v4l2 device info [/dev/video1] ###
general info
VIDIOC_QUERYCAP
driver : "uvcvideo"
card : "USB2.0 PC CAMERA"
bus_info : "usb-0000:00:10.3-3"
version : 3.1.5
capabilities : 0x4000001 [VIDEO_CAPTURE,STREAMING]
standards
inputs
VIDIOC_ENUMINPUT(0)
index : 0
name : "Camera 1"
type : CAMERA
audioset : 0
tuner : 0
std : 0x0 []
status : 0x0 []
video capture
VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE)
index : 0
type : VIDEO_CAPTURE
flags : 0
description : "YUV 4:2:2 (YUYV)"
pixelformat : 0x56595559 [YUYV]
VIDIOC_G_FMT(VIDEO_CAPTURE)
type : VIDEO_CAPTURE
fmt.pix.width : 320
fmt.pix.height : 240
fmt.pix.pixelformat : 0x56595559 [YUYV]
fmt.pix.field : NONE

When it stops working it gives :
### v4l2 device info [/dev/video1] ###
general info
VIDIOC_QUERYCAP
driver : "uvcvideo"
card : "USB2.0 PC CAMERA"
bus_info : "usb-0000:00:10.1-1"
version : 3.1.5
capabilities : 0x4000001 [VIDEO_CAPTURE,STREAMING]

standards

inputs
VIDIOC_ENUMINPUT(0)
index : 0
name : "Camera 1"
type : CAMERA
audioset : 0
tuner : 0
std : 0x0 []
status : 0x0 []

video capture
VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE)
index : 0
type : VIDEO_CAPTURE
flags : 1
description : "MJPEG"
pixelformat : 0x47504a4d [MJPG]
VIDIOC_G_FMT(VIDEO_CAPTURE)
type : VIDEO_CAPTURE
fmt.pix.width : 320
fmt.pix.height : 240
fmt.pix.pixelformat : 0x47504a4d [MJPG]
fmt.pix.field : NONE

SAME CAMERA !!! No power off !! No other usage !!

Can Zoneminder (ZMC) send a command that turns camera from YUYV to MJPEG ??

After that, of course settings are not correct and video format is fails.
When MJPG is on I can use camera starting uvc_capture and looking camera as http stream in setup. Works for long time.
But if pc is booted I have to change settings again.

Might be also uvcvideo driver fault, eh?
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: Failed to set video format: Invalid argument "Man in mid

Post by mastertheknife »

I have seen that in few UVC cameras. They show YUYV when connected to a USB 2.0 or higher port, and MJPEG on slower USB ports because it uses less bandwidth.
Are you using any USB hubs? Why does the camera disconnect after some time, in the first place?
I have a small workaround but its not a fix for the disconnection. The workaround is to use my patch (which adds MJPEG support) and use the "Auto" capture palette, See here: http://www.zoneminder.com/forums/viewto ... =9&t=17652

Though, i believe the correct solution is to prevent the camera from disconnecting in the first place. Try different USB ports and try disconnecting other USB devices.

mastertheknife.
Kfir Itzhak.
OH1KH
Posts: 13
Joined: Mon Dec 19, 2011 12:49 pm

Re: Failed to set video format: Invalid argument "Man in mid

Post by OH1KH »

No.
I'm using no hubs.

Just bought another USB-PCI card as I did not get those cameras working (2 uvc cameras) with zoneminder and PC's own USB ports (6 sockets).
Now they work when one is at PCs socket and other at new usb-card. Except this problem.

Previously I had 2 creative cameras with gspy(modified) and they worked many years ok from PC's USB. I did upgrade from Mandrake 9.4
to Fedora 15 and had to give up for gspy (v4l1) and also liked to change cameras to better resolution with 160deg lens.

I have tried quirks=128 when loading uvcvideo, but no help. 2 different USB cards are needed. quirks are so poorly documented that I do not know
what those different numbers do. Just googled that 128 that should reduce bandwidth.

I have no idea what breaks the camera. Yesterday evening I booted the server and set camera to YUYV. This morning I found out that it is no longer working.
Procedure to fix: stop zm; rmmod uvcvideo; modprobe uvcvideo; start uvc_stream -d /dev/video1 -r 320x240 -p 8080 -b; change monitor in zm from /dev/video1 YUYV to remote http regexp localhost:8080 /?action=snapshot; start zm

Works until server is rebooted again.

Perhps I have to do cron script that first digs out YUYV or MJPEG in use and after that does changes ;) Or find another camera.
Those 2 are from DealExtreme cheap cameras with wide angle lens added. They look similar out, but register themselfs totally different
numbers.
OH1KH
Posts: 13
Joined: Mon Dec 19, 2011 12:49 pm

Re: Failed to set video format: Invalid argument "Man in mid

Post by OH1KH »

Hi!
It might be that I found solution for my camera drops.

I did upgrade from Fedora15 to Fedora16 and after that I had to recompile ZM. I do not think
this did any help.

But because of this upgrade I lost contact to my sound card that is used for AIS monitoring (gnuais).
This happened also with Fedora15, but randomly, and I did not pay attention for this as there
were bigger problems with other things.

Now I looked that little further and noticed that sometimes motherboard's soundcard was device 1,
sometimes device 0 that affected to gnuais config.

The problem camera that changed YUYV to MPEG after some time has also microphone and
it represent itself as USB-audio. Other camera, that has worked all the time, has microphone too.
How ever it has 3,5 jack for audio connect, so it does not use USB for audio.

After blacklisting "snd_usb_audio" driver the camera has kept YUYV online all the time.

Solution might not be good if you really need USB audio for some other sound device. Then you should
change udev so that camera does not use sound driver rather than disabling whole driver.

I think this can be done, but jumping from Mandrake9.4 to Fedora16 leaves some gaps to system's
inside life. So much has changed :? Disabling whole driver was fastest found solution for me.
OH1KH
Posts: 13
Joined: Mon Dec 19, 2011 12:49 pm

Re: Failed to set video format: Invalid argument "Man in mid

Post by OH1KH »

Don't be fooled ! :(
Disabling snd_USB_audio did not resolve camera problem. It just took few days before camera was dropped from YUYV to MJPG.
It keeps now steady on MJPG, but will return to YUYV when server is rebooted. And after that YUYV will keep some time before camera
goes back to MJPG.

I have now made a script that I'm going to run from root's crontab every 10 minutes. I hope it resolves this problem altough it does
not fix the reason. On simulation script seems to work as expected.

SwapVideo1Mode.sh

#!/bin/sh
# Differences in zm.Monitors-table when using direct v4l2-YUYV
##Type=Local,Method=v4l2,Palette=1448695129
# OR uvc-streamer-server accessing MJPG-mode of camera
##Type=Remote,Method=regexp,Palette=3

zmode=$(mysql -u zmuser --password=zmpass -D zm --batch --column-names=false -e 'SELECT Type from Monitors where Device="/dev/video1" ')
videomode=$(/usr/bin/v4l-info /dev/video1 | grep fmt.pix.pixelformat | awk '{print $4}'| tr -d [])

if [[ $videomode == "MJPG" ]]; then
{
if [[ $zmode == "Remote" ]]; then
{
echo All Ok! Using Remote-MJPG.
}
else
{
echo change to Remote...
#Start uvc-streamer for video1-camera It can handle MJPG stream
/usr/src/mjpg-streamer/uvc-streamer/uvc_stream -d /dev/video1 -r 320x240 -p 8080 -b -f 1 --disable_control
mysql -u zmuser --password=zmpass -D zm --batch --column-names=false -e 'update Monitors set Type="Remote",Method="regexp",Palette="3" where Device="/dev/video1" '
/usr/local/bin/zmpkg.pl restart
}
fi
}
else
{
if [[ $zmode == "Local" ]]; then
{
echo All Ok ! Using Local-YUYV.
}
else
{
echo change to Local...
mysql -u zmuser --password=zmpass -D zm --batch --column-names=false -e 'update Monitors set Type="Local",Method="v4l2",Palette="1448695129" where Device="/dev/video1" '
/usr/local/bin/zmpkg.pl restart
}
fi
}
fi
Locked