title: How to change mjpeg to yuyv422 from a webcam to a v4l2loopback?
body: <p>Backstory: One livestreaming site I use isn't smart enough to detect the capabilities of my webcam (Logitech Brio, 4k), and instead just uses the default frames per second settings, which is 5fps.</p>
  <p><em><strong>(full solution walk-through in the answer)</strong></em></p>
  <p>The best solution I could think of (besides changing livestream providers) was to create a loopback virtual webcam using v4l2loopback that I could force to have the exact settings I wanted to use on that livestream site.</p>
  <p>For the brio, the higher frame rates come with mjpeg, not the default yuyv.</p>
  <p><strong>Problem 1:</strong></p>
  <p>I could easily read mjpeg, but unfortunately kept banging my head against the wall because v4l2loopback evidently only wanted yuyv.</p>
  <p>I tried things like:</p>
  <pre><code>ffmpeg -f v4l2              \
         -input_format mjpeg  \
         -framerate 30        \
         -video_size 1280x720 \
         -i /dev/video0       \
         -vcodec copy         \
         -f v4l2 /dev/video6
  </code></pre>
  <p>and</p>
  <pre><code>ffmpeg -f v4l2              \
         -input_format mjpeg  \
         -framerate 30        \
         -video_size 1280x720 \
         -i /dev/video0       \
         -vcodec yuyv422      \ # this line changed (even tried &quot;copy&quot;)
         -f v4l2 /dev/video6
  </code></pre>
  <p>But they wouldn't work.  I got errors like:</p>
  <blockquote>
  <p>Unknown V4L2 pixel format equivalent for yuvj422p</p>
  </blockquote>
  <p>and</p>
  <blockquote>
  <p>...deprecated pixel format used, make sure you did set range correctly...</p>
  <p>...V4L2 output device supports only a single raw video stream...</p>
  </blockquote>
  <p>Eventually I got this to work:</p>
  <pre><code>ffmpeg -f v4l2              \
         -input_format mjpeg  \
         -framerate 30        \
         -video_size 1280x720 \
         -i /dev/video0       \
         -pix_fmt yuyv422     \ # The winning entry
         -f v4l2 /dev/video6
  </code></pre>
  <p><strong>Problem 2</strong></p>
  <p>The next problem was getting chrome to see the virtual webcam.  It worked correctly with guvcview, and on firefox I could use webcam testing sites and it would pick the virtual camera up without a problem.</p>
  <p>Turns out google, in it's overly-protective nature (while it's siphoning off all our data, btw), doesn't want to use webcams that can be read and written to.</p>
  <p>So when starting v4l2loopback you have to tell it to announce that it's &quot;read only&quot; to consumers like chrome.</p>
  <p>Here's the exact modprobe I use that works:</p>
  <pre><code>sudo modprobe v4l2loopback devices=1 exclusive_caps=1
  </code></pre>