UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

Method to play encrypted mp4

Open DebugD0tLog opened this issue 4 years ago • 5 comments

Describe the issue It seems I cannot make the overrideDecryption workflow working (on Windows for now)

Your Setup (please complete the following information):

  • Unity version: 2019.3.4f1
  • AVPro Video version: Trial Version
  • Operating system version: Windows 10
  • Device model: /
  • Video specs (resolution, frame-rate, codec, file size): 3840x2160, 25fps, mp4, 60.3Mb

To Reproduce

  1. Encrypt a video to local storage with a 16bits key (in this example the key is "Thats my Kung Fu")
  2. Assign overrideDecryptionKey to the key that has been use for the encryption
  3. Try to MediaPlayer.OpenMedia

Here are some snippets of the code used :

Encryption :

public static byte[] EncryptBytes(byte[] dataToEncrypt)
    {
        byte[] encrypted;
        AesCryptoServiceProvider endec = new AesCryptoServiceProvider();
        endec.IV = ASCIIEncoding.ASCII.GetBytes(IV_byte);
        endec.Key = ASCIIEncoding.ASCII.GetBytes(Key_byte_16);
        ICryptoTransform icrypt = endec.CreateEncryptor(endec.Key, endec.IV);
        using (MemoryStream msEncrypt = new MemoryStream())
        {
            using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, icrypt, CryptoStreamMode.Write))
            {
                csEncrypt.Write(dataToEncrypt, 0, dataToEncrypt.Length);
                csEncrypt.FlushFinalBlock();
                encrypted = msEncrypt.ToArray();
            }
        }
        return encrypted;
    }   

Setting key and open media :

    private void LoadVideo()
    {
        mp.PlatformOptionsWindows.keyAuth.overrideDecryptionKey = Key_byte_16;
        mp.OpenMedia(MediaPathType.AbsolutePathOrURL, myMediaPath, false);
    }

Logs

[AVProVideo] Error: Loading failed.  File not found, codec not supported, video resolution too high or insufficient system resources.

DebugD0tLog avatar Jul 22 '21 10:07 DebugD0tLog

Sorry but this feature is for HLS (m3u8) streams only, not MP4 files. You can read more about it here: https://www.renderheads.com/content/docs/AVProVideo/articles/feature-content-protection-ultra.html#hls-aes-128-encrypted-playback

Thanks,

AndrewRH avatar Jul 22 '21 14:07 AndrewRH

Oh my bad I was not aware of that. So there is no way to decrypt encrypted local mp4 with Avpro at the moment ? If not, would it be possible at some point ? (on multiple platforms)

Regards

DebugD0tLog avatar Jul 22 '21 14:07 DebugD0tLog

This isn't something we've tried, but I'll make this a feature request - we'll need to look into it.

kahnivore avatar Jul 29 '21 09:07 kahnivore

@kahnivore I've turned it off #967 I want to play encrypted mp4 on Windows platform

sam8890 avatar Oct 14 '21 09:10 sam8890

I also need this feature for Android (Oculus Quest 2).

Luhari avatar Mar 02 '22 10:03 Luhari