RenderHeads / UnityPlugin-AVProVideo

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

HLS overrideDecryptionKey doesn't seem to work #850

Closed NigelMorgan closed 3 years ago

NigelMorgan commented 3 years ago

Using overrideDecryptionKey for decrypting AES-128 via C# scripting results in error. Using the Unity editor fields works correctly.

Windows platform, AVPro Unity plug in, trying to provide offline HLS AES-128 playback of local video file. Using Trial version (I was told it's full functionally, just with the renderheads logo watermark)

Setup:

Reproduce:

1) Use ffmpeg to create a HLS video. No encryption. 2) Works fine in editor (Media source field) & when application is run. 3) Use ffmpeg to create a HLS AES-128 video. I used an encryption key of "AAAAAAAAAAAAAAAA" for this example. URL encoded will not return a valid key, this needs to work offline. 4) Can load & play this video in the unity editor using the media player "Key Override (Base64)" and setting this to "QUFBQUFBQUFBQUFBQUFBQQ==" (this is "AAAAAAAAAAAAAAAA" in Base64). Enter the key override & hit Load, the video loads & plays.

image

5) Now I want todo this via scripting on the windows platform so it works when run:

According to the AVPro docs I should set overrideDecryptionKey, ie

mediaPlayer.PlatformOptionsWindows.keyAuth.overrideDecryptionKey = Convert.FromBase64String("QUFBQUFBQUFBQUFBQUFBQQ==");

OR

mediaPlayer.PlatformOptionsWindows.keyAuth.overrideDecryptionKey = Encoding.ASCII.GetBytes("AAAAAAAAAAAAAAAA");

before i call mediaPlayer.OpenMedia & mediaPlayer.Play();

I also don't set the keyServerToken, according to the docs the overrideDecryptionKey will bypass any internet key lookup & in my case this needs to work offline.

However this results in the error:

[AVProVideo] Error: Loading failed. File not found, codec not supported, video resolution too high or insufficient system resources. UnityEngine.Debug:LogError(Object) RenderHeads.Media.AVProVideo.MediaPlayer:UpdateErrors() (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:1221) RenderHeads.Media.AVProVideo.MediaPlayer:Update() (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:652)

the same error you get if you enter the wrong or no key.

I debugged & can confirm that its using the correct key ie:

image

Any suggestions on what I might be doing wrong? or is this a bug like I suspect?

AndrewRH commented 3 years ago

Thanks for the detailed report. We have reproduced this and it is indeed a bug.

We'll be releasing a fix very soon.

AndrewRH commented 3 years ago

2.1.6 has been released with this fix - please let us know if you have any further issues

NigelMorgan commented 3 years ago

Verified fixed in version 2.1.6