DirectShow Video Source Filter for JPEG and M-JPEG IP Cameras

This implements a DirectShow driver/wrapper over a HTTP based JPEG/M-JPEG streamed video, widely available with IP cameras. Once installed, it provides a Start Menu shortcut to manage video capture devices, where a user can add/remove devices. The devices are automatically registered with DriectShow and are available to applications.

The compatibility list includes:

  • Windows SDK AmCap Sample (reference)
  • VideoLan VLC
  • Skype (see below)
  • Google Talk Video Chat
  • Luxriot (as rather an example as Luxriot has its own generic JPEG/M-JPEG device driver, however this still demonstrates compatibility and interoperability of applications)
  • GraphEdit, GraphStudio and similar tools

For a created device it is required to configure:

  1. JPEG or M-JPEG resource URL on the device, where the driver will access video feed or sequential snapshots
  2. Image/video size on the device

Resource URLs vary from device to device and there is no standard identifier. This has to be looked up for specific model in device API reference or SDK. For JPEG snapshots it is possible to copy image shortcut from web browser and paste address into device settings.

Note that some devices, especially low end IP cameras deliver non-compliant feed which can be decoded either by manufacturer’s ActiveX control or model-specific implementation which this driver does not convert and is unlikely to ever cover. The driver will only work with hardware which honors industry standards.

For example, Stardot NetCam SC cameras make the video feed accessible using /nph-mjpeg.cgi resource, so the full URL will consist of protocol prefix “http://”, optional username and password (see screenshot above), IP address or host name e.g. “demo2.stardotcams.com”, resource identifier on the device “/nph-mjpeg.cgi”.

Hence, http://demo2.stardotcams.com/nph-mjpeg.cgi

It is necessary to provide video size of the footage in advance so that the driver could negotiate content media types without accessing the device. Future versions of the driver might implement auto-detection.

Skype Compatibility

To make the device work with Skype, it is necessary to:

  1. Configure the device (using its web interface) to work at resolution 640×480
  2. Add/configure device with Alax.Info IP video Source as described above, including setting of 640 by 480 pixel resolution in device configuration

Internals

Software implements and registers video input/capture devices, listed under DirectShow CLSID_VideoInputDeviceCategory category. The applications access devices from the list and treat as a regular device such as web camera.

Windows SDK AmCap sample will create the following DirectShow graph where the source filter implemented by this software:

Internally, software creates a worker filter graph in order to stream data from the device:

To decode video, software uses stock MJPEG Decompressor Filter provided with operating system.

Download links

Bonus content

14 Replies to “DirectShow Video Source Filter for JPEG and M-JPEG IP Cameras”

  1. Guest: I am a newbie to Directshow.
    I have an Axis P1347 IP camera and want to play it in Media Player. In fact, I need a DirectShow source filter which can decode JPEG stream to RGB stream available via directshow.
    Could you help me which of your work is suitable for me?

    First of all you can check Axis software, I am sure they provide a filter for this. You can use my filter https://alax.info/blog/1216 and I am pretty sure there are a number of filters available on the net.

    Guest: OK, they have provided , but it doessn’t work in Win 7

    You will need an URL which works for your camera to get M-JPEG stream. I think their API is here http://www.axis.com/files/manuals/VAPIX_3_HTTP_API_3_00.pdf page 29

  2. Dear Roman,

    Thanks for nice Directshow source filter, the only problem is that it works only with 32 bit applications but I have a 64 bit application and it did not accept it, could you also make the 64 bit version.
    Also as a suggestion if it can accept RTSP URLs I thenk it will be ideal.

  3. Roman :
    Great news: x64 build is also available, see https://alax.info/blog/1223
    I have bits of code to build RTSP filter also, but this goes slowly as a low priorty thing.

    Hi, Roman,
    First of all, I must thank for your great DirectShow wrapper. It works very well for me.
    Recently I have to deal with similar case to get video fed into my application via DirectShow, but the IP camera provided can only stream H.264 via RTSP. I know it was a low priority thing for you, but just curious to know how soon it will be published as it has a quite some time since March of this year. Thanks in anticipation.

  4. Hi

    Is it possible to change the framerate, even that the camera can’t do that?

    When using a grabberprogram that use the directshow device, the fps dont change anything, always the ip-camera fps.

    It’s fine if it was possible to set the fps inside the manager.

    Best regards
    HamsterHauge

  5. @HamsterHauge

    Throttling – to lower effective FPS and reach certain target FPS of interest – on my filter is possible, however it is not the best way to approach the problem.

    It is certainly better to embed the FPS setting into URL, or otherwise set it up on the camera directly. It is not applicable to every device, of course. Throttling network activity does not work good because there is buffering between the host and the camera. The best would be to receive at maximal rate and drop unnecessary frames. This does not have to happen in the source filter, and can take place any time later down the stream.

    I don’t think I am going to add this option to the source filter itself.

  6. The 64 bit version does not work with Skype. I have Windows 7 64 bit. Tried to install both 32 and 62 bit versions, but the IP camera does not show up in the camera list of Skype. I followed the indications strictly to no avail. However, with a different Webcam Viewer, the IP camera is seen. So there must be something wrong just with Skype.

    • Hey Paul, sorry I lost your comment… It’s hard to tell what’s wrong without being able to try oneself. If your camera is on Internet, I could possibly try to configure it on my end and then share the instructions. Or, the M-JPEG feed might be not quite valid, or decoder rejects this flavor of JPEG etc.

Leave a Reply