I have created a project using directShow that takes the captured video from a webcam and preview it.
Now I want to encode on run time video captured alive and save it on desk then play it back I want to use it as part from my code(dll for example) not a standalone part.
Any links can help me to get how to do that please I am in search process for a week and feel not understood with the methodology?
If you're writting new app, or you're interested in learn about video processing you should consider using Microsoft Media Foundation.
DirectShow is an 'obsolete' and shortly will be discontinued technology.
If despite this, you're still interested in DirectShow, you could start with MSDN DirectShow Documentation (Examples are in C++ but the idea is the same).
As short summary you must understand this concepts.
What is a DirectShow Filter, and wich types exists (Source,Transform,Renderers and Capture).Introduction to DirectShow
How can I connect multiple Filters in a Graph,how filters are connected between them, and how I can control the playback. Start with Building the Filter Graph.
Some utils that can help you:
DirectShow Graph Spy DLL Allows to watch Graphs created by others app
Monogram Graph Studio Improved version of Microsoft Graph Edit.
NOTE: As you tagged this post with 'C#' and 'Directshow.NET' tags, I will consider that you're using DirectShow.NET library (the unofficial port of DirectShow to .NET).
Related
I'm trying to find the way for getting image (only image, not video stream) from webcam in managed C#.
Usually people suggesting libraries, but they are old or commercial or under gpl.
How get image from webcam without third-party libraries?
upd.: thanks for Media Foundation, I shall use that.
Web cameras are supposed to deliver video feeds, not stills. So the native API you might be interested in is the one for video capture, which are DirectShow and Media Foundation.
The one you would most likely want is DirectShow, but it is not well suited to be interfaced from managed code, so you will need a DirectShow.NET which is open source wrapper. You typically start video streaming there and once you have a good image you stop the activity.
Or instead you might keep looking for a ready to use library which does the mentioned above for you.
One of DirectShow.NET samples does what you look for.
DxSnap – Use DirectShow to take snapshots from the Still pin of a
capture device. Note the MS encourages you to use WIA for this, but if
you want to do in with DirectShow and C#, here's how.
It mentions WIA, however WIA API is not available for all (or any in recent OSes?) web cameras, WIA more targets device like scanners.
Other APIs are perhaps less suitable.
VFW ("avicap32.dll") limits you to a subset of devices, is simple yet not well interfaced into managed code
Media Foundation is not well available in earlier OS versions
I wrote this many years ago
http://www.vbforums.com/showthread.php?344471-Vb.Net-WebCam-Class-(ICam)) in VB.net
You could easily port it to c#?
Is avicap32.dll out of the question?
Otherwise I think this is a simple and straightforward way:
http://www.creativecodedesign.com/node/66
http://www.c-sharpcorner.com/uploadfile/yougerthen/integrate-the-web-webcam-functionality-using-C-Sharp-net-and-com-part-viii/
I'm developping a SmartDevice application (Pocket PC 2003 template) in C# for a device with Windows Mobile 6.1. I need to use the camera of this device (photos, video); to do this work i tried using the CameraCaptureDialog class but it does not work for Pocket PC applications.
So, I documented on the internet and found that I probably refer to DirectShow API, but the problem is that I do not know where to start because I can't found a working/correct example.
My questions:
Is this the right way? Are there alternatives?
Where I can find a very good example that shows how to do this work?
You may try directshowbetcf: http://alexmogurenko.com/blog/directshownetcf/ if you really want to go with DirectShow and NetCF.
There's plenty of examples of directshow on the web. There is a site dedicated to converting the API over to C# which makes it a lot easier, maybe this was it http://directshownet.sourceforge.net/about.html. I struggled with DirectShow until I read the book "programming directshow" from microsoft press. About a third of that way through that book it all seemed incredibly easy and I was able to complete what I wanted. In the end it's a lot like referencing any library and using the classes from within that library. The added difficulty is that you need to add wrappers because they are all COM objects but that has been done for you.
This might be useful to you to understand the DirectShow technology. Basically gives a start to DirctShow and explains some of the important points. But its C++ not C#. Hope this help
Basic Video Capture
DirectShow is the video capture API in Windows Mobile 6. There is a Video Capture Filter there and all in all things are designed pretty much the same way they are in Windows.
The problem is that however that this is a native API, and not just in Windows Mobile. To develop in C# you need some bindings and they are missing. On desktop there is DirectShow.NET, which is a missing piece, but it does not seem to fit well for CE. Yet you still need to fill this gap in Windows Mobile.
To work it around you have a few ways, the first would be to go through DirectShow.NET and update it appropriately to start working on your device, strip parts missing in mobile OS etc. This would get you a twin for DS.NET but for mobile operating system.
Another option would be to do some C++ development and implement the minimal sufficient feature set in that domain, exposing the component via COM. Then you will reference this from managed code and things will get connected together. And another obvious option would be to use a third party solution which already does one of the mentioned above.
I want to put a news marquee over an analog TV stream using c#, I can stream analog TV using DirectShow but I can't figure out how to mix it with rotating text, should I create a filter? or I have to use another technology than DirectShow?
DirectShow is the simplest way of doing this but it does have a bit of a learning curve, particularly coming from C#. The Wikipedia page gives you a basic overview of DirectShow.
DirectShow tools are available in the latest Windows SDK. Using C++ for DirectShow programming is more straightforward but you can use DirectShow fairly easily via COM interop or DirectShow.net (which I haven't tried yet). If using COM interop the following article is helpful:
http://blogs.msdn.com/b/ericgu/archive/2004/09/20/232027.aspx
You may be able to use the VMR overlay filter if the animation performance is smooth enough. See the following articles
http://www.codeproject.com/KB/audio-video/VideoPicture.aspx
http://www.codeproject.com/KB/audio-video/Ticker.aspx
http://msdn.microsoft.com/en-us/library/dd407344(v=vs.85).aspx
Alternatively you will need to write your own filter that renders the text on each frame adjusting its position in synch with the time stamps of the video frames. If you only need to do this inside your own application then the following approach might be easiest
http://www.sichbo.ca/Free_Code/100_C_Sharp_directshow_filters
Microsoft officially recommend that DirectShow filters should be created in C++ for performance reasons but overlaying scrolling text should be OK in C# as the bottleneck will be the APIs used to overlay the text if you program carefully.
Actually you don't have to write a filter to draw some text over your video. Just make a graph where uncompressed video goes through sample grabber (one of standard DirectShow filters), set up a callback for the sample grabber and you'll be able to modify the video data in your callback. Doing it in C# is very easy using DirectShow.NET but not optimal due to marshalling. You can first build such a graph in GraphEditPlus, then it will show you source code in C# or C++ of how to build this graph and use sample grabber.
Does anyone know if it is possible to grab a frame/image from a video (.wmv) on position X using C# without installing DirectX and working on Windows 2008 (a webserver I would like to install as less as possible).
Or even a simple solution with directx could be nice.
Henk
What you'll actually need to look into is DirectShow, the general-purpose media (both audio and video) library for Windows. It used to be part of DirectX but several years ago it branched off and became part of the Windows (Platform) SDK. I should also point out here that it's now been deprecated since Windows Vista in favour of Media Foundation. From what I've read it's a much better library (DirectShow is hell for complex tasks), but unfortunately it's not really feasible to only target Media Foundation at the moment because of the lack of support for XP and earlier...
The best I can really do is point you to DirectShow.NET, a .NET wrapper library for DirectShow, which is rather stable and well tested at the moment. It includes various samples which should help you get going, but by no means will it be a straightforward solution. Also, I strongly recommend you take a look at this CodeProject article/sample application. It deals with both webcam video capture and video playback from files (including WMV). A bit of playing around with that, and learning how to do frame seeking/single frame capture (I think that project might even some code to do that) should get you what you need. Perhaps you'll even find the precise solution somewhere within the DirectShow.NET samples of that CodeProject app.
Of course, I would suggest an easier solution if I could here, but you're pretty much stuck with the horribleness that is DirectShow for the moment. Good luck anyway!
You should try FFmpeg.
Take a look at the Windows Media Format SDK, which is designed to give you pretty direct access to the frames inside a WMV (/WMA/ASF) file.
http://msdn.microsoft.com/en-us/library/dd757738(VS.85).aspx
In particular, you're interested in the synchronous API for reading these files (IWMSyncReader is the interface name). There are some pretty decent samples in the WMFSDK; I believe the most interesting one for you here will be WMSyncReader, which will show you how to dig through a WMV file and get frames, starting at position X.
I am interested in developing an application that will allow me to build a list of videos from xml (containing video title, duration, etc) and play that list as my webcam stream. Meaning, if I were to visit ustream.tv, or activate my webcam on live messenger my video playlist would register as my active webcam.
Does anybody have experience in this area, and perhaps have some advice to offer?
If you want this to work so that third party apps see your video as a standard webcam stream (and is sounds very much like you do) then the only way to do it is to write a virtual webcam driver. You will then then be able to "play" your video content as your webcam's streaming output. This will involve writing code to decode the video content - probably using DirectShow - and then copying the raw video stream to the webcam's output stream. You'll need to either write a custom DirectShow renderer filter or use the sample grabber to access the raw, decoded frames.
It's certainly an achievable goal, but not particularly easy given that both DirectShow and driver development have fairly steep learning curves. There are a variety of different driver models you could use for this, depending on exactly what your aims are. The easiest thing would be to create a Video for Windows (VfW) virtual camera driver. The huge benefit of this approach is that the driver will be entirely user mode code - much easier to debug and to write in general.
I don't have a lot of experience in this area, but I would start by looking at the MSDN docs for the DirectShow API.
A couple of .NET wrapper libraries exist as well:
Managed DirectShow
DirectShow.NET
Another DirectShow.NET