Search Unity

Video Playing multiple video in succession cause memory leak?

Discussion in 'Audio & Video' started by PunchCircle, Jan 22, 2021.

  1. PunchCircle

    PunchCircle

    Joined:
    Jul 8, 2019
    Posts:
    12
    So I have been making a project for 360 video playing for VR.
    I make a function to extract frame and save it as png for thumbnail.
    I basically use frame-ready callback of video player, prepare and then pause to deliver the frame, then save it.
    The function loop to all videos in a given directory.

    I noticed as soon as I press play and the function started, my GPU VRAM usage is maxed out in Task manager. However different story when I checked using unity profiler that the VRAM usage detected is only 12 MB.
    I already test by disabling some fuinctions like converting textures, saving texture to PNG, nothing solve the high VRAM usage, only when I disabled the videoplayer, there is no high memory usage.
    I also stop the videoplayer as soon as I save the PNG I also try to destroy the videoplayer and recreate it, but nothing help.

    Also the VRAM is never release unless I close the Unity Editor. Even if I stop the play mode.
    Also How much accurate is the profiler?

    I attached the script for the thumbnail creator.
    I use Unity 2019.4.17f1
     

    Attached Files:

    Last edited: Jan 22, 2021
  2. Kartikaeya

    Kartikaeya

    Joined:
    Jan 3, 2021
    Posts:
    10
    Hi!
    I am also facing the same issue. Did u find any solution?

    Also, similar to your case, I was building the app for google cardboard(VR) but later I moved to a pc build instead. Although, I removed all scripts related to the VR version, the plugins(for google cardboard) still exist . Is it possible that I am facing this issue because of that.

    Thanks
     
  3. PunchCircle

    PunchCircle

    Joined:
    Jul 8, 2019
    Posts:
    12
    The best solution I got to get around this issue to either downgrade the unity version or try another version of unity. This seems like a bug in some Unity version.
    Last time I tried, 2018 didn't have this issue, some 2020 have this issue too when I tried to upgrade the Unity that time.
    Unity 2021 however I haven't try, it might already fixed on that version.
     
    Kartikaeya likes this.
  4. Kartikaeya

    Kartikaeya

    Joined:
    Jan 3, 2021
    Posts:
    10
    Thanks for the reply. Although I cannot change to other version of Unity as you suggested, I got a method to work for me. Transcoding the video with the vp8 codec seems to do the trick for me.
     
  5. PunchCircle

    PunchCircle

    Joined:
    Jul 8, 2019
    Posts:
    12
    Oh great! I will keep that in mind in case I encounter this problem again.
     
    Kartikaeya likes this.