recently i have started workin on project of my own which is capturing a camera output using DirectShow .Net. There are few problems that i don't know how ot solve
1) How can i encode the captured stream into H.264 format.I understand i should some how add filter in the filter graph. But i wasn't able to find where and how . Also i was not able to find if there is standart H.264 filter or should i download it form some where? If i need to download it can it just be a dll to wich i add reference or should it be installer?
2) Is there a way to save the captured output into a memory object, some kind of stream or it can only be written to file?
Best Regards,
Iordan
You're can use commercial software from VisioForge or Viscomsoft.
AForge potencial problem - no audio during capture, only video. Also output formats is a very limited. But - it's free and open source, if you're have any DirectShow experiense you can add audio support.
You will need to use something like FFMpeg or Handbrake. Check out http://vidcoder.codeplex.com/.
AForge also has some video editing abilities and you can also pass filters to it. There are also several FFMpeg C# wrappers you could use such as https://github.com/crazyender/FFMPEG.net
You should use AForge.net. All of the hard work is done for you already. Use VideoFileWriter http://www.aforgenet.com/framework/docs/html/4ee1742c-44d3-b250-d6aa-90cd2d606611.htm. I appears that the AForge framework uses FFMpeg under the hood as well (See AForge.Video.FFMPEG namespace). You just create a writer and pass it the bitmap/frame writer.WriteVideoFrame(bitmap);
You should fully investigate the video abstractions in AForge. You could save yourself considerable amounts of time.
Example: http://www.aforgenet.com/framework/samples/video.html
1) Yes, You should download encoder filter library. Most of decoders are supplied with free. But encoder is not. If you don't want to pay, you have to find open source Encoder.
And To use at the graphedit program, you should do dll register with that dll file. Or the installer program do this instead. And you also need to check container type like mp4, mkv... In other words you need mux filter to save that in a file. I think someone will link available urls. Sorry I don't have urls now.
2)What is that the means of capture? Is that Movie? or Image?
In case of Image, There are many sample projects and SampleGrabbers. You can save it to both of a file and memory.
In case of Movie, I'm sure your pc memory is not enougth to them with out encoding. Make memory stream and pass it to capture manager.
You can also make a filter in order to customize filter to your needs. All of information are included in Windows SDK samples.
Related
I want to develop a desktop application by programming in C# and using the .Net framework 4.
The goal of my application is to extract a MP3 audio stream from a supplied AVI file.
I have learned from the Internet that an AVI file is a container and it might contain different audio streams.
If the supplied AVI file contains one MP3 audio stream at least then I want to extract it and split it.
I want to split the MP3 audio stream into MP3 audio parts identified with a start time and an end time.
I have looked on the Internet for any .Net library I could use but without success.
Does someone know what documented .Net library would be useful ?
Maybe you can try this:
Simple C# Wrapper for the AviFile Library
It is targeted at AVI video but there might be some clues as how to use the same methods to extract the audio only.
Either use it as-is or use the example to incorporate what you need into your own code.
Since tools for this task already exist, I see no point in creating another one unless you're curious about how to do this yourself and learn something new.
If so, using a ready-made library would defeat the entire idea of learning something which is why I strongly recommend you try implementing the splitter yourself.
You can find descriptions of the AVI file format online, that should get you started.
Just curious to see if this is possible. I have a windows application that reads all the bytes from a .avi file situated on my pc and then stores it in a byte[]. So now I have the avi file in memory, and I want to load it into some sort of a video player control, directly from memory. I've tried using the wmplayer control, apparently this is not possible. I've read suggestion about using the DirectShow and VLC plugins, but I have no idea where to even start using those two and I haven't seen any sample code of this being down. Anybody have any ideas to elaborate on the mentioned plugins, or have a different approach to it?
For DirectShow, an in-memory source filter may be required. I am not aware of such a filter being available, but one can be based on Async Filter Sample from DirectShow samples. This is in C++ though.
For .NET, DirectShow.NET library can be used. A sample GSSF filter there may be a good start for an in-memory source filter implementation. This library also provides COM Interop for DirectShow that could be used to build a test player application that instantiates this filter.
I want to make a program which takes video and audio and merges them. Video type or audio type is not important for me. How can I make this? Does any library exist for this? I know there are many programs about this topic but I want to learn how to implement such a program.
The technical term for what you are trying to do is 'multiplexing', and commonly referred to as 'muxing'.
FFmpeg is a multiplatform command line tool that does this, and arguable the industry standard. Many projects wrap FFmpeg into libraries and GUIs.
FFmpeg is also open source, so you can download the code and see how they have done it. That siad, it is very big and complex.
If you are interested in the actual mechanics of muxing separate audio and video files together into a destination file, then you will need to learn much about container formats and Codecs.
Look at some sort of FFMPEG wrapper in C#.
An easy way to multiplex audio and video on linux is to use gstreamer. Here's a A/V pipeline that you can create using gst-launch on a shell prompt.
filesrc location=file1.vid ! queue ! mux. filesrc location=file2.aud ! queue ! mux. avimux name=mux ! filesink location=output.avi
Replace file1.vid with the name of your encoded video file and file2.aud with the name of your encoded audio file. output.avi is the container file that you need.
I would like to emulate video input from a webcam for testing purposes.
So I need to be able to emulate a software video capture device in Windows and be able to dynamically generate its output.
How can I achieve this?
I would prefer a solution in C# or C++.
You can use a Virtual Webcam (old link, but there are others) it will take a video/images file and will display it in a webcam device. Your system will think that its a normal device.
Then you will need to create something that will generate the video/images, if you need static image then its pretty easy to generate a bmp.
Old (no selected answer) question.... actually probably one of the oldest I've ever seen... but I came across this looking for an answer myself, I remembered the day when "Virtual Webcam" still existed (now just a chinese ad site).
Fear not! There are new sources to solve your decade long quest:
First of all, checkout OBS, open source does a LOT with video streams:
https://obsproject.com/
Second, checkout this virtual webcam plugin for it. Does exactly what you're talking about, and does use #qbeuek's suggestion of DirectDraw:
https://obsproject.com/forum/resources/obs-virtualcam.949/
It is written in C++, so grabbing the bits you need and rewriting to C# is left as an exercise to the reader, but the capability is there.
As far as I know, there is a set of COM interfaces that govern the recording and playback of audio and video in Windows. It used to be called DirectShow, but maybe in the meantime the name has been changed. Those interfaces are used to construct a graph of audio and video filters, to encode / decode the data stream.
The way to go:
- read about the Microsoft DirectShow API,
- implement a COM object that implements the video source interface,
A project I am currently working on at work requires the ability to convert videos from other formats to the WMV format. We need to be able to convert virtually any video format that is commonly used to a WMV format. I am looking for a solution allot like On2's flix engine converts other video types to .flv videos. I am aware of the encoder that windows offers, but it has a very limited list of video types that it can convert from. Please let me know if you have any suggestions or opinions, or recommendation of software I can use to do this. I need to be able to do the conversions in batch and I need to be able to do them programmatically with C#.
Have you had a look at ffmpeg?
It seems to be at the core of many open source video conversion utilities, so I imagine you could use it in the scenario you describe.
SUPER, the name is really covering the load!
Well, first you have to be able to decode the file format. You need to set this up with directshow, which is very hard to work with. You can take a look at the mediaportal project for a directshow file player written in C#. Instead of using the video renderer at the end of the directshow graph, you would reencode the video and audio and mux them into a .wmv file. This is a very involved project to get right. You essentially have to mimic a player's ability to play any format and handle failure.
I've been very satisfied using Quick Media Converter.