1

I Tried as below using libmedia library (http://libeasy.alwaysdata.net/) : But the encrypted video doesn't decrypt and play with the same key and cipher. Pls. see my code below: (Modified for easy understanding)

public class MyClassActivity extends Activity {

VideoView mVideoView; 
LocalSingleHttpServer mServer ;

@Override 
protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState);

  SecretKey sk = encryptVideo("/mnt/sdcard/input.mp4", "/mnt/sdcard/enc.mp4");

  playENCVideo(sk,"/mnt/sdcard/enc.mp4");
}

public void playENCVideo(SecretKey skey, String path) {

   Cipher decipher = null;

   decipher = Cipher.getInstance("AES");

   decipher.init(Cipher.DECRYPT_MODE, skey);

   mServer = new LocalSingleHttpServer();

   mServer.setCipher(decipher);
   mServer.start();

   path = mServer.getURL(path);

  mVideoView = (VideoView) findViewById(R.id.vid_view);
  mVideoView.setVideoPath(path);
  mVideoView.setOnPreparedListener(this);
  mVideoView.setOnCompletionListener(this);
  mVideoView.setMediaController(new MediaController(this));
  mVideoView.start();
} //playENCVideo()

encryptVideo() {

}

decryptVideo() {

}
} //MyClassActivity

My observations:

  1. With smaller MP4 files, atleast the unencrypted video plays from the local http server
  2. With larger MP4 files, uncencrypted video also doesn't play
  3. With smaller files, the encrypted file doesn't play with the Cipher based on the same key that used for encryption.
  4. I can confirm that my encryption and decryption with AES/RC4 works well. I can play decrypted files normally from a player.

Please help me in using the correct way of using libmedia API for playing encrypted video

matzone
  • 5,703
  • 3
  • 17
  • 20
user1444172
  • 151
  • 1
  • 6
  • What happens if you call `mServer.setCipher(decipher)` right before `mVideoView.start()`? – Maarten Bodewes May 30 '13 at 18:49
  • Please also provide the encryption routine. We cannot check if encryption/decryption works correctly if we have only the decryption operation. – Maarten Bodewes May 30 '13 at 18:51
  • It doesn't help. Just says 'video can'y be played'. But the decrypted file can be played with a player(MX). – user1444172 May 31 '13 at 08:29
  • @owlstead, it doesn't help either. Just says 'video can'y be played'. But the decrypted file can be played with a player(MX). I followed this link - http://stackoverflow.com/questions/9496447/encryption-of-video-files?rq=1 - for encrypting and decrypting video (except my file names are different - /sdcard/input.mp4 , /sdcard/enc.mp4, /sdcard/dec.mp4) - Pls.see my observations in original post (points 1-4). Same behavior with AES or RC4. Can it be issue with server? It can't play large un-encrypted files also! – user1444172 May 31 '13 at 08:40
  • Could be an issue with the server, but I'm mostly into crypto and I noticed that the API requires you to set the cipher after setting the source (as setting another source will remove said cipher). – Maarten Bodewes Jun 01 '13 at 22:22

0 Answers0