title: How to use gstreamer to save webcam video to file?
body: <p><a href="https://stackoverflow.com/questions/21034131/x264-error-message-when-capturing-video">I've been trying to get emgu to save same webcam video to file</a></p>
  
  <p>The problem is opencv only ssupports avi, and avi does not seem to suit a format like X264 very well.</p>
  
  <p>Could I use Gstreamer to do this for me in C?</p>
  
  <p>It would be good if I could choose the file format and container type too. It would be good if I could use a format like schrodinger dirac. </p>
  
  <p>I'm new to GStreamer so I'm not quite sure if I'm on the right track here.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've managed to capture the webcam video using </p>
  
  <blockquote>
    <p>gst-launch-0.10 ksvideosrc ! autovideosink</p>
  </blockquote>
  
  <p>Now how to transcode this to a format like H264 or dirac ...?</p>
  
  <p><strong>EDIT</strong></p>
  
  <blockquote>
    <p>gst-launch-0.10  ksvideosrc num-buffers=10 ! decodebin2 !
    ffmpegcolorspace ! x264enc ! matroskamux ! filesink
    location=video.mkv</p>
  </blockquote>
  
  <p>This seems to create a file, but VLC player can't read it.</p>