Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Next Gen Recorder - News & Support

Discussion in 'Assets and Asset Store' started by pmjo, Mar 6, 2020.

  1. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    77
    Thank you for your reply,

    For someone with no C/C++ knowledge (like myself), it would be CRAZY appreciated if you (or anyone on the Unity team) could include what's needed to read runtime data from a named AudioMixerGroup into a Unity package.

    There are lots of threads on this forum asking for this exact feature, so I know plenty of folks would find it incredibly useful :)
     
    pmjo likes this.
  2. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    May I ask why you need to access the audio samples? And on what platforms?
     
  3. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    77
    I my case I use it to automatically switch between talk and idle automation whenever there are pauses in voice acting. Today I do this using OnFilterRead and it works perfectly for both pre-recorded audio and voices generated at runtime.

    But of course using OnFilterRead has the huge side effect of then leading to crackling audio:
    https://forum.unity.com/threads/is-onfilterread-paused-by-the-garbage-collector.923390/

    There's a number of use cases, but most folks asking for it seem to be needing it for doing dynamic things based on microphone input. From what I gather, we all need just read access to the stream - we just need a way to monitor if a named MixerGroup is producing output or not.
     
    Last edited: Aug 26, 2023
    pmjo likes this.
  4. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    A customer just reported that Next Gen Recorder is giving an error "failed to capture render target" with URP 14. I have confirmed this to happen and it seems URP has changed so radically from 12 that I don't have a fast fix or any fix for this at the moment.

    I will investigate the issue but for now I advice not to buy NGR if you are planning to use URP14. And please always try the FREE version before buying to make sure it works with your rendering setup.
     
  5. AndrewStyan

    AndrewStyan

    Joined:
    Apr 6, 2020
    Posts:
    14
    Hi pmjo,
    I've just started using NGR again after ages and Unity now occasionally throws a bunch of "More than 2048 allocators are registered. Reduce the allocator count." errors then crashes. Doesn't happen all the time, but only when NGR is active. Using 2019.4.36f1 and looks like URP 7.71.

    Does this sound like an NGR problem? Any suggestions?
     
  6. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    Hmm. Might actually be a bug in the Unity version you are using. At least such problem seems to be fixed in 2019.4.3f1. See here: https://unity.com/releases/editor/whats-new/2019.4.3

    Maybe you could try that version version? If that does not help, let's check more.

    EDIT :Hmm.. but you mentioned that your version is slightly newer. What kind of integration are you using and does the problem happen in editor? You could try to see if it is audio related by disabling audio, set Recorder.RecordAudio = false and be sure you haven't added the audio recorder component (usually added automatically but setting RecordAudio false disables it)
     
    Last edited: Sep 23, 2023
  7. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    Automatic integration with URP 14 is still unsupported but I have created a custom integration guide for it. It handles two different cases, a) Recording the screen, b) Recording the screen without the UI.

    You can find it from here.
     
  8. Airmouse

    Airmouse

    Joined:
    Jan 12, 2019
    Posts:
    107
    Would it be possible to use the Audio Mixer Recorder to retrieve raw audio samples from the mixer channel?
     
  9. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    Unfortunately no. Audio Mixer Recorder passes the mixer channel data directly to NGR in native code so the data never goes to C#.
     
  10. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    Actually after thinking it a bit more it might actually work. You just need to change the ngr_AudioMixerRecorderConnect's first parameter in AudioMixerRecorder.cs to point to a static C# function instead of the native one.

    Code (CSharp):
    1. delegate void AudioCallbackDelegate(System.IntPtr ptr, int bufferLength, int numChannels, int sampleRate);
    2.  
    3. [MonoPInvokeCallback(typeof(AudioCallbackDelegate))]
    4. private static void AudioCallback(IntPtr ptr, int bufferLength, int numChannels, int sampleRate) {
    5.     float[] channelData = new float[bufferLength];
    6.     Marshal.Copy(ptr, channelData, 0, bufferLength);
    7. }
    8.  
    9. void OnEnable()
    10. {
    11.     if (s_Instance == this)
    12.     {
    13.         ngr_AudioMixerRecorderConnect(AudioCallback);
    14.     }
    15. }
    This would not be very optimal though because you need to do the marshal copy but you would get the data. You must also keep in mind that the function will be called in audio thread so you should not block it in any way or the audio will stutter. You should probably instead send the channelData to some queue or a circular buffer and process it in some Update() so everything you do will be called in main thread. Almost all Unity calls will fail or crash when called from an arbitrary thread.
     
  11. gtk2kritto

    gtk2kritto

    Joined:
    Oct 6, 2023
    Posts:
    4
    I want to record render textures, so I created a class like the one below and attached it to Empty GameObject.

    Code (CSharp):
    1. using pmjo.NextGenRecorder;
    2. using UnityEngine;
    3.  
    4. public class CustomVideoRecorder : Recorder.VideoRecorderBase
    5. {
    6.     public int videoWidth = 1920;
    7.     public int videoHeight = 1080;
    8.     public RenderTexture rt;
    9.     void Awake()
    10.     {
    11.         rt = new RenderTexture(videoWidth, videoHeight, 0, RenderTextureFormat.Default);
    12.         rt.Create();
    13.         if (!Recorder.IsSupported)
    14.         {
    15.             Debug.LogWarning("Next Gen Recorder not supported on this platform");
    16.             return;
    17.         }
    18.         if (Recorder.IsReadyForRecording)
    19.         {
    20.             RecordingTexture = rt;
    21.         }
    22.     }
    23. }
    but, In ExportRecordingSession()
    Failed to export recording, error code NothingToExport, session id 721893008104
    It will become.
    How can I export correctly?
    (iOS 15)
     
  12. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    The problem in your code is that it only defines what texture to record but it does not tell when to record it. So you are basically missing the recording texture blit part which actually copies the recording texture to a video frame. Please view the custom integration part at the end of this documentation: http://www.pmjo.org/nextgenrecorder/integration.html

    Keep in mind that the way of integration depends on the used rendering pipeline. By default Unity uses built in render pipeline. There are some example scripts for different pipelines in the above mentioned integration guide.
     
  13. gtk2kritto

    gtk2kritto

    Joined:
    Oct 6, 2023
    Posts:
    4
    I used built in render pipeline.
    I expect that the export will be black even without Blit, but I would like to know why Export fails?
     
  14. gtk2kritto

    gtk2kritto

    Joined:
    Oct 6, 2023
    Posts:
    4
    Solved.

    Graphics.Blit()
    CaptureMetalRenderTarget();
     
    pmjo likes this.
  15. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    244
    It would not be black because there would be no frames to store to the video, video would be impossible to export.