title: Convert YUY2 (YUYV) to png from the command line
body: <p>I'm using <code>v4l2-ctl(1)</code> to capture an image from my webcam and I'm trying to <code>convert(1)</code> the raw format into a png.</p>
  <p>Here are the commands I ran.</p>
  <pre><code># This is the format my camera outputs.
  $ v4l2-ctl --device /dev/video0 --list-formats-ext
  ioctl: VIDIOC_ENUM_FMT
          Type: Video Capture
  
          [1]: 'YUYV' (YUYV 4:2:2)
                  Size: Discrete 640x480
                          Interval: Discrete 0.033s (30.000 fps)
  
  # This is how I'm capturing an image.
  $ v4l2-ctl --device /dev/video0 --set-fmt-video=width=640,height=480,pixelformat=YUYV
  $ v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=1
  
  # This is how I tried to convert. (This didn't work.)
  $ convert -size 640x480 -depth 8 -sampling-factor 4:2:2 -colorspace YUV yuv:frame.raw frame.png
  </code></pre>
  <p>This gives me a green and pink png.</p>
  <p>I also tried to display the raw image with this command.</p>
  <pre><code>$ display -size 640x480 -depth 8 -sampling-factor 4:2:2 -colorspace yuv yuv:frame.raw
  </code></pre>
  <p>The image looks a little better there, but there is a blue filter over the entire image.</p>
  <p>Here is a sample image from my webcam.
  <a href="http://s000.tinyupload.com/?file_id=36420855739943963603" rel="nofollow noreferrer">http://s000.tinyupload.com/?file_id=36420855739943963603</a></p>