views:

2158

answers:

2

How to encode Video from Web-Camera into H.264 in C# ?

What do I need

  • MSDN if thare is any help on this.
  • Open Source Libs/wrappers for encoding/decoding.
  • Tutorials and blog articles on How to do it.

Some examples of of how to encode into 3GP or FLV or some thing else (whith low size) would be more than apriciated!)))

+1  A: 

Below are 2 samples from CodeProject for Video Capturing in .NET.

They do not include H.264 specifically. For that you might want to post-process the video after capturing, with 3rd party components E.g: http://www.elecard.com/products/products-pc/sdk/codec-.net-sdk/

o.k.w
hm.. Thay capture Streams - it is cool thay do no cmpression its not cool. 3rd party component is not OpenSource, not Free( But Thank you wary much)
Blender
@Ole: You can have the post-processing done by other encoder outside your .NET code. Just trigger a batch file type process to perform the encoding.
o.k.w
+1  A: 

You will need to look into DirectShow SDK.

Encoding into H.264 is directly not possible, however there are commercial activex controls that can help you. But you need to understand few things,

DirectShow is audio/video processing framework, and you can use graph edit tool to put your devices on the graph and test it. And you have to write similar code to build graph, graph is chain of devices/objects that interact with each other to produce final output.

DirectShow can be used in .NET, you can use GraphEditPlus tool to create a graph and use it in .NET, however I doubt .NET is better way because it may lead to unknown errors as DirectShow is closely bound to COM. If you create ActiveX control, in native C++ and use DirectShow to do entire recording and you use ActiveX in WPF, that will be more stable however difficult to program.

Typically you will need graph as following,

Video Source => Demux -> Audio Stream + Video Stream -> MP4Muxer

x264 is free open source and has a good MP4Muxer but not legal, you must have patent licenses acquired for using H264 in your code.

Alternatives are you can go with lots of commercial controls, Intel's IPP is the best implementation of H264 so far, but its little tricky to put it in directshow.

Akash Kava