Captain
Captain

Reputation: 743

Play videos from memory stream

Couldn't find any satisfying answer anywhere so far...

I'm working on a C# WinForms .NET3.5 application that needs to load video files from a database BLOB and play it inside the application window. The database is a local file (no servers involved).

I don't think that saving the file to the hard drive is a good solution since it might be time consuming, and I already have the file in a memory stream anyway.

I need to be able to play as much types of video formats as possible (codecs?). Including divX, XVid, mpeg, avi, 3gp, etc.

I'm looking for an easy-to-use working code sample, or an existing third party component.

Suggestions like DirectShow or VLC which require almost having a major degree in video rendering, filters, graphs and what-not are out of the question, unless there's a working sample.

Any ideas?

Thank you.

Upvotes: 4

Views: 7050

Answers (2)

NickNick
NickNick

Reputation: 21

You are right the most popular approach is to use DirectShow but in this case you have to build graph etc. It's not easy to start using DirectShow if you have not had experience in this area.

Another quite rich idea (and a "general idea" as you wrote) is to hook file calls like ReadFile and SetFilePointer and translate these calls to memorystream's methods (Read, Seek), so the calling code would think that it works with really existing file.

For example here an article that shows how to play video that is encrypted chunk by chunk, playing without decryption the whole file, and without dropping decrypted chunks to a disk: http://boxedapp.com/encrypted_video_streaming.html

Upvotes: 2

user1922061
user1922061

Reputation:

You should be able to do this by writing a thin wrapper (I assume you are in managed code) on VLC then utilize invmem and imem. Some examples are given of passing input can be found at: here and here

Upvotes: 0

Related Questions