Search Unity

Question Recorder:Take High-res screenshot per second without framerate drop

Discussion in 'Audio & Video' started by alibozorgian, Dec 7, 2022.

  1. alibozorgian

    alibozorgian

    Joined:
    Oct 18, 2021
    Posts:
    1
    Hello everyone,

    I am using the recorder to capture high-res screenshots from my VR application. My goal is to record a single screenshot each second without decreasing the framerate of the application itself. I am using the code below; however, the framerate of the application is decreased and matched to the recording framerate. Do you know how can I fix this?

    Code (CSharp):
    1. namespace UnityEngine.Recorder.Examples
    2. {
    3.     public class ImageRecorder : MonoBehaviour
    4.     {
    5.         RecorderController m_RecorderController;
    6.         public void StartRecording(Environment environment)
    7.         {
    8.             var controllerSettings = ScriptableObject.CreateInstance<RecorderControllerSettings>();
    9.             m_RecorderController = new RecorderController(controllerSettings);
    10.  
    11.             var mediaOutputFolder = Path.Combine(Application.dataPath, "..", "SampleRecordings");
    12.  
    13.             // Image Sequence
    14.             var imageRecorder = ScriptableObject.CreateInstance<ImageRecorderSettings>();
    15.             imageRecorder.name = "My Image Recorder";
    16.             imageRecorder.Enabled = true;
    17.  
    18.             imageRecorder.OutputFormat = ImageRecorderSettings.ImageRecorderOutputFormat.PNG;
    19.  
    20.             imageRecorder.OutputFile = Path.Combine(mediaOutputFolder, "_PNG", "image_frame") + "." + DefaultWildcard.Frame + $"-{environment.m_ContentIndex}-{environment.m_FocusScalingFactor}-{environment.m_ContextScalingFactor}";
    21.             imageRecorder.imageInputSettings = new GameViewInputSettings
    22.             {
    23.                 OutputWidth = 1920,
    24.                 OutputHeight = 1080
    25.             };
    26.  
    27.             controllerSettings.AddRecorderSettings(imageRecorder);
    28.             controllerSettings.SetRecordModeToManual();
    29.             controllerSettings.CapFrameRate = false;
    30.             controllerSettings.FrameRatePlayback = FrameRatePlayback.Constant;
    31.             controllerSettings.FrameRate = 1.0f;
    32.  
    33.             RecorderOptions.VerboseMode = true;
    34.             m_RecorderController.PrepareRecording();
    35.             m_RecorderController.StartRecording();
    36.         }
    37.  
    38.         public void StopRecording()
    39.         {
    40.             m_RecorderController.StopRecording();
    41.         }
     
    Last edited: Dec 8, 2022