Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Memory usage of VideoClip

Discussion in 'Audio & Video' started by shivaduke28, May 3, 2021.

  1. shivaduke28

    shivaduke28

    Joined:
    Feb 5, 2019
    Posts:
    1
    I am trying to create a VJ application with Unity.
    The app has a "catalog" ScriptableObject asset like this:

    Code (CSharp):
    1. public class MyCatalog : ScriptableObject
    2. {
    3.     public VideoClip[] videoClips;
    4. }
    When the app starts, a MonoBehaviour ("Scene Controller class") loads the scriptable object,
    and creates UI with it.

    When app uses some VideoClip asset, it creates a new GameObject in the Scene with VideoPlayer component, create a new RenderTexture to which the VideoPlayer renders,
    set the videoclip asset to it, play it, then render it in UI via RenderTexture.


    My question is;

    Because the catalog file has the references of VideoClip assets, I guess that mp4 video files are on memory when the scene starts.
    If so, then the memory usage must increase when many VideoClip assets are added to the catalog file.

    But, it seems not the case.

    What actually happens in my app is:
    When I created many VideoPlayer objects with RenderTexture, then memory usage increase.
    And when I destroy the object and its RenderTexture, then the memory usage decreases.


    How does Unity control memory usage is controlled around VideoClips?
    (Also I will be very happy if I could know memory usage practices around video files in Unity)