Search Unity

Video Unity Recorder: Once-per-frame Event?

Discussion in 'Audio & Video' started by Selzier, Dec 6, 2018.

  1. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    I want to execute some custom function every frame of the video render. This is different than a regular script, because a regular script is typically running at 60fps and the render does not run at 60fps.

    I want a script to perform a function right before each video frame is rendered. Is this possible?
     
  2. marief_unity

    marief_unity

    Unity Technologies

    Joined:
    Oct 9, 2018
    Posts:
    142
    Hello @Selzier,

    Right now there is no such hook in the code.
    One thing that is on our road map and could help you in the future is the possibility to extend the Recorder object to create a customized Recorder.

    Would you mind giving me more details about your use case so I can make sure a workaround does not already exist ?

    Thanks for reaching out !
     
  3. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Well it was for rendering music videos like this one that I make with Unity.



    You can see it visualizes the audio spectrum which depends on AudioSource.GetSpectrumData and actually having audio coming out of the speakers in realtime. This has always been problematic with rendering music videos because when rendering the audio is not playing back in realtime, nor out of the speaker.

    I've been using the 360 Panorama Pro renderer, and I've written custom code which "injects" the audio spectrum data per frame and that's how the above result was achieved. However, when I recently tried using Unity Render, it automatically visualized the audio spectrum without me needed to 'inject' the spectrum data.

    Do you know how Unity Render achieved this?? As long as Unity Render visualizes the audio spectrum correctly during render, I don't need the hook anymore!