Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Show Preview in PictureBox?
    primarykey
    data
    text
    <p>my is too record video from webcam using DirectshowLib and c# but during video recoding video preview is also be shown so for this i have done following steps</p> <p>1.i got the available video device</p> <ol> <li><p>init. IFilterGrapth2 object by using <code>Graph = (IFilterGraph2)new FilterGraph();</code></p></li> <li><p>init. ICaptureGraphBuilder2 object by using <code>captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();</code></p></li> </ol> <p>4.filter grapth is set to ICaptureGraphBuilder2 object <code>captureGraph.SetFiltergraph(Graph);</code></p> <ol> <li>and then added soursefilterformoniker() and outputfilename()</li> </ol> <p>The full code is as below.it does not any error but it opens preview window separately;i want to show preview on picture box..</p> <p><strong>how to preview window in picturebox?</strong></p> <p>here is my full code</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DirectShowLib; using DirectShowLib.DMO; using System.Runtime.InteropServices; using System.Drawing.Drawing2D; using System.IO; namespace Cam_Recording_V1_directshow.net_ { public partial class Form1 : Form { string captureDeviceName = string.Empty; IFilterGraph2 Graph = null; IMediaControl m_mediaCtrl = null; public List&lt;DsDevice&gt; AvailableVideoInputDevices { get; private set; } IAMVideoProcAmp vpa; [DllImport("olepro32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] private static extern int OleCreatePropertyFrame(IntPtr hwndOwner, int x, int y, string lpszCaption, int cObjects, [In, MarshalAs(UnmanagedType.Interface)] ref object ppUnk, int cPages, IntPtr pPageClsID, int lcid, int dwReserved, IntPtr pvReserved); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { IBaseFilter capFilter = null; IBaseFilter asfWriter = null; IFileSinkFilter pTmpSink = null; ICaptureGraphBuilder2 captureGraph = null; object o; // //Get list of video devices // AvailableVideoInputDevices = new List&lt;DsDevice&gt;(); DsDevice[] videoInputDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); AvailableVideoInputDevices.AddRange(videoInputDevices); if (AvailableVideoInputDevices.Count &gt; 0) { // //init capture graph // Graph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); // //sets filter object from graph // captureGraph.SetFiltergraph(Graph); // //which device will use graph setting // Graph.AddSourceFilterForMoniker(AvailableVideoInputDevices.First().Mon, null, AvailableVideoInputDevices.First().Name, out capFilter); captureDeviceName = AvailableVideoInputDevices.First().Name; #region WMV // //sets output file name,and file type // captureGraph.SetOutputFileName(MediaSubType.Asf, /*DateTime.Now.Ticks.ToString() +".wmv"*/ "test.wmv", out asfWriter, out pTmpSink); // //configure which video setting is used by graph // IConfigAsfWriter lConfig = asfWriter as IConfigAsfWriter; Guid cat = new Guid("8C45B4C7-4AEB-4f78-A5EC-88420B9DADEF"); lConfig.ConfigureFilterUsingProfileGuid(cat); #endregion captureGraph.RenderStream(PinCategory.Preview, MediaType.Video, capFilter, null, null); captureGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, null, asfWriter); m_mediaCtrl = Graph as IMediaControl; m_mediaCtrl.Run(); } else { MessageBox.Show("Video Capture Device Not Found!!"); button1.Visible = false; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload