Showing results for 
Search instead for 
Did you mean: 

Access compressed live video bitstream

Go to solution

Is there a way to access compressed live video bitstream from a USB camera that has on-board video compression (like Logitech c920 or c925e) in Labview? When I use IMAQ Grab or Snap, I can only get the encoded video stream.

If not, is there another camera or driver that I can use with Labview to access compressed bitstream?

0 Kudos
Message 1 of 16

When you say compressed you mean one of the H.26x standards?

If so I'm not sure that IMAQdx itself supports any of them. It is a copyright nightmare to build software that uses most of those standards. Since the US is in high favor of software patents, and NI being a US company, they are certainly likely to avoid those hassles by simply not providing a direct way of implementing that.

You still could do it by downloading and installing one of the many streaming video camera drivers that provide a Windows Video driver interface to any Windows application that accesses the DirectShow interface.


Datastead RTSP/RTMP/HTTP/ONVIF DirectShow Source Filter

LeadTools DirectShow Filters SDK

Moonware Universal Source Filter

FLV Socket Filter

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 16

Hi Rolf,

Thank you so much for your reply. Yes, I mean h.26x when I say compressed. I am not familiar with DirectShow, but from a quick search, it seems to me that it is mostly used for streaming over a network. Maybe the word "bitstream" was misleading in my post. What I need is to access compressed data from webcam on-the-fly (without saving it as .mp4, .avi, etc.) and enqueue it to a queue in Labview. Can I still use DirectShow for that? If so, how do I integrate these filters you referenced into Labview? 

0 Kudos
Message 3 of 16

Well DirectShow is the old but still predominantly used COM API in Windows when accessing anything that looks, smells and quacks like a webcam. That can also include virtual webcam devices that translate another video interface into a DirectShow compatible interface. There are drivers (Microsoft developer documents call this a DirectShow Video Source Filter) for just about any video source you can think off, but not all of them are free of course.

The IMAQdx driver from NI can then access the DirectShow device like any other build-in or USB attached webcam, as it supports a DirectShow interface under Windows.

So the task to access your video source is to find a DirectShow Input Filter that supports your camera or video stream and for those network cams using compressed video streams that is definitely possible to find. If it is free is another issue. Generally there are free and often Open Source variants out there but you usually get what you pay for. That means the free ones are typically the "use at your own risk, if it works, lucky for you, if it doesn't, don't call us as we long ago moved on and are now working on much more exciting stuff!".

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 16

Thank you Rolf, your answer made me understand the concepts better. But I am still in the dark about the implementation. I was looking for a tutorial or an example that can show me how to translate the camera feed to Labview via DirectShow, and encountered this thread: DirectShow .NET LabVIEW SDK (Video, Audio, IP streams) 

Seems like the implementation will be a bit cumbersome, so I wanted to make sure first before diving deep: Do you think this SDK would work for my purpose? If not, I would appreciate if you could point me to other examples or how/where to look for one.

0 Kudos
Message 5 of 16

Seems like the link is not working in my previous post, so here it is again: The DirectShow .NET LabVIEW SDK (Video, Audio, IP streams) thread under Example Program Drafts.

0 Kudos
Message 6 of 16

Most webcams have a DirectShow filter that is installed with the manufacturer's driver. It generally isn't something you should have to implement with an SDK. You connect the camera, make sure the manufacturer's driver is installed, and (assuming it includes a DirectShow filter) the IMAQdx driver recognizes the camera and allows you to acquire from it.


The difference between this and standard machine vision camera protocols is that LabVIEW/IMAQdx are communicating with the DirectShow filter rather than communicating directly with the camera. But as far as implementing video capture, the code you run in LabVIEW is exactly the same.


Maybe I'm confused about what you are trying to accomplish, but I think you might be over-complicating it.



0 Kudos
Message 7 of 16

Yes webcams should come with a Direct Show input filter if they are worth any money at all (even if they are the no-name to cheap to even include a manual of any sorts type).

But IP cameras are often not sold as webcams. The better ones do support a Direct Show input filter driver too, others just assume that you always will connect to them either through a web browser to the continuous JPEG still image stream or through a dedicated security application that inclludes the necessary RTP or whatever protocol interfaces. There are however generic IP camera Direct Show filters, some free and some paid. Generally the free ones have very limited possibilities to configure them but may work for some of the IP cameras out there. Usually the difficult part is to figure out the URL you have to configure in the Direct Show configuration for that driver for a specific camera. Each manufacturer likes to use their own URL syntax.

Rolf Kalbermatter
My Blog
Message 8 of 16

Jordan, yes I can acquire from the webcam as you said. But I can only acquire the encoded pixel values of each frame, not the compressed h.264 bitstream. At least, I couldn't find a way. I need the compressed bitstream because I will transmit the data through a bandlimited channel, so I need it to be as small as possible. Do you know how to get h.264 bitstream with IMAQdx?

Rolf, my application does not include an IP or any type of network camera. I will be working with a USB webcam. It is a commonly used Logitech webcam (c925e), so I assume from what you both said, it most probably already has DirectShow filter. So the question is, how to access the compressed bitstream from that?

0 Kudos
Message 9 of 16

If the Logitech driver doesn't support it, I'm afraid there is no way to do it. USB Webcams are usually using all kinds of proprietary protocol interfaces to access high value features of the camera, since the standard does not usually specify much more than at least one low cost method of accessing the device. Compressed bitstream data is a high value feature encumbered with patent licensing costs and therefore it is very possible that you only get that access with special drivers from the manufacturer, which you might have to pay separately for.


What makes you believe that this camera even supports such compressed bitstream data? If I look at this data sheet it mentions nowhere that H.264 is supported in any way. Correction: I see UVC H.264 support, but that is between the camera and the driver over the USB interface. If and how that driver communicates through USB with this protocol should be transparent and not something you likely can arbitrarily change on the Direct Show side.


The DirectShow filter will communicate with the camera in whatever way it determines is the best and then convert the data to DirectShow compatible frames which then are passed to the IMAQdx DirectShow sink. There might be ways to control the DirectShow Input filter from Logitec to use a specific communication method but these configuration interfaces are always proprietary so there is almost certainly no way the IMAQdx driver could provide a configuration interface for that.

Even then I fail to see what it would bring you. The data is (or is not) H.264 encoded between the camera and the DirectShow input filter, so purely on the USB wire, and after that it is in whatever DirectShow format the source (your Logitec driver) and sink (IMAQdx driver) agree upon, which certainly is NOT a compressed bitstream and it shouldn't really matter either as the data on the DirectShow path is all inside your computer so not sure where the bandwidth constrain could come in play.


The data sheet states explicitly that the camera supports high speed USB 3, in order to allow HD content, and USB 3 is certainly not bandwidth limited.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 16