Multiple IP Camera Streams

Stefan
2012-01-03
2013-02-20
  • Stefan

    Stefan - 2012-01-03

    Hi!

    Since last week I'm playing around with DirectShow and trying to understand
    the basics.

    The work I've to do is to build an application that shows (and later records
    to a file) the streams of 4 different network cameras. I'm doing this with the
    DirectShow.net-Libary, C# and WPF.

    I have achieved to get one mjpeg stream of one camera. But now I'm wondering
    how to get the other 3 in my application. I'm using AXIS network cameras and
    also their video capture driver. My problem is that I don't know how to set
    the filter properties (IP address) inside the C# code. I've searched the forum
    and found out that some methods for configuring a filter should be provided
    from its COM Interface (?). The documentation of the capture driver I've seen
    is useless for me
    (here).

    How can I set these IP addresses from code? I've seen in another thread, that
    contacting AXIS should be the best but maybe someone knows the answer.
    Here are pictures of the settings and the interfaces for this filter:

    I've tried this, but it didn't work:

    /*
              *  [ComImport, Guid("7BB7689B-1635-498D-9214-6AF9C829D052")]
              *  public class AXIS_MJPEG_Capture_Filter
              *  {
              *  }
              * 
              * */
             IBaseFilter pAXISMjpegCapture = (IBaseFilter)new AXIS_MJPEG_Capture_Filter();
             IFileSourceFilter source = pAXISMjpegCapture as IFileSourceFilter;
    
             string path = @"axmp[url]http://192.168.2.137/axis-cgi/mjpg/video.cgi[/url]";
             AMMediaType type = null;
             hr = source.Load(path, type); // returns -2147467259
    
             hr = pGraph.AddFilter(pAXISMjpegCapture, "AXIS MJPEG Capture Filter");
    

    My other question is, when I know how to set this parameters is it possible to
    create this application with 4 different graphes running at the same time? I'm
    a bit confused because when I set the properties of the filter, wouldn't it
    affect all the other graphes, so that the filters in the other graphs have the
    same configurations. Because actually it is always the same filter that will
    be configured, isn't it?

    I hope you can help me with my problems.

    Stefan

     
  • snarfle

    snarfle - 2012-01-04

    Since I don't have any Axis cameras, it is difficult for me to say how to make
    it work. And it's not like I can experiment. But if I needed to do this:

    My first thought would be to try building the graph manually, using the
    property screen to set the parameters (see the DxPropPage sample), then using
    IFileSourceFilter::GetCurrentFile to see what it returns. There might be
    something interesting about the path, or it might be that you can't use NULL
    for the AMMediaType (ie you must create an AMMediaType, and set the specific
    values that the filter wants).

    Second choice would be some variation of using the Axis property page to get
    the settings, then save them to a file (using IPersist). You would only need
    to do this when setting up new cameras. After the values have been saved for
    each of your cameras, you can use IPersist to load the saved settings. This
    may be the cleanest, most supportable solution. But it does expose the Axis
    property page, which may not be acceptable for your needs.

    Last choice (seriously, last choice) would be to use IPersist to write the
    settings to a file, then try to manually discover the format of the data in
    the file (ie where is the ip address stored, the resolution, etc). If you know
    that, you can (in theory) create your own settings files without having to
    using the Axis property page. The problem here (besides the difficulty in
    parsing out the data and building your own settings) is that a new version of
    the filter could save the data in an entirely different way. An upgrade of
    their sw could cause your app to fail.

    As for your other question (set the properties of the filter, wouldn't it
    affect all the other graphes), I'm sorry but this is a silly question. It's
    like saying "If my app creates 4 disk files, won't anything I write to one
    file end up in all 4 files?" If you create 4 graphs, and for each graph you
    create all the necessary filters, set their properties and add them to the
    graph, then each graph will use the settings of the filters in that graph.

     
  • Stefan

    Stefan - 2012-01-05

    Thanks for you help.
    I'll try to get this working with one of your solutions.

    I asked this question ("...same properties for all...") because first I've
    built the graph in GraphEdit and set the properties for the filter. After that
    I've built a new graph in GraphEditPlus and when I wanted to set the right
    settings again, but the right URL was already set. And so I thougt maybe there
    is one single property file (or one entry in the registry) and all instances
    of this filter are using this.

     
  • Derric Lyns

    Derric Lyns - 2012-01-11

    Stefan,
    I had the same situation with Vivotek cameras. They had a property page and
    their documentation did not provide much for configuring the camera. Like
    Michael said IFileSource Filter Interface is used by most of the ip camera
    capture filters. I did the same thing you are doing over WPF. I ended up in
    the same situation of thinking whether i will be able to get multiple camera
    views. Finally it all did happen.
    There are two ways to make the filter work
    1) Tweaking the registry before building the graphs : axis and vivotek cameras
    store the values in registry and is used by the capture filter. Here you dont
    need to use the IFileSource Filter and all you need is to build the graph.
    2) Use IFileSource Filter Interface and use the method Load(,) as follows

    //make sure you build the graphs first before you write this and before you
    run the graph
    eg: IFileSourceFilter ipSource = (IFileSourceFilter) GraphYouAreUsing; //
    typecast
    ipSource.Load("http://192.168.2.137/axis-
    cgi/mjpg/image.cgi
    ", null);
    3) bringing multiple camera views was a challenge as all the graph required
    Handle to window and even if we did use multiple graphs you would only see one
    camera live. However there is a tweak to overcome this. You can read the
    articles written by Jeremiah Morril or contact me.

    Regards,
    Derric Lyns
    (skype: DERRIC.LYNS)

     
  • Stefan

    Stefan - 2012-01-16

    '... //make sure you build the graphs first before you write this and before
    you run the graph ...'

    That was the problem! Thanks.
    My code before was something like

    IBaseFilter pAXISMjpegCapture = (IBaseFilter)new AXIS_MJPEG_Capture_Filter();
    
    IFileSourceFilter ipSource = (IFileSourceFilter)pAXISMjpegCapture;
    hr = ipSource.Load(@"axmp[url]http://ip-address/axis-cgi/mjpg/video.cgi[/url]", null); // returns -2147467259
    
    hr = pGraph.AddFilter(pAXISMjpegCapture, "AXIS MJPEG Capture Filter");
    

    and it didn't work.

    Now I have that

    IBaseFilter pAXISMjpegCapture = (IBaseFilter)new AXIS_MJPEG_Capture_Filter();
    hr = pGraph.AddFilter(pAXISMjpegCapture, "AXIS MJPEG Capture Filter");
    
    IFileSourceFilter ipSource = (IFileSourceFilter)pAXISMjpegCapture;
    hr = ipSource.Load(@"axmp[url]http://ip-address/axis-cgi/mjpg/video.cgi[/url]", null);
    

    and I can finally specify the URL to load.

    The next step will be to make 4 views instead of just one. I'll look at the
    articles Derric have linked. I hope that I can achieve this on my own, but if
    not, I'll contact you :)

     
  • Qasim Qadri

    Qasim Qadri - 2013-02-20

    I'm doing this with the
    DirectShow.net-Libary, C#

    i use namespace using DirectShowLib.MultimediaStreaming;
    i have to one access ip cammera pls anyone tell me coding here all....coz iam new..write all code to access ip camera.this is ipcamera link "rtsp://192.168.10.20:1125/Master-0?Profile=Master-O3"

     
    Last edit: Qasim Qadri 2013-02-20
  • Qasim Qadri

    Qasim Qadri - 2013-02-20

    I'm doing this with the
    DirectShow.net-Libary, C#

    i use namespace using DirectShowLib.MultimediaStreaming;

    using DirectShowLib;

    i have to access one ip cammera pls anyone tell me coding here all....coz iam new..write all code to access ip camera.this is ipcamera link "rtsp://192.168.10.20:1125/Master-0?Profile=Master-O3"

    my code

    IBaseFilter pAXISMjpegCapture = (IBaseFilter) new ...................wat must i write here to build graph................

            IFileSourceFilter ipSource = (IFileSourceFilter)pAXISMjpegCapture;
            ipSource.Load(@"axmp[url]rtsp://192.168.10.20:1125/Master-0?Profile=Master-O3[/url]", null);
    

    how i build graph.can any one tell me?i want to play rtsp protocol instead of http...

    Stefan, u have done many work.now help me to solve my problm.write code instead of link pls

    AXIS_MJPEG_Capture_Filter();i get error here if i use with

    IBaseFilter pAXISMjpegCapture = (IBaseFilter)new AXIS_MJPEG_Capture_Filter();

    i dnt know how to build graph ...

     
    Last edit: Qasim Qadri 2013-02-20

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks