43

I am well aware that there is "exactly" the same question already asked, but it seems the user that posted the question initially never took an interest in the question, and the answers all were for windows systems.

I want to take a picture with the webcam every N time units and store it to /tmp/somefolder/ for further use with other tools and only keep the last M images.

The main problem is taking the picture to start with, the rest i would have pretty much covered, would be glad for any suggestions. OS: Ubuntu 10.04 x86_64 Webcam: MS LifeCam VX2000 and/or Logitech C210 (both working with cheese)

Community
  • 1
  • 1
Stoppal
  • 683
  • 1
  • 5
  • 15
  • Since your question appears to be about how to take a snapshot from the command-line under Ubuntu and not about how to script this, I suggest migrating this question to http://askubuntu.com/ , where you're more likely to get a satisfactory answer. – johnsyweb Feb 22 '12 at 08:42
  • I believe this has been covered on sister sites, so I'm closing this as off topic (and the other one, that somehow fell through the cracks since 2009). I'm glad you were able to get an answer, though :) – Tim Post Feb 22 '12 at 08:53

1 Answers1

54

Install mplayer

mplayer -vo png -frames 1 tv://
Alessandro Pezzato
  • 8,603
  • 5
  • 45
  • 63
  • 14
    After a little browsing on the different video players cli functions i found [this post](http://forum.videolan.org/viewtopic.php?f=13&t=89461) quite useful. The following command does exactly what i need: `vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path /home/stoppal/test --scene-prefix image_prefix --scene-format png vlc://quit --run-time=1` This command is quite human readable, takes one picture and stores it to the specified folder. – Stoppal Feb 22 '12 at 10:11
  • @Stoppal: That works exactly as reqd. Do you know any software that i can use to view the feed from my cam? – IcyFlame Jun 19 '13 at 09:20
  • 2
    what do you mean for *feed*? – Alessandro Pezzato Jun 19 '13 at 11:03
  • 2
    @Stoppal Following https://wiki.videolan.org/Documentation:Modules/v4l2#Video_input, I added `-V dummy -A dummy` to suppress video and audio output too. – gatoatigrado Sep 02 '13 at 20:07
  • I use `guvcview -s 800x600 -c 5 -m 100000 -i /path/to/output.jpg` where `-c` is the time in secends to wait between each picture, `-m` is the maximum number of pictures to take and `-s` is for the image dimensions. – erik Feb 07 '14 at 07:30
  • With mplayer command my photo is green. Anyone know how solve it? – jedi Jul 30 '14 at 23:22
  • @jedi try `mplayer tv:// -vo x11`, what do you see? – Alessandro Pezzato Jul 31 '14 at 04:37
  • @alessandro-pezzato: now works with the first command. maybe yesterday my cam was crazy for an error with glx when i tryed to use cheese – jedi Aug 01 '14 at 11:06
  • Both the original command and the vlc command just opened the app with the GUI and was taking many images without ever quitting. I ended up wrapping this command with `timeout 10`. [timeout](https://www.howtoforge.com/linux-timeout-command/) This worked: `timeout 10 vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path /home/stoppal/test --scene-prefix image_prefix --scene-format png vlc://quit --run-time=1` – urirot Feb 04 '21 at 16:32
  • I get "FATAL: Cannot initialize video driver." – Valter Ekholm Apr 02 '21 at 20:45
  • With -frames 1, the picture is always green, thus I use -frames 2 and delete the first picture. – Christoph Oct 18 '21 at 06:09