Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8114779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:15:18+00:00 2026-06-06T03:15:18+00:00

my is too record video from webcam using DirectshowLib and c# but during video

  • 0

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

1.i got the available video device

  1. init. IFilterGrapth2 object by using Graph = (IFilterGraph2)new FilterGraph();

  2. init. ICaptureGraphBuilder2 object by using captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();

4.filter grapth is set to ICaptureGraphBuilder2 object captureGraph.SetFiltergraph(Graph);

  1. and then added soursefilterformoniker() and outputfilename()

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..

how to preview window in picturebox?

here is my full 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<DsDevice> 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<DsDevice>();
            DsDevice[] videoInputDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
            AvailableVideoInputDevices.AddRange(videoInputDevices);
            if (AvailableVideoInputDevices.Count > 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;
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:15:20+00:00Added an answer on June 6, 2026 at 3:15 am

    I have done this using VMR9. I added a VMR9 filter in the Graph. and many more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not too sure how to explain this, but I will try. I have
I have 2 iphones. I would like to record live video from one, and
Been at this far too long; trying to populate a field in a record
Already check this video which is very helpful. But actually i dont just want
I have a program in c# that Insert 4,500,000 record into sql using ExecuteNoneQuery
I'm trying to record video with camera in android, but any output format i
I need to record audio clips from web browser using flash and store them
I try to record video using MediaRecorder Class. However I find out that I
How can we do video recording using VNC? I want to record all the
I need to get last record from db. I'm using sqlalchemy. At the moment,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.