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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Failed to record tagged camera via recorder

Discussion in 'Audio & Video' started by mikoajciszek, Oct 9, 2022.

  1. mikoajciszek

    mikoajciszek

    Joined:
    May 2, 2022
    Posts:
    2
    Hi,

    I am tring to manage the recording from the selected camera.

    The goal: I have a few cameras in the scene and I need to capture video from all of them.

    What I tried: I wrote the script which is rendering mp4 file for all cameras based on their tags but all of them have a black screen after the recording is finished. Then I used a recorder (version: 3.0.3), select TaggedCamera as a source and record the animation (to verify if it works at all for tagged camera)
    upload_2022-10-9_14-25-59.png upload_2022-10-9_14-27-58.png



    The problem: Every time the mp4 has a black screen. Only if I select display, in game mode, which contains the view from this camera, then the mp4 file is correct, so it seems like the recorder always takes the game view. Is it a common bug?
     
  2. mikoajciszek

    mikoajciszek

    Joined:
    May 2, 2022
    Posts:
    2
    And here is my script which suppose to record from all selected cameras.

    Code (CSharp):
    1. public class MovieRecorder : MonoBehaviour
    2. {
    3.     RecorderController m_RecorderController;
    4.     public bool m_RecordAudio = true;
    5.     //internal MovieRecorderSettings m_Settings = null;
    6.     protected List<GameObject> cameras = new List<GameObject>();
    7.  
    8.  
    9.     void OnEnable()
    10.     {
    11.         Initialize();
    12.     }
    13.  
    14.     internal void Initialize()
    15.     {
    16.         var controllerSettings = ScriptableObject.CreateInstance<RecorderControllerSettings>();
    17.         m_RecorderController = new RecorderController(controllerSettings);
    18.  
    19.         var mediaOutputFolder = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "SampleRecordings"));
    20.         foreach (Transform child in transform)
    21.         {
    22.             cameras.Add(child.gameObject);
    23.         }
    24.         foreach (var camera in cameras)
    25.         {
    26.            // Video
    27.             var videoRecorder = ScriptableObject.CreateInstance<MovieRecorderSettings>();
    28.             videoRecorder.name = camera.name;
    29.             videoRecorder.Enabled = true;
    30.  
    31.             videoRecorder.CaptureAlpha = true;
    32.  
    33.             // This example performs an MP4 recording
    34.             videoRecorder.OutputFormat = MovieRecorderSettings.VideoRecorderOutputFormat.MP4;
    35.             videoRecorder.VideoBitRateMode = VideoBitrateMode.High;
    36.  
    37.             print(camera.tag);
    38.             videoRecorder.ImageInputSettings = new CameraInputSettings
    39.             {
    40.                 Source = ImageSource.TaggedCamera,
    41.                 OutputWidth = 1920,
    42.                 OutputHeight = 1080,
    43.                 CameraTag = camera.tag
    44.                 //RecordTransparency = false,
    45.                 //CaptureUI = false,
    46.                 //FlipFinalOutput = false
    47.             };
    48.  
    49.             videoRecorder.AudioInputSettings.PreserveAudio = m_RecordAudio;
    50.  
    51.             // Simple file name (no wildcards) so that FileInfo constructor works in OutputFile getter.
    52.             videoRecorder.OutputFile = mediaOutputFolder.FullName + "/" + "video_" + camera.name;
    53.  
    54.  
    55.             // Setup Recording
    56.             controllerSettings.AddRecorderSettings(videoRecorder);
    57.  
    58.             //Debug.Log($"Started recording for file {OutputFile.FullName}");
    59.         }
    60.  
    61.         controllerSettings.SetRecordModeToManual();
    62.         controllerSettings.FrameRate = 60.0f;
    63.  
    64.         RecorderOptions.VerboseMode = false;
    65.         m_RecorderController.PrepareRecording();
    66.         m_RecorderController.StartRecording();
    67.     }
    68.  
    69.     void OnDisable()
    70.     {
    71.         m_RecorderController.StopRecording();
    72.     }
    73. }
    74.  
     
  3. rooose

    rooose

    Unity Technologies

    Joined:
    Jun 8, 2022
    Posts:
    30
    mikoajciszek likes this.