Menu

How to use DirectShow in WPF

2009-09-21
2012-10-29
  • Alexander Mogren

    Hi everyone.

    I need some help how to use DShow. I have the library and i want to use this
    in WPF.

    The thing i want to do is to capture the webcam and then save it as a
    compressed avi file in a given directory,.

    The directory will be written in the code so we dont need a savefiledialog.

    Can i get any help with this?

     
  • eclere

    eclere - 2009-09-23
     
  • Alexander Mogren

    Hello again. Thanks for the response.
    I have been getting some help from jmorrill.

    Did wrote this to jmorrill

    "Now the case is that I have a “cmd_record_start” button and a
    “cmd_record_stop” button.

    I want to start recording of the webcam when you press the start button, and
    when you hit the stop button I want the recording to stop and save the file to
    already given directory."

    Before i write the answer to this i wonder if its possible to start the cam
    without selecting a webcam from the combobox.

    On to the main question again, i did get this as answer,

    You will have to edit the VideoCapturePlayer.cs (and eventually
    VideoCaptureElement.cs).

    Here is a link that shows what you probably would like to do:

    Check out the ConfigAsf(...) method.

    Try copying and pasting that into VideoCapturePlayer.cs. I think right before
    the m_graph.Render statement is where you'd want to call it. You might want to
    delete the m_graph.Render call and use the captureGraph.RenderStream i have
    commented. You code would look something like this:

    var asfWriter = ConfigAsf(capGraph, szOutputFileName);
    hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video,
    m_captureDevice, null, asfWriter);

    So now iam stuck, should i take all the code in the link and replace the whole
    VideoCapturePlayer.cs
    http://google.com/codesearch/p?hl=en&sa=N&cd=12&ct=rc#Djne73msXF
    0/trunk/%E4%BB%A3%E7%A0%81%E5%BA%93/%E6%9D%8E%E4%BB%8E%E9%99%86/v2%E5%AE%A2%E6
    %88%B7%E7%AB%AF(%E6%9C%AA%E9%9B%86%E6%88%90)/Capture/v1-only%20image/Capture/C
    apture.cs&q=lang:c%23%20SetOutputFilename
     

Log in to post a comment.