private void btnApplyCompression_Click(object sender, System.EventArgs e) { try { frmAV.RenderAndRunVideo(vcg, false); // Create the custom settings and set them VideoCompressorQualityInfo vcqi = VideoCompressor.DefaultQualityInfo; vcqi.BitRate = (uint)BitRateValue; vcqi.KeyFrameRate = KeyFrameRateValue; vcg.VideoCompressor.QualityInfo = vcqi; frmAV.RenderAndRunVideo(vcg); // Save them vc.SaveVideoCompressorSettings(); vc.RegCustomCompression = true; UpdateCurrentSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
public void SaveVideoCompressorSettings() { VideoCompressorQualityInfo vcqi = vcg.VideoCompressor.QualityInfo; // Cast to int, otherwise it gets stored as a string AVReg.WriteValue(DeviceKey(), AVReg.CompressorBitRate, (int)vcqi.BitRate); AVReg.WriteValue(DeviceKey(), AVReg.CompressorKeyFrameRate, vcqi.KeyFrameRate); }
private void UpdateCustomCompressionFields() { if (vcg.VideoCompressor != null) { VideoCompressorQualityInfo vcqi = vcg.VideoCompressor.QualityInfo; BitRateValue = (int)vcqi.BitRate; KeyFrameRateValue = vcqi.KeyFrameRate; } }
/// <summary> /// Restore the video compressor's last settings from the registry /// </summary> private void RestoreVideoCompressorSettings() { VideoCompressorQualityInfo vcqi = DefaultQualityInfo(); vcqi.KeyFrameRate = (int)AVReg.ReadValue(DeviceKey(), AVReg.CompressorKeyFrameRate); vcqi.BitRate = (uint)((int)AVReg.ReadValue(DeviceKey(), AVReg.CompressorBitRate)); vcg.VideoCompressor.QualityInfo = vcqi; }
private void UpdateCustomCompressionFields() { if (((IVideoCaptureGraph)vc.CaptureGraph).VideoCompressor != null) { VideoCompressorQualityInfo vcqi = ((IVideoCaptureGraph)vc.CaptureGraph).VideoCompressor.QualityInfo; BitRateValue = (int)vcqi.BitRate; KeyFrameRateValue = vcqi.KeyFrameRate; } }
/// <summary> /// By default, we use the WMVideo9 Encoder DMO, WMV1 media type /// /// We support 3 basic default bit rates for video /// 100 Kbps for video < 320 x 240 /// 300 Kbps for video >e; 320 x 240 && < 640 x 480 /// 1 Mbps for video >e; 640 x 480 /// </summary> private void DefaultVideoCompressorSettings() { // Read camera's current media type _AMMediaType mt; object fb; cg.Source.GetMediaType(out mt, out fb); int bmpRes = 640 * 480; if (fb is VIDEOINFOHEADER) { VIDEOINFOHEADER vih = (VIDEOINFOHEADER)fb; bmpRes = vih.BitmapInfo.Height * vih.BitmapInfo.Width; } else if (fb is DVINFO) { DVCaptureGraph dvcg = cg as DVCaptureGraph; if (dvcg != null) { dvcg.GetVideoMediaType(out mt, out fb); if (fb is VIDEOINFOHEADER) { VIDEOINFOHEADER vih = (VIDEOINFOHEADER)fb; bmpRes = vih.BitmapInfo.Height * vih.BitmapInfo.Width; } } } else { Debug.Fail(string.Format(CultureInfo.CurrentCulture, "We were expecting a DVINFO or VIDEOINFOHEADER format block, not a {0}", MediaType.FormatType.GuidToString(mt.formattype))); return; } // Construct the compressor settings VideoCompressorQualityInfo vcqi = DefaultQualityInfo(); if (bmpRes < 320 * 240) { vcqi.BitRate = 100000; } else if (bmpRes < 640 * 480) { vcqi.BitRate = 300000; } else { vcqi.BitRate = 1000000; } // Set the Video Compressor's Quality vcg.VideoCompressor.QualityInfo = vcqi; }
private void UpdateCompressorSettings() { if (((IVideoCaptureGraph)vc.CaptureGraph).VideoCompressor == null) { lblCurrentSettings.Text += string.Format(CultureInfo.CurrentCulture, "\r\n\r\n" + Strings.CompressorDisabled2, TAB); } else { VideoCompressor vcomp = ((IVideoCaptureGraph)vc.CaptureGraph).VideoCompressor; VideoCompressorQualityInfo vcqi = vcomp.QualityInfo; lblCurrentSettings.Text += string.Format(CultureInfo.CurrentCulture, "\r\n\r\n" + Strings.CompressorStatus, TAB, vcomp.FriendlyName, MediaType.SubType.GuidToString(vcqi.MediaSubType), vcqi.BitRate / 1000, KeyFrameRateString); } }
private void UpdateCompressorSettings() { if (vcg.Compressor == null) { lblCurrentSettings.Text += string.Format("\r\n\r\nCompressor \r\n{0}Disabled", TAB); } else { VideoCompressorQualityInfo vcqi = vcg.VideoCompressor.QualityInfo; lblCurrentSettings.Text += string.Format("\r\n\r\nCompressor" + "\r\n{0}Name: {1} \r\n{0}Media sub-type: {2} \r\n{0}Compressed bit rate: {3} Kbps" + "\r\n{0}{4}", TAB, vcg.Compressor.FriendlyName, MediaType.SubType.GuidToString(vcqi.MediaSubType), vcqi.BitRate / 1000, KeyFrameRateString); } }
/// <summary> /// By default, we use the WMVideo9 Encoder DMO, WMV1 media type /// /// We support 3 basic default bit rates for video /// 100 Kbps for video < 320 x 240 /// 300 Kbps for video >e; 320 x 240 && < 640 x 480 /// 1 Mbps for video >e; 640 x 480 /// </summary> private void DefaultVideoCompressorSettings() { // Read camera's current media type _AMMediaType mt; object fb; vcg.Source.GetMediaType(out mt, out fb); if (!(fb is VIDEOINFOHEADER)) { Debug.Fail("We were expecting a VIDEOINFOHEADER format block, not a " + MediaType.FormatType.GuidToString(mt.formattype)); return; } // Construct the compressor settings VideoCompressorQualityInfo vcqi = DefaultQualityInfo(); VIDEOINFOHEADER vih = (VIDEOINFOHEADER)fb; int bmpRes = vih.BitmapInfo.Height * vih.BitmapInfo.Width; if (bmpRes < 320 * 240) { vcqi.BitRate = 100000; } else if (bmpRes < 640 * 480) { vcqi.BitRate = 300000; } else { vcqi.BitRate = 1000000; } // Set the Video Compressor's Quality vcg.VideoCompressor.QualityInfo = vcqi; }