title: Video Capture output always in 320x240 despite changing resolution
body: <p>Ok I have been at this for 2 days and need help with this last part.</p>
  
  <p>I have a Microsoft LifeCam Cinema camera and I use the .NET DirectShowLib to capture the video stream. Well actually I use WPFMediaKit, but I am in the source code of that dealing directly with the direct show library now.</p>
  
  <p>What I have working is:
  - View the video output of the camera
  - Record the video output of the camera in ASF or AVI (the only 2 MediaType's supported with ICaptureGraphBuilder2)</p>
  
  <p>The problem is: I can save it as a .avi. This works fine and at a resolution of 1280x720 but it saves the file in RAW output. Meaning it is about 50-60MB per second. Way too high.</p>
  
  <p>Or I can switch it to .asf and it outputs a WMV, but when I do this the capture and the output both go to resolution 320x240.</p>
  
  <p>In WPFMediaKit there is a function I changed because apparently with Microsoft LifeCam Cinema cameras a lot of people have this problem. So instead of creating or changing the AMMediaType you iterate through and then use that to call SetFormat. </p>
  
  <pre><code>        ///* Make the VIDEOINFOHEADER 'readable' */
          var videoInfo = new VideoInfoHeader();
  
          int iCount = 0, iSize = 0;
          videoStreamConfig.GetNumberOfCapabilities(out iCount, out iSize);
  
          IntPtr TaskMemPointer = Marshal.AllocCoTaskMem(iSize);
  
  
          AMMediaType pmtConfig = null;
          for (int iFormat = 0; iFormat &lt; iCount; iFormat++)
          {
              IntPtr ptr = IntPtr.Zero;
  
              videoStreamConfig.GetStreamCaps(iFormat, out pmtConfig, TaskMemPointer);
  
              videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(pmtConfig.formatPtr, typeof(VideoInfoHeader));
  
              if (videoInfo.BmiHeader.Width == DesiredWidth &amp;&amp; videoInfo.BmiHeader.Height == DesiredHeight)
              {
  
                  ///* Setup the VIDEOINFOHEADER with the parameters we want */
                  videoInfo.AvgTimePerFrame = DSHOW_ONE_SECOND_UNIT / FPS;
  
                  if (mediaSubType != Guid.Empty)
                  {
                      int fourCC = 0;
                      byte[] b = mediaSubType.ToByteArray();
                      fourCC = b[0];
                      fourCC |= b[1] &lt;&lt; 8;
                      fourCC |= b[2] &lt;&lt; 16;
                      fourCC |= b[3] &lt;&lt; 24;
  
                      videoInfo.BmiHeader.Compression = fourCC;
                     // pmtConfig.subType = mediaSubType;
  
                  }
  
                  /* Copy the data back to unmanaged memory */
                  Marshal.StructureToPtr(videoInfo, pmtConfig.formatPtr, true);
  
                  hr = videoStreamConfig.SetFormat(pmtConfig);
                  break;
              }
  
          }
  
          /* Free memory */
          Marshal.FreeCoTaskMem(TaskMemPointer);
          DsUtils.FreeAMMediaType(pmtConfig);
  
          if (hr &lt; 0)
              return false;
  
          return true;
  </code></pre>
  
  <p>When that was implemented I could finally view the captured video as 1280x720 as long as I set the SetOutputFilename to a MediaType.Avi.</p>
  
  <p>If I set it to a MediaType.Asf it goes to 320x240 and the output is the same.</p>
  
  <p>Or the AVI works and outputs in the correct format but does so in RAW video, hence a very large file size. I have attempted to add a compressor to the graph but with no luck, this is far out of my experience.</p>
  
  <p>I am looking for 1 of 2 answers.</p>
  
  <ol>
  <li>Recording the ASF at 1280x720</li>
  <li>Adding a compressor to the graph so that the filesize of my outputted AVI is small.</li>
  </ol>