Play videos from memory stream

混江龙づ霸主 提交于 2019-12-01 07:40:37

问题


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.


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/12405635/play-videos-from-memory-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!