Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question In 2022 Recorder slows down to 1 fps

Discussion in 'Audio & Video' started by fwalker, Nov 8, 2023.

  1. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    I upgraded my project from 2021 to 2022 and now the recorder slows down horribly. From the profile I see this: upload_2023-11-7_18-18-8.png

    Does anyone know what the issue might be. I realize that that operation can be slow, but I think something else is going on.
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,152
    Which recorder is this?
    Is deep profiling disabled?
    Is this runtime or in editor?
     
  3. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    1. This is the Unity recorder of course.
    2 No deep profiler was not on. I was not aware of the setting.
    3 This is on the editor (Recorder only works on editor anyways no?).
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,152
    I mixed up some features. Which version of the recorder are you using?
     
  5. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    I am using 4.0.1 · May 17, 2023 (Which I totally thought it was the latest). But I just realized there is a new one. I will report back on this.
     
    DevDunk likes this.
  6. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    Ok I uploaded latest: 4.0.2 · November 09, 2023 Same issue.
    I also notice that the problem is only happening with the movie recorder when running from script. It works fine from the Recorder Window. So the problem must be with a setting. Here is what my code looks like:
    Code (CSharp):
    1.     public class GameScreenRecorder : ScreenRecorder
    2.     {
    3.         [SerializeField] private int _outputWidth = 256;
    4.         [SerializeField] private int _outputHeight = 256;
    5.  
    6.         private RecorderController _recorderController = null;
    7.         private MovieRecorderSettings _videoRecorder;
    8.         private RecorderControllerSettings _controllerSettings;
    9.         public int OnRecordingComplete { get; private set; }
    10.  
    11.         public void Awake()
    12.         {
    13.             _controllerSettings = ScriptableObject.CreateInstance<RecorderControllerSettings>();
    14.             _recorderController = new RecorderController(_controllerSettings);
    15.  
    16.             _videoRecorder = ScriptableObject.CreateInstance<MovieRecorderSettings>();
    17.             _videoRecorder.name = "MovieRecorder";
    18.             _videoRecorder.Enabled = true;
    19.             _videoRecorder.VideoBitRateMode = VideoBitrateMode.High;
    20.  
    21.             _videoRecorder.ImageInputSettings = new GameViewInputSettings
    22.             {
    23.                 OutputWidth = _outputWidth,
    24.                 OutputHeight = _outputHeight
    25.             };
    26.  
    27.             _videoRecorder.AudioInputSettings.PreserveAudio = false;
    28.  
    29.             _controllerSettings.AddRecorderSettings(_videoRecorder);
    30.             _controllerSettings.FrameRate = FramesPerSecond;
    31.  
    32.             RecorderOptions.VerboseMode = false;
    33.  
    34.         }
    35.  
    36.         public override void StartRecording(String path, String movieFileName)
    37.         {
    38.             _videoRecorder.OutputFile = Path.Combine(path, movieFileName);
    39.  
    40.             _controllerSettings.AddRecorderSettings(_videoRecorder);
    41.             _recorderController.PrepareRecording();
    42.             _recorderController.StartRecording();
    43.         }
    44.  
    45.         public override void StopRecording()
    46.         {
    47.             _recorderController.StopRecording();
    48.         }
    49.  
    50.         public override bool IsRecording()
    51.         {
    52.             return _recorderController.IsRecording();
    53.         }
    54.  
    55.         public void OnApplicationQuit()
    56.         {
    57.             _recorderController.StopRecording();
    58.         }

    Am I missing some setting? Documentation is not very clear so this is hard to work with. If anyone has any input I would appreciate the feedback.
     
  7. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    I also did a profile with deepProfiling and I seem to get similar information:
    That writeSamples seems to be the issue.
    upload_2023-11-16_10-50-55.png
     
  8. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    Ok answering my own question here. And good thing I do not need audio. Because
    _videoRecorder.CaptureAudio = false;
    Fixes the problem ! Don't ask me I have no idea why.
     
  9. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,152
    Maybe file a bug report for that?