Taking picture from webcam gives black image

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
xinouch
New Cone
New Cone
Posts: 3
Joined: 25 Feb 2013 15:07

Taking picture from webcam gives black image

Postby xinouch » 25 Feb 2013 15:27

Hello !

I have two problems with VLC actually, that's why I didn't post in the OS specific threads (but it may be not the bes idea (?)):

- First
I want to take a picture from my webcam every X seconds. I tried the following comand on Linux:

Code: Select all

vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path /home/xinouch/cam --scene-prefix img --scene-format png vlc://quit --run-time=1
I found it there: http://pc-freak.net/blog/linux-webcam-p ... webcamera/
this should take a simple picture from my webcam (it's a beginning).

The problem is it the image result is a simple black image, whereas with VLC, I'm able to see me with my webcam or save what the webcam see in a video file. Moreover, when I execute this command, vlc launch (and it exits directly) and I have the time to see the picture taken in VLC which is clearly not black! Is the problem coming from the conversion?

- Second
I want to test this in windows to see if it works better or not. In windows the name of my webcam is "USB2.0 PC CAMERA" but I don't know how to call it in the command:

Code: Select all

vlc -I dummy v4l2://USB2.0 PC CAMERA
does not work (nor it does with quotes)

I use Debian Sid amd64 with VLC 2.0.5, windows 7 64 bits with VLC 2.0.5 and my webcam is the following: http://www.amazon.co.uk/eSecure-Microph ... B0041LK8NI

thank you for your help!

xinouch
New Cone
New Cone
Posts: 3
Joined: 25 Feb 2013 15:07

Re: Taking picture from webcam gives black image

Postby xinouch » 01 Mar 2013 16:30

OK, I know what were the problems, but I still have a SIMPLE problem (see below please to help me)

- First
My cam seems to be a bit long to start, so if I take the first picture, it is black. If I take a picture after a while (A or 2 seconds), it works!!! so, I just have to replace the runtime argument: --run-time=2

- Second
I want a command that works either on windows AND linux:

Code: Select all

vlc v4l2:// :v4l2-vdev="/dev/video0" :v4l2-adev="none" --dshow-size=640x480 -V dummy --intf=dummy --dummy-quiet --video-filter=scene --no-audio --scene-path=. --scene-format=png --scene-prefix=cam- --scene-replace --run-time=10 --scene-ratio=24 "dshow://" vlc://quit
On windows, I just have to replace "/dev/video0" by "USB2.0 PC CAMERA" and it works \o/

- Actual problem
When I run the last command, I take a picture each seconds for 10 seconds. The problem is: each pictures are saved in the same file (wtf!?) "cam-.png".
What I want to have is 10 files: "cam-XX.png" where XX is the number of the file. How to do it???

xinouch
New Cone
New Cone
Posts: 3
Joined: 25 Feb 2013 15:07

Re: Taking picture from webcam gives black image

Postby xinouch » 01 Mar 2013 20:14

finally, I succeed to do what I wanted in Linux with a loop. for windows, it should be the same... the scripts I used:

to take pictures (launch in a terminal, ctrl+C to stop the script)

Code: Select all

#!/bin/sh # As program uses vlc you need to have vlc properly configured and installed # as well as the webcam video be properly working (detected by Linux kernel) # licensed under GPLv3 - hip0 - xinouch # Path where to store taken snapshots STORE_PATH=/home/xinouch/cam # Device locatation of webcam many webcams have default device in /dev/video0 WEBCAM_DEV=/dev/video1 # Size of the pictures IMAGE_WIDTH=640 IMAGE_HEIGHT=480 # Time between 2 pictures Time=2 # Stored grabbed picture filename prefix FILE_NAME_PREF=cam- while (true) ; do vlc v4l2://$WEBCAM_DEV :v4l2-vdev="$WEBCAM_DEV" :v4l2-adev="none" :v4l2-width=$IMAGE_WIDTH :v4l2-height=$IMAGE_HEIGHT :v4l2-aspect-ratio=4\:3 -V dummy --intf=dummy --video-filter=scene --no-audio --scene-path=. --scene-format=png --scene-prefix=$FILE_NAME_PREF$(date +%d_%m_%H_%M_%S|sed -e 's/^ *//') --scene-replace --run-time=$Time --scene-ratio=24 vlc://quit done
this script do something pretty bad: it takes photos every 24 frames and write these successively in the same file, until $Time is reach. And it do it again on a new file...

NOTE: For windows, you certainly can do the same, but the vlc command in the loop will be:

Code: Select all

vlc v4l2:// :v4l2-vdev="USB2.0 PC CAMERA" :v4l2-adev="none" --dshow-size=640x480 -V dummy --intf=dummy --dummy-quiet --video-filter=scene --no-audio --scene-path=. --scene-format=png --scene-prefix=cam- --scene-replace --run-time=2 --scene-ratio=24 "dshow://" vlc://quit
The problem here is the name of the pictures because in windows, "date" don't print the seconds. so you maybe should increment a variable in the loop and add it to the --scene-prefix

The script to make a video from the pictures:

Code: Select all

#!/bin/bash # As program uses mencoder you need to have mencoder properly configured and installed # licensed under GPLv3 - Rieaden - xinouch # name of the video nomVideo=videoTest # Length (in seconds) dureeVideo=15 mencoder mf://*.png -mf w=640:h=360:fps=$(($(ls -l *.png | wc -l)/$dureeVideo)):type=png -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o $nomVideo.avi echo '' echo "vidéo de $dureeVideo secondes enregistrée dans $nomVideo.avi"


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 120 guests