views:

243

answers:

4

I want to open .avi file (preferably any video file), to work with that video as a sequence of bitmaps (arrays) and then display it on the screen or save it to the file.

What options do I have in .NET?

+1  A: 

I've been using this C# AVIFile wrapper on CodeProject to convert bitmap -> AVI and it can also do the reverse.

MrTelly
+1  A: 

Previously the Managed DirectX wrappers from Microsoft supplied an AudioVideoPlayback assembly which could be used for this but this has basically died

That article lists several alternates which I'll list here for completeness (I cannot speak for their relative merits):

It is worth noting that one of the reasons to NOT use managed code to implement filters in the DirectShow chain is that only one version of the CLR can be hosted at a time[1] so two filters with incompatible versions would fail in unpleasant ways (this is the same issue with managed shell addins).

However doing this as an app rather than as a filter should be fine.

By using DirectShow any existing audio/video stream decodable by the system should be come accessible to you.

[1] The 4.0 CLR is meant to remove this issue for all CLR versions from 2.0 onwards. Whether this is a retrospective fix for existing extension points is an open question.

ShuggyCoUk
The thing with "only one version of the CLR can be hosted at a time" is scheduled to vanish with .NET 4.0, isn't it?
OregonGhost
Yes, however this is a while to wait... Even Windows7 is IIRC not taking a dependency on 4.0 so despite it supplying a managed layer to do shell extensions it will be dangerous to use them till 4.0. I assume they will simply release them with 4.0 to avoid this
ShuggyCoUk
I will however update the answer since it's relevant to you
ShuggyCoUk
+1  A: 

You can also download a free for non commercial purposes VideoLab.NET - www.mitov.com and use it. It includes demo showing how to grab bitmaps from a stream with just a single line of code.

+1  A: 

It turns out that Splicer was the best option for me. It is open source wrapper around DirectShow.Net. The programming model is so simple that even I was able to understand it.

Jakub Šturc
I'm glad you find splicer did the trick :)
Bittercoder