I'm trying to take snapshots with my Pi3 + USB camera. I've tried a few different things, but all with different results. I've tried:
mplayer -vo jpeg -frames 1 tv://
And the output text is:
MPlayer2 2.0-728-g2c378c7-4build1 (C) 2000-2012 MPlayer Team Cannot open file '/home/jems/.mplayer/input.conf': No such file or directory Failed to open /home/jems/.mplayer/input.conf. Playing tv://. Detected file format: TV Selected driver: v4l2 name: Video 4 Linux 2 input author: Martin 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: UVC Camera (046d:0990) Capabilities: video capture streaming supported norms: inputs: 0 = Camera 1; Current input: 0 Current format: MJPEG tv.c: norm_from_string(pal): Bogus norm parameter, setting default. v4l2: ioctl enum norm failed: Inappropriate ioctl for device Error: Cannot set norm! Selected input hasn't got a tuner! v4l2: ioctl set mute failed: Invalid argument v4l2: ioctl query control failed: Invalid argument jpeg: Progressive JPEG disabled. jpeg: Baseline JPEG enabled. Opening video filter: [scale] [ass] auto-open Selected video codec: MJPEG (Motion JPEG) [libavcodec] Audio: no sound Starting playback... v4l2: select timeout [mjpeg @ 0x76186870]No JPEG data found in image Error while decoding frame! [mjpeg @ 0x76186870]No JPEG data found in image Error while decoding frame! v4l2: select timeout [mjpeg @ 0x76186870]No JPEG data found in image Error while decoding frame! [mjpeg @ 0x76186870]Changeing bps to 8 VIDEO: 640x480 15.000 fps 0.0 kbps ( 0.0 kB/s) [swscaler @ 0x7587a488]bicubic scaler, from yuv420p to rgb24 using C [swscaler @ 0x7587a488]No accelerated colorspace conversion found from yuv420p to rgb24. [swscaler @ 0x7587a488]using unscaled yuv420p -> rgb24 special converter VO: [jpeg] 640x480 => 640x480 RGB 24-bit jpeg: . - Output directory already exists and is writable. V: 0.0 4/ 4 ??% ??% ??,?% 0 0 v4l2: ioctl set mute failed: Invalid argument v4l2: 3 frames successfully processed, 0 frames dropped. Exiting... (End of file) $
It works, and creates and image, but the image color is all blue and red:
Also, if I try to run the command again, I get no image and the following output:
$ mplayer -vo jpeg -frames 1 tv:// MPlayer2 2.0-728-g2c378c7-4build1 (C) 2000-2012 MPlayer Team Cannot open file '/home/jems/.mplayer/input.conf': No such file or directory Failed to open /home/jems/.mplayer/input.conf. Playing tv://. Detected file format: TV Selected driver: v4l2 name: Video 4 Linux 2 input author: Martin 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: UVC Camera (046d:0990) Capabilities: video capture streaming supported norms: inputs: 0 = Camera 1; Current input: 0 Current format: MJPEG v4l2: ioctl set format failed: Input/output error v4l2: ioctl set mute failed: Invalid argument v4l2: 0 frames successfully processed, 0 frames dropped. Opening as detected format "TV" failed. Failed to recognize file format. Exiting... (End of file)
So I tried using ffmpeg, as follows:
ffmpeg -i /dev/video0 -vframes 1 output.png
Which created a smaller picture, but it worked:
However, I can only run either command once. If I try again, I get an error:
/dev/video0: Input/output error
And I have to reboot in order to take another picture.
Does anyone have a solution which works consistently? The first command I mentioned works well on my Linux Mint desktop every time, so I don't think there is a problem with my camera.
Thanks!