Playing encrypted video

好久不见. 提交于 2019-11-28 17:14:25

问题


What I want to do is next: We need to protect the video content(encrypt it) and be able to play it.

Tricky part is that we do not want to load everything into memory at once and decrypt there.(though that is also a option)

What am essentially looking for is the solution for us to play encrpyted video content, from HDD, such that only our APPLICATIOn can play that video.

Yet it should read the file from block by block(because if we are dealing with 2GB file, it should not be loaded into memory all at once).

Please let us know, what are possible ways?

  • SilverLight4 DRM - Okay, this looks like reasonable solution, flexible enough for our needs. However, the PlayReady SDK costs about $30,000 and we do not want to use SilverLight. Presumably C# or C++

  • well one idea we had, is to split big video file to seperate encrypted video files(like sequence) and then load each file("block") to directly memory/decrypt it and play it from memory(and alternate between sequence files), this seems to be the easiest one yet and probably the one what could be really done. However, what libs are capable of playing video file from memoryStream? I do believe VLC should BE able to do it..?

  • Another idea was to just take uncompressed AVI, process video frame by frame, modify each frame(encrypt it somehow), now when we play the video, we reprocess the frame in memory and decrypt it.

  • Dealing with only one specific codec and writing custom solution for it - actually this sounds pretty cool but im afraid it will take us way too much time, but do let us know about this approach

  • The another one, using VLC to play encrypted stream from localhost(eg APPLICATION is streaming encrypted HDD file to the localhost:800/BLAHBLAH) and the same application has VLC control there to decrypt the encrypted stream. We still dont know if the file on HDD can actually be encrypted too(so user would not be able to play that file on another player), plus VLC is GPL which is no good for us.


回答1:


Playback pipeline is typically a set of components plugged in together. In DirectShow, one of the APIs and the most popular one, one uses reader, splitter, codecs, post-processing and presentation parts known as filters and the whole thing plays back. It is possible to substitute reader with your own replacement which reads encrypted content and decodes on the fly. It can easily be decoding on demand, no need to decode the whole 2GB block in order to for example get a first frame or a thumbnail.

Having only hooked the reader part you are free to choose encryption method, between custom algorithm, one one of well known, API or external library.

Still I think this and other (at least most of the other) ways do not get you bullet proof guarantee that encoded content cannot be reversed. Someone else can still hook into the pipeline and grab decoded content from there. If you are happy that this at least will require complexity and experience to implement, then such encryption is going to work out pretty well.




回答2:


Just about every widely used encryption algorithm works on blocks of sizes between 128 and 256 bits – and will happily decrypt only a few of these at a time, just fine for streaming. Check out, e.g., Crypto++ for a software library that has streaming interfaces. (I.e., you just open a file, put a decrypting filter around that, and then just continue pretty much like with any other file.)




回答3:


Ok, this is how I did it. (Android)

Encrypted video is placed in sd-card. RC4 encrypted - so it can be converted on the fly while streaming. Then I created a local file server that runs on the device (as a service). The output stream does a little something extra before sending out data - it filters it through an RC4 decrypter before writing it out to the buffer. Then just point the media player to the url of the video (http://localhost:port/abc.3gp"). As a result, video from the sdcard remains secure - you cannot play it unless you have the key - which you should differ for each video for additional security.




回答4:


Thank you all for the ansers. I am a guy who went through a lot of different approaches.

I wrote my own Videoplayer using openGL+FFMPEG that could play mp4 and decrypt each frame in the GPU using shaders. I also experimented with another possible solutions, such as streaming from a webserver using VLC. (VLC offers some kind of encryption/decryption when dealing with streams), and yada yada yada.

Also one solution was to use 4 mediaelements(WPF) and the actual video was virtually split into 4 areas and each area was rotated so the video was not viewable. Once you loaded the video into 4 mediaelements, you could map out which part you wanted to show and also rotate it back. But in all honesty, MediaElement is bad.

However I ended up exactly with what RomanR said. I built DirectShow graph using mp4splitter, ffdshow, videorenderer and I modified mp4splitter sourcefilter. The reading happens in BaseSplitter/AsyncReader.cpp (just modify SyncRead function) that mp4splitter uses.

If you would like to implement it yourself, just use MPC-HC project and modify the filters as you like. It took me some time to get around the DirectShow concept, but once you understand it, it becomes great weapon.

http://sourceforge.net/apps/trac/mpc-hc/




回答5:


There is a way for Windows using file virtualization. The idea is to create a pseudofile those content is encrypted and can be decrypted on demand. E.g. with the help of BoxedApp SDK you create a virtual file that it is based on IStream using BoxedAppSDK_CreateVirtualFileBasedOnIStream. Then you pass the path of the virtual file to a player (an external application, or media player activex). When the player needs next part of decrypted data, this request passes to IStream, and its implementation decrypts data and returns it back. Thus entire file is not decrypted entirely at any moment. Also there is a large step-by-step tutorial.



来源:https://stackoverflow.com/questions/7316729/playing-encrypted-video

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