/// <summary> /// Restore the camera's last settings from the registry /// </summary> private void RestoreCameraSettings() { object setting; if (cg is VideoCaptureGraph) { VideoCaptureGraph vcg = (VideoCaptureGraph)cg; if (vcg.VideoSource.HasVideoStandards) { if ((setting = AVReg.ReadValue(DeviceKey(), AVReg.VideoStandardIndex)) != null) { vcg.VideoSource.VideoStandardIndex = (int)setting; } } } else if (cg is DVCaptureGraph) { DVCaptureGraph dvcg = (DVCaptureGraph)cg; if (dvcg.VideoSource.HasVideoStandards) { if ((setting = AVReg.ReadValue(DeviceKey(), AVReg.VideoStandardIndex)) != null) { dvcg.VideoSource.VideoStandardIndex = (int)setting; } } } if (cg.Source.HasPhysConns) { if ((setting = AVReg.ReadValue(DeviceKey(), AVReg.PhysicalConnectorIndex)) != null) { cg.Source.PhysicalConnectorIndex = (int)setting; } } }
protected override void UpdateCurrentSettings() { _AMMediaType mt; object fb; ac.CaptureGraph.Source.GetMediaType(out mt, out fb); if (fb is WAVEFORMATEX) { WAVEFORMATEX wfe = (WAVEFORMATEX)fb; lblCurrentSettings.Text = string.Format(CultureInfo.CurrentCulture, Strings.AudioFormatSettings, TAB, wfe.Channels, wfe.BitsPerSample, wfe.SamplesPerSec, wfe.AvgBytesPerSec * 8 / 1000); } else if (fb is DVINFO) { DVCaptureGraph dvcg = ac.CaptureGraph as DVCaptureGraph; if (dvcg != null) { dvcg.GetAudioMediaType(out mt, out fb); if (fb is WAVEFORMATEX) { WAVEFORMATEX wfe = (WAVEFORMATEX)fb; lblCurrentSettings.Text = string.Format(CultureInfo.CurrentCulture, Strings.AudioFormatSettings, TAB, wfe.Channels, wfe.BitsPerSample, wfe.SamplesPerSec, wfe.AvgBytesPerSec * 8 / 1000); } } } else { lblCurrentSettings.Text = "Unknown"; } }
/// <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; }
/// <summary> /// Creates the actual FilgraphManager with the chosen camera /// </summary> private void CreateVideoGraph(FilterInfo fi) { Debug.Assert(cg == null); // Create the graph, which creates the source filter if (DVSource.IsDVSourceWithAudio(fi)) { cg = DVCaptureGraph.GetInstance(fi); Log(((DVCaptureGraph)cg).VideoSource.Dump()); } else { cg = new VideoCaptureGraph(fi); Log(((VideoCaptureGraph)cg).VideoSource.Dump()); } }
/// <summary> /// Save the camera's current settings to the registry /// </summary> public void SaveCameraSettings() { if (cg is VideoCaptureGraph) { VideoCaptureGraph vcg = (VideoCaptureGraph)cg; if (vcg.VideoSource.HasVideoStandards) { AVReg.WriteValue(DeviceKey(), AVReg.VideoStandardIndex, vcg.VideoSource.VideoStandardIndex); } } else if (cg is DVCaptureGraph) { DVCaptureGraph dvcg = (DVCaptureGraph)cg; if (dvcg.VideoSource.HasVideoStandards) //Always false for DV devices? { AVReg.WriteValue(DeviceKey(), AVReg.VideoStandardIndex, dvcg.VideoSource.VideoStandardIndex); } } SaveDeviceSettings(); }
private void UpdateVideoSettings() { _AMMediaType mt; object formatBlock; vc.CaptureGraph.Source.GetMediaType(out mt, out formatBlock); VIDEOINFOHEADER vih = new VIDEOINFOHEADER(); bool unknownFormat = false; if (formatBlock is VIDEOINFOHEADER) { vih = (VIDEOINFOHEADER)formatBlock; } else if (formatBlock is DVINFO) { DVCaptureGraph dvcg = vc.CaptureGraph as DVCaptureGraph; if (dvcg != null) { dvcg.GetVideoMediaType(out mt, out formatBlock); if (formatBlock is VIDEOINFOHEADER) { vih = (VIDEOINFOHEADER)formatBlock; } else { unknownFormat = true; } } else { unknownFormat = true; } } else { unknownFormat = true; } if (unknownFormat) { lblCurrentSettings.Text += "Unknown Video Format"; return; } BITMAPINFOHEADER bmih = vih.BitmapInfo; if (lblCurrentSettings.Text == String.Empty) { lblCurrentSettings.Text = Strings.VideoStream; } else { lblCurrentSettings.Text += "\r\n\r\n" + Strings.VideoStream; } lblCurrentSettings.Text += string.Format(CultureInfo.CurrentCulture, "\r\n" + Strings.AdvancedVideoSettingsStatus, TAB, bmih.Width, bmih.Height, vih.FrameRate.ToString("F2", CultureInfo.InvariantCulture), MediaType.SubType.GuidToString(mt.subtype), bmih.BitCount, (uint)(bmih.Width * bmih.Height * bmih.BitCount * vih.FrameRate) / 1000); }