title: DirectShow VB.net can't change recording format
body: <p>I'm using direct show to try and capture a webcam stream in to my vb.net program. Heres the subroutine running which works:</p>
  
  <pre><code>Private Sub CaptureVideo()
              Dim hr As Integer = 0
              Dim sourceFilter As IBaseFilter = Nothing
              Try
                  GetInterfaces()
  
                  hr = Me.CaptureGraphBuilder.SetFiltergraph(Me.GraphBuilder)
                  Debug.WriteLine("Attach the filter graph to the capture graph : " &amp; DsError.GetErrorText(hr))
                  DsError.ThrowExceptionForHR(hr)
  
                  sourceFilter = FindCaptureDevice()
  
                  hr = Me.GraphBuilder.AddFilter(sourceFilter, "Video Capture")
                  Debug.WriteLine("Add capture filter to our graph : " &amp; DsError.GetErrorText(hr))
                  DsError.ThrowExceptionForHR(hr)
  
  
  
                  hr = Me.CaptureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, sourceFilter, Nothing, Nothing)
                  Debug.WriteLine("Render the preview pin on the video capture filter : " &amp; DsError.GetErrorText(hr))
                  DsError.ThrowExceptionForHR(hr)
  
  
                  Dim pSink As DirectShowLib.IFileSinkFilter = Nothing
                  Dim pMux As DirectShowLib.IBaseFilter = Nothing
                  hr = Me.CaptureGraphBuilder.SetOutputFileName(DirectShowLib.MediaSubType.Avi, "c:\video\myvid1.avi", pMux, pSink)
                  Debug.WriteLine("Set File : " &amp; DirectShowLib.DsError.GetErrorText(hr))
                  DirectShowLib.DsError.ThrowExceptionForHR(hr)
  
  
                  hr = Me.CaptureGraphBuilder.RenderStream(DirectShowLib.PinCategory.Capture, DirectShowLib.MediaType.Video, sourceFilter, Nothing, pMux)
                  Debug.WriteLine("Render the capture pin on the video capture filter : " &amp; DirectShowLib.DsError.GetErrorText(hr))
                  DirectShowLib.DsError.ThrowExceptionForHR(hr)
  
                  Marshal.ReleaseComObject(sourceFilter)
  
                  SetupVideoWindow()
  
                  rot = New DsROTEntry(Me.GraphBuilder)
  
                  hr = Me.MediaControl.Run()
                  Debug.WriteLine("Start previewing video data : " &amp; DsError.GetErrorText(hr))
                  DsError.ThrowExceptionForHR(hr)
  
                  Me.CurrentState = PlayState.Running
                  Debug.WriteLine("The currentstate : " &amp; Me.CurrentState.ToString)
  
              Catch ex As Exception
                  MessageBox.Show("An unrecoverable error has occurred.With error : " &amp; ex.ToString)
              End Try
          End Sub
  </code></pre>
  
  <p>However when I change the line:</p>
  
  <pre><code>hr = Me.CaptureGraphBuilder.SetOutputFileName(DirectShowLib.MediaSubType.Avi, "c:\video\myvid1.avi", pMux, pSink)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>hr = Me.CaptureGraphBuilder.SetOutputFileName(DirectShowLib.MediaSubType.Asf, "c:\video\myvid1.wmv", pMux, pSink)
  </code></pre>
  
  <p>I get a black screen and an error:</p>
  
  <p><img src="https://i.stack.imgur.com/9Klf1.jpg" alt="enter image description here"></p>
  
  <p>Basically i'm trying to record in wmv instead of uncompressed AVI (something like DiVX / xvid would be fine too)</p>
  
  <p>Thanks</p>