Search Unity

How to play Encrypted video in WebGL

Discussion in 'Web' started by palash_ecomi, Jul 4, 2022.

  1. palash_ecomi

    palash_ecomi

    Joined:
    Oct 27, 2021
    Posts:
    2
    I have encrypted video in my server.
    For mobile builds:-
    1. I download the video.
    2, Decrypt it.
    3. Android/iOS plays the unencrypted video.

    But if I follow the same for Web, it is not working.

    Unencrypted video can be played using URL in WebGL.
    But Encrypted video is not working.

    --- Does anyone ever faced the same thing?
    Encryption is must for me.

    Also any other solution or work-around, if any paid plugin is there, Welcome.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,886
    What do you mean by encryption? Codec or is the file itself encrypted? What have you tried to make encrypted playback work in WebGL? Where and how does it fail?

    You cannot just download a file in WebGL since you do not have file system access (at least not without jumping through hoops and user interaction). But you could download it into memory and decrypt it in memory but for anything that‘s more than a few KB/MB (or creates a lot of garbage while decrypting) it is prohibitive in WebGL since memory is extremely limited.

    Unity WebGL defaults to 256 MB memory usage. You can increase that but the higher you go the more likely the player will only run on higher end devices (ie desktop). Check this article and specifically the two links at the bottom: https://docs.unity3d.com/2019.3/Documentation/Manual/webgl-memory.html
     
  3. palash_ecomi

    palash_ecomi

    Joined:
    Oct 27, 2021
    Posts:
    2
    File itself is encrypted, like I use AesCryptoServiceProvider to encrypt/decrypt the video file. I do the same for AssetBundles as well in WebGL. But AssetBundle works good, as I can decrypt & load bundle from decrypted byteArray.

    But Video-file in VideoPlayer can't be loaded from byteArray. And file system access also not a workaround for videos in Web.