UnityPlugin-AVProVideo
UnityPlugin-AVProVideo copied to clipboard
Method to play encrypted mp4
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
- Encrypt a video to local storage with a 16bits key (in this example the key is "Thats my Kung Fu")
- Assign overrideDecryptionKey to the key that has been use for the encryption
- 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.
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,
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
This isn't something we've tried, but I'll make this a feature request - we'll need to look into it.
@kahnivore I've turned it off #967 I want to play encrypted mp4 on Windows platform
I also need this feature for Android (Oculus Quest 2).