RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
235 stars 28 forks source link

Method to play encrypted mp4 #871

Open DebugD0tLog opened 3 years ago

DebugD0tLog commented 3 years ago

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

Your Setup (please complete the following information):

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.
AndrewRH commented 3 years ago

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,

DebugD0tLog commented 3 years ago

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

kahnivore commented 3 years ago

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

sam8890 commented 2 years ago

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

Luhari commented 2 years ago

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