Rectangle 27 0

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.

Decrypt each frame on the GPU! WOW. How does one frame look before it's GPU decrypted?

Since each frame was encrypted, mp4 wasn't so efficient anymore, since it could not interpolate anymore between frames, thus the filesize doubled and frames per second decoded decreased. As for the frame, I used simple technique of swaping pixel nibbles. So 1111 0000 would become 0000 1111. You could still see actual video but it was really messed up, color's didnt make sense. It seemed like a "color-filter" was applied. In order to actually make it unviewable, you gotta use some kind of stream based encryption and encrypt considering also position(you can read that in GPU afaik).

encryption - Playing encrypted video - Stack Overflow

video encryption playing
Rectangle 27 0

You have multiple variables in this problem. Whether the HLS Playback is the issue or Encrypted video is the issue, or Switching network itself is the issue. So first, 1. Play a youtube video in WiFi and switch off the wifi router to see the video continue to playback even after the buffer. (Pick a longer video and enough playback to really make sure the buffer was over and is still playing. OR check the network logs to be 100% sure) If that works fine, then we know network switching is not the issue. 2. If the Step 1 is passed, check a non encrypted video on your player and test the same. (Ex. "http://edu.infozen.cshls.lldns.net/infozen/edu/edu.m3u8") 3. If the step 2 is failed, it could be your player. 4. If the step 2 is passed, check whether you are using a standard aes encryption or any type of DRM which may stop streaming in such as change. For all this, a network capture tool is a great way to proceed. It can tell you whether the requests are made or not. If made whether it is success or not. (Charles Proxy and Fiddler are simple tools. You may use wireshark as well)

video streaming - HLS Videostreaming in Android - Stack Overflow

android video-streaming android-mediaplayer android-video-player hls
Rectangle 27 0

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.

+1 I am trying for the same in android, can you direct me with what are the initial things required.

For sure. You want to run a small http server inside your app (in a separate thread in a service, probably) - look into NanoHttpd elonen.iki.fi/code/nanohttpd now modify it a bit to do your decryption stuff. That should go somewhere along the write() method to the outputstream

encryption - Playing encrypted video - Stack Overflow

video encryption playing
Rectangle 27 0

A hacker could easily figure out you are using a stream and get an unencrypted copy of the file by just pointing to your url -defeating your encryption.

encryption - Playing encrypted video - Stack Overflow

video encryption playing
Rectangle 27 0

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.)

It's not as much problem encrypting/decrypting but rather what lib allows me to play videofiles and at the same time let me play videofile block by block? (from memory)

I have no idea what libraries are available. Neither do I know which platform you develop for I just did a quick search and found that you can create custom data handlers in QT for this: developer.apple.com/library/mac/#samplecode/ , and encryption is already implemented, e.g., in VLC: forum.videolan.org/viewtopic.php?f=2&t=54937

encryption - Playing encrypted video - Stack Overflow

video encryption playing
Rectangle 27 0

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.

encryption - Playing encrypted video - Stack Overflow

video encryption playing
Rectangle 27 0

Yes a hacker can easily figure out. but the decrypted stream should not be handed away to any request coming in. a handshake is more secure.

encryption - Playing encrypted video - Stack Overflow

video encryption playing