[Solved]Camera shows as green but no camera image/stream

Forum for questions and support relating to the 1.24.x releases only.
Locked
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

[Solved]Camera shows as green but no camera image/stream

Post by lyallp »

edit: changed orange to green after adding a zone to the monitor and added mplayer output.

I can't seem to get ZoneMinder to show a stream of my webcam.
I am using Gentoo Linux, intel 32bit
"Linux myhost 2.6.34-gentoo-r12 #2 SMP PREEMPT Fri Nov 12 11:22:03 CST 2010 i686 Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz GenuineIntel GNU/Linux"

ZoneMinder 1.24.2 using the Gentoo www-misc/zoneminder ebuild.

My webcam shows up

Code: Select all

root@myhost
# v4l-info

### v4l2 device info [/dev/video0] ###
general info
    VIDIOC_QUERYCAP
	driver                  : "sn9c102"
	card                    : "SN9C1xx PC Camera"
	bus_info                : "usb-0000:00:1d.2-2"
	version                 : 1.1.47
	capabilities            : 0x5000001 [VIDEO_CAPTURE,READWRITE,STREAMING]

standards

inputs
    VIDIOC_ENUMINPUT(0)
	index                   : 0
	name                    : "Camera"
	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             : "bayer rgb"
	pixelformat             : 0x31384142 [BA81]
    VIDIOC_ENUM_FMT(1,VIDEO_CAPTURE)
	index                   : 1
	type                    : VIDEO_CAPTURE
	flags                   : 1
	description             : "JPEG"
	pixelformat             : 0x4745504a [JPEG]
    VIDIOC_G_FMT(VIDEO_CAPTURE)
	type                    : VIDEO_CAPTURE
	fmt.pix.width           : 640
	fmt.pix.height          : 480
	fmt.pix.pixelformat     : 0x4745504a [JPEG]
	fmt.pix.field           : NONE
	fmt.pix.bytesperline    : 0
	fmt.pix.sizeimage       : 307200
	fmt.pix.colorspace      : JPEG
	fmt.pix.priv            : 8

controls
root@myhost
#
I have the appropriate settings in the kernel configured and can use 'mplayer' to see my camera

Code: Select all

env LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 15
MPlayer SVN-r29796-4.4.4 (C) 2000-2009 MPlayer Team
Can't open joystick device /dev/input/js0: No such file or directory
Can't init input joystick

Playing tv://.
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <olschewski>
 comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: SN9C1xx PC Camera
 Capabilites:  video capture  read/write  streaming
 supported norms:
 inputs: 0 = Camera;
 Current input: 0
 Current format: unknown (0x4745504a)
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Invalid argument
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: Cannot get fps
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
Movie-Aspect is undefined - no prescaling applied.
VO: [xv] 640x480 => 640x480 Planar YV12 
Selected video codec: [rawyv12] vfm: raw (RAW YV12)
==========================================================================
Audio: no sound
FPS forced to be 15.000  (ftime: 0.067).
Starting playback...
libv4l2: error dequeuing buf: Invalid argument
v4l2: ioctl set mute failed: Invalid argument
v4l2: 71 frames successfully processed, -70 frames dropped.

Exiting... (Quit)
I have tweaked the ZoneMinder startup script in /etc/init.d/zoneminder to include this pre-load.

Code: Select all

ZM_SCRIPT=/usr/bin/zmpkg.pl

# Commands for starting and stopping the server

if [ -x /usr/lib/libv4l/v4l1compat.so ]
then
    # preload="env LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so "
    preload="env LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so "
fi
CMD_START="${preload}${ZM_SCRIPT} start"
CMD_STOP="${preload}${ZM_SCRIPT} stop"
unset preload
When I configure the monitor (with one zone), it shows in green. If I click on the monitor name, I expected to see a real time view of the camera but nothing shows.
My zone config shows no camera image either.

I tried turning debug up to 9, and things seem to be 'processing' just fine.

I have ffmpeg installed

Code: Select all

root@myhost
# ffmpeg -version
FFmpeg version 0.6, Copyright (c) 2000-2010 the FFmpeg developers
  built on Oct 28 2010 15:30:42 with gcc 4.4.4
  configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --enable-static --enable-shared --cc=i686-pc-linux-gnu-gcc --disable-debug --disable-network --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --disable-indev=v4l --disable-indev=jack --enable-x11grab --enable-pthreads --enable-libfaad --enable-libopenjpeg --disable-vdpau --disable-vaapi --disable-altivec --cpu=core2 --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-avfilter-lavf --disable-stripping --enable-hardcoded-tables --disable-doc
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
root@myhost
# 
Syslog output is

Code: Select all

Nov 26 13:38:36 pearcely zmpkg[16657]: INF [Command: start]
Nov 26 13:38:36 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/bin/true
Nov 26 13:38:36 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:36 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmdc.pl check
Nov 26 13:38:36 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:36 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmfix
Nov 26 13:38:36 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:36 pearcely zmfix[16670]: INF [New Debug Level = 0, New Debug Log = /var/log/zoneminder/zm_debug.log.16670]
Nov 26 13:38:36 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmdc.pl startup
Nov 26 13:38:36 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:37 pearcely zmdc[16675]: INF [Server starting at 10/11/26 13:38:37]
Nov 26 13:38:40 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmdc.pl start zmc -d /dev/video0
Nov 26 13:38:40 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:40 pearcely zmdc[16675]: INF ['zmc -d /dev/video0' starting at 10/11/26 13:38:40, pid = 16699]
Nov 26 13:38:40 pearcely zmdc[16699]: INF ['zmc -d /dev/video0' started at 10/11/26 13:38:40]
Nov 26 13:38:40 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmdc.pl start zmfilter.pl
Nov 26 13:38:40 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: INF [Debug Level = 0, Debug Log = <none>]
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: INF [New Debug Level = 0, New Debug Log = /var/log/zoneminder/zm_debug.log.16699]
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: INF [Starting Capture]
Nov 26 13:38:40 pearcely kernel: [1217555.520629] uhci_hcd 0000:00:1d.2: reserve dev 13 ep81-ISO, period 1, phase 0, 807 us
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: WAR [Contrast control is not suppported]
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: WAR [Brightness control is not suppported]
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: INF [Brightness 1 0]
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: WAR [Hue control is not suppported]
Nov 26 13:38:40 pearcely zmc_dvideo0[16699]: WAR [Saturation control is not suppported]
Nov 26 13:38:40 pearcely zmdc[16675]: INF ['zmfilter.pl' starting at 10/11/26 13:38:40, pid = 16705]
Nov 26 13:38:40 pearcely zmdc[16705]: INF ['zmfilter.pl' started at 10/11/26 13:38:40]
Nov 26 13:38:40 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmdc.pl start zmaudit.pl -c
Nov 26 13:38:40 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:40 pearcely zmdc[16675]: INF ['zmaudit.pl -c' starting at 10/11/26 13:38:40, pid = 16710]
Nov 26 13:38:40 pearcely zmdc[16710]: INF ['zmaudit.pl -c' started at 10/11/26 13:38:40]
Nov 26 13:38:40 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmdc.pl start zmwatch.pl
Nov 26 13:38:40 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:40 pearcely zmfilter[16705]: INF [Scanning for events]
Nov 26 13:38:40 pearcely zmdc[16675]: INF ['zmwatch.pl' starting at 10/11/26 13:38:40, pid = 16716]
Nov 26 13:38:40 pearcely zmdc[16716]: INF ['zmwatch.pl' started at 10/11/26 13:38:40]
Nov 26 13:38:40 pearcely sudo:     root : TTY=pts/0 ; PWD=/var/www/zoneminder/htdocs ; USER=apache ; COMMAND=/usr/bin/zmdc.pl start zmupdate.pl -c
Nov 26 13:38:40 pearcely sudo: pam_unix(sudo:session): session opened for user apache by (uid=0)
Nov 26 13:38:40 pearcely zmwatch[16716]: INF [Watchdog starting]
Nov 26 13:38:40 pearcely zmwatch[16716]: INF [Watchdog pausing for 30 seconds]
Nov 26 13:38:40 pearcely zmdc[16675]: INF ['zmupdate.pl -c' starting at 10/11/26 13:38:40, pid = 16722]
Nov 26 13:38:40 pearcely zmdc[16722]: INF ['zmupdate.pl -c' started at 10/11/26 13:38:40]
/var/log/zoneminder logs are as good as empty.

My Configuration, from MySQL is as follows

Code: Select all

name 	value
ZM_LANG_DEFAULT 	en_us
ZM_OPT_USE_AUTH 	1
ZM_AUTH_TYPE 	builtin
ZM_AUTH_RELAY 	hashed
ZM_AUTH_HASH_SECRET 	650307
ZM_AUTH_HASH_IPS 	1
ZM_AUTH_HASH_LOGINS 	0
ZM_DIR_EVENTS 	events
ZM_USE_DEEP_STORAGE 	0
ZM_DIR_IMAGES 	images
ZM_DIR_SOUNDS 	sounds
ZM_PATH_ZMS 	/cgi-bin/nph-zms
ZM_CAN_STREAM 	auto
ZM_STREAM_METHOD 	jpeg
ZM_COLOUR_JPEG_FILES 	1
ZM_ADD_JPEG_COMMENTS 	0
ZM_JPEG_FILE_QUALITY 	70
ZM_JPEG_ALARM_FILE_QUALITY 	80
ZM_JPEG_IMAGE_QUALITY 	70
ZM_JPEG_STREAM_QUALITY 	70
ZM_MPEG_TIMED_FRAMES 	1
ZM_MPEG_LIVE_FORMAT 	swf
ZM_MPEG_REPLAY_FORMAT 	swf
ZM_RAND_STREAM 	1
ZM_OPT_CAMBOZOLA 	0
ZM_PATH_CAMBOZOLA 	cambozola.jar
ZM_RELOAD_CAMBOZOLA 	0
ZM_TIMESTAMP_ON_CAPTURE 	1
ZM_LOCAL_BGR_INVERT 	1
ZM_Y_IMAGE_DELTAS 	1
Anything else I need to supply to assist in diagnosing this?
Any assistance is appreciated.[/code]
Last edited by lyallp on Thu Dec 02, 2010 3:05 am, edited 1 time in total.
...Lyall
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Post by lyallp »

I found that looking in my apache error log, when I try opening the monitor window, I am seeing the following (only showing 1 of the date() warnings, lots of them appear)

Code: Select all

[Fri Nov 26 15:09:25 2010] [error] [client 16.145.135.8] PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Australia/Adelaide' for 'CST/10.0/DST' instead in /var/www/zoneminder/htdocs/skins/classic/views/console.php on line 188, referer: http://myhost/zoneminder/index.php

[Fri Nov 26 15:09:25 2010] [error] [client 16.145.135.8] PHP Warning:  strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Australia/Adelaide' for 'CST/10.0/DST' instead in /var/www/zoneminder/htdocs/includes/functions.php on line 1412, referer: http://myhost/zoneminder/index.php

[Fri Nov 26 15:27:36 2010] [error] [client 16.145.135.8] PHP Deprecated:  Function ereg() is deprecated in /var/www/zoneminder/htdocs/includes/functions.php on line 828, referer: http://myhost/zoneminder/index.php

[Fri Nov 26 15:27:42 2010] [error] [client 16.145.135.8] socket_sendto( /var/run/zm/zms-791698s.sock ) failed: No such file or directory, referer: http://myhost/zoneminder/index.php?view=watch&mid=3

[Fri Nov 26 15:27:42 2010] [error] [client 16.145.135.8] array (\n  0 => \n  array (\n    'file' => '/var/www/zoneminder/htdocs/ajax/stream.php',\n    'line' => 55,\n    'function' => 'ajaxError',\n    'args' => \n    array (\n      0 => 'socket_sendto( /var/run/zm/zms-791698s.sock ) failed: No such file or directory',\n    ),\n  ),\n  1 => \n  array (\n    'file' => '/var/www/zoneminder/htdocs/index.php',\n    'line' => 116,\n    'args' => \n    array (\n      0 => '/var/www/zoneminder/htdocs/ajax/stream.php',\n    ),\n    'function' => 'require_once',\n  ),\n), referer: http://myhost/zoneminder/index.php?view=watch&mid=3

...Lyall
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Post by lyallp »

Slight improvement.
I now see a green square with about the top 5% showing 'static' that changes for each screen update.
I can show the webcam using the LD_PRELOAD with mplayer, and assume that the same preload will be required by zoneminder.
I have tried assorted means to apply this, including
  • * exporting LD_PRELOAD prior to executing the startup script
    * making LD_PRELOAD global to the system
    * hacking the zoneminder script itself to hard code it
Nothing works.

I did notice in my system log, that I had not created my swap image directory. This I created and I can see it being populated by the images of the green boxes with static.

Suggestions would be welcomed.
...Lyall
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Post by lyallp »

Solved.

I had to put

Code: Select all

LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so; export LD_PRELOAD
in my apache2 startup.

Now, I can see the webcam stream!

I had tried simply putting it in the zoneminder service startup script, to no avail.
...Lyall
hornetster
Posts: 15
Joined: Mon Nov 01, 2010 10:00 am
Location: Redlands, Oz

Post by hornetster »

Hi lyallp,
Just ran across this thread, as I am having the same issue.
I am assuming by apache2 startup, you mean /etc/init.d/apache2??
Is there anywhere in particular that has to go? I have just put it in here:
....
# See the output of "help ulimit" in the bash, or "man 1 ulimit".
#
test -s /etc/rc.status && . /etc/rc.status && rc_reset

# Added below
LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so; export LD_PRELOAD
# Added above

. /usr/share/$pname/load_configuration
export ${!APACHE_*}

httpd_conf=${APACHE_HTTPD_CONF:-$sysconfdir/httpd.conf}
....

Any other clues?
Thanks, John.
hornetster
Posts: 15
Joined: Mon Nov 01, 2010 10:00 am
Location: Redlands, Oz

Post by hornetster »

Think I've sorted it. had copied your fix, but then realized that it should actually be: LD_PRELOAD=/usr/lib64/libv4l/v4l1compat.so
Also, was referencing the device incorrectly - just had /dev/video, not /dev/video0...
Now just have to figure out how everything else works!!

Thanks,
John.
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Post by lyallp »

I am not on the computer on which I did this, but anywhere such that the apache environment contains the preload.

Also, I found I could not have zoneminder start automatically, I had to start it using the web page.

Still, I have it at my office as a proof of concept and it seems to work quite well.

Edit: I checked my work computer, I use Gentoo, and that has a file /etc/conf.d/apache2, which is sourced by the startup system.
Placing it in the /etc/init.d/apache2 startup file would be just as good, but liable to be lost on updates/upgrades.
...Lyall
Locked