Sebastian Gray
Sebastian Gray

Reputation: 2704

How can I mix two streams of Video in C#?

In the past I have used Managed Direct X and DirectShow.Net to play a video to a texture on a simple mesh. I have then used this same technique to combine multiple video sources into a single texture, using the various capabilities exposed through textures to blend these streams together. This was a very interesting experiment 2 years ago and was quite suitable for the purpose when Managed Dirext X was still being developed and supported (which is no longer is) and similarly with DirectShow.Net - it doesn't seem like it has been updated since July 2007.

I'm looking to venture in to this space again and would like to know how this can be done in C#, without using depreciated or end-of-life API's and how best to approach it.

Upvotes: 2

Views: 2983

Answers (5)

gureumi
gureumi

Reputation: 71

I did exactly that around 2003. I had to use unsafe code, in other words, pointers to convert each image frame COPIED out of the two video streams into RGB format and average each pixel values and then convert back to original format. The performance hit is so huge if you don't use unsafe code. My understanding is that When handling video stream, the DirectShow does the magic by automatically aligning many codecs to do the deed. In the mean time those image streams has to be thread-safe and properly synchronized, which means a lot of overhead. But somebody who knows better should jump in on this.

Upvotes: 1

Sebastian Gray
Sebastian Gray

Reputation: 2704

An additional option is OpenTK; for mixing the frames provided by a video stream: http://www.opentk.com/doc/graphics

Upvotes: 2

Sebastian Gray
Sebastian Gray

Reputation: 2704

Another option I came across today may be AForge.net - it contains a namespace for playing videos. http://www.aforgenet.com/framework/samples/video.html and is published under the LGPL license.

Upvotes: 2

Firoz
Firoz

Reputation: 7454

you can use SlimDX open source library that is same as almost same as MDX and DirectShow and have support in vista also in win7.0

Upvotes: 3

SLaks
SLaks

Reputation: 888283

It's very easy to do in WPF.

Use two MediaElement controls, one above the other, and make the upper one 50% transparent.

However, I don't think it's possible to save it into a new video

Upvotes: 3

Related Questions