Some of the images I get from the Webcam using fswebcam are not displaying properly.


enter image description hereenter image description here

I got these images using the following command:

sudo fswebcam -r 640x480 test.jpg

I'm having the same issues with 320x240 resolution.


I've also tried skipping some frames before getting the picture:

  sudo fswebcam -r 640x480 -S 20 test.jpg

And, although I am getting less malformed images I'm still getting a lot (1 every 6-7 taken)

What can I do to solve this output problem?

  • would you mind to elaborate, how did you get the first and the second images, and what result you're looking for?
    – lenik
    Jul 7 '13 at 3:59
  • @lenik I got both results by using the same command, same specifications. I would like to always get a complete and good drawn picture like the first one.
    – zurfyx
    Jul 7 '13 at 21:56
  • I get similar issues with the Pi Camera module. Weird alignment problems. But I use ffmpeg and raspicam/raspistill. Not sure if related. How often does that happen to you?
    – Piotr Kula
    Jul 11 '13 at 14:42
  • @ppumkin Normally every 10-15 photos. Sometimes every 4-5.
    – zurfyx
    Jul 11 '13 at 14:47
  • Even though old question, still top in google.. Some times this is also a case of taking two many shots one after the other.. Slow down your frame rate.. But as in try doing something like 1 frame every 5 seconds and see if it appears then decrease the timer until you find the limit.. This is most likely a power draw issue.
    – Angry 84
    Dec 11 '16 at 5:49

I was having a similar issue as well. To get rid of those malformed images try:

sudo fswebcam -r 640x480 test.jpg -S 2

. The -S instructs it to skip a number of frames,in this case two. Hope it helps!

  • I tried, but still having the same problem with -S 20. Not as much as without -S (as I was getting constant malformed) but still getting every 5-6 photos.
    – zurfyx
    Jul 14 '13 at 9:26

I am onto my second camera On my first cam I had constant broken images. They are proper files but the picture is distorted.

I am now using a Logitech c270 that i got cheap of an auction site. Initially i had some color issues because i over compensated for the previous camera.

Here is my current line

 fswebcam -d /dev/video0  -S 2 -s brightness=60% -s Contrast=15%  -s Gamma=50%  -p YUYV -r 1280x720 --jpeg 80 -s Sharpness=40% -s Saturation=15%   --title "New Zealand - Wellington - Tawa"  $DIR/$filename
  • 1
    This seems a comment about your own experiences not an answer. Do you have a solution for the problem from your experience? Oct 20 '13 at 14:16

Found the solution! After tweaking the motion.conf file for a couple of minutes I've came to this conclusion: NEVER use higher framerates than 30 for a webcam (30fps is more than enough to work on any decent camera, so higher fps just stresses the camera beyond its limits ). In conf. file (after installing motion, type in Cli: sudo nano /etc/motion/motion.conf), set the "framerate" to 30 and "webcam_maxrate" to 30. Problem solved!
P.S.-don't use higher resolutions than 640 x 480 !


@darius solution does not help at all, as it seems to be related to motion, not directly to fswebcam.

For me, using a really low framerate, and skipping frames, seems to have helped a bit (not much). Something like

fswebcam --fps 15 -S 8 -r 640x480 $DATE.jpg
  • Welcome to rpi@stackexchange. This should probably be a comment, rather than an answer on its own.
    – Bex
    Mar 23 '16 at 8:17
  • Should it? I gave a solution Mar 24 '16 at 22:26

Problem with images?

You must generate images into a directory example one image per second

/cam 20160729154102.jpg 29-Jul-2016 18:40 132K
20160729154202.jpg 29-Jul-2016 18:41 132K

and view the one generate other and delete the first

Ex: /cam.jpg in other directory

The image to view: /cam.jpg The directory with the images: /cam

When view the image, the same in totally downloading (cm.jpg) otherwise you view the last image in some time that is downloading and some times have an error.

**PHP script (execute with cron every minute)**

<meta http-equiv="refresh" content="60">
date_default_timezone_set("America/Argentina/Buenos_Aires" ) ;
<!--<meta http-equiv="refresh" content="60">-->
    $dirint = dir($directory);
    while (($archivo = $dirint->read()) !== false)
      $archivos[$archivo] = $archivo; 

 rsort ($archivos);

 foreach ($archivos as $archivo) {   





 foreach ($archivos as $archivo) {      


                       $alto =400;                 

                            $salida = '<img src="'.$file.'">';  

                               if (!copy($file, $newfile)) {
                                echo "failed to copy<br>";
                               if (!copy($file,'capturas/'. $archivo)) {
                                echo "failed to copy<br>";



    <div align="center">
    echo $salida;   


see the sample running: http://diarionecochea.mobi/camarita/camara.html


I was getting only a dark picture (no detail at all) when I ran fswebcam image.jpg. However, I got a good picture when I ran

fswebcam --fps 15 -S 8 image.jpg

as suggested by Alexandre Strube in the answers. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.