Пример #1
0
        void StartVideoRecording()
        {
#if UNITY_EDITOR && AT_VIDEO_INIT
            RecorderOptions.VerboseMode = false;

            var controllerSettings = ScriptableObject.CreateInstance <RecorderControllerSettings>();
            this.mRecorderController = new RecorderController(controllerSettings);

            var videoRecorder = ScriptableObject.CreateInstance <MovieRecorderSettings>();
            videoRecorder.name             = this.mProject.ProjectName;
            videoRecorder.Enabled          = true;
            videoRecorder.OutputFile       = "Recordings/" + GetVideoName();
            videoRecorder.OutputFormat     = MovieRecorderSettings.VideoRecorderOutputFormat.MP4;
            videoRecorder.VideoBitRateMode = UnityEditor.VideoBitrateMode.High;

            if (this.mProject.is360)
            {
                videoRecorder.ImageInputSettings = new Camera360InputSettings()
                {
                    OutputWidth  = this.mProject.OutputWidth,
                    OutputHeight = this.mProject.OutputHeight,
                    RenderStereo = this.mProject.is360Stereo
                };
            }
            else
            {
                videoRecorder.ImageInputSettings = new GameViewInputSettings()
                {
                    OutputWidth  = this.mProject.OutputWidth,
                    OutputHeight = this.mProject.OutputHeight,
                };
            }


            videoRecorder.AudioInputSettings.PreserveAudio = true;

            controllerSettings.AddRecorderSettings(videoRecorder);

            controllerSettings.SetRecordModeToManual();
            //controllerSettings.SetRecordModeToFrameInterval(0, this.mProject.GetDuration() * this.FrameRate); // 2s @ 30 FPS
            controllerSettings.FrameRate         = this.mProject.FrameRate;
            controllerSettings.FrameRatePlayback = FrameRatePlayback.Constant;
            controllerSettings.CapFrameRate      = false;

            mRecorderController.PrepareRecording();
            mRecorderController.StartRecording();
#endif
        }
        public void StartAndStopRecording_WithValidSettings_ShouldStartThenStopRecording()
        {
            var settings      = ScriptableObject.CreateInstance <RecorderControllerSettings>();
            var imageRecorder = ScriptableObject.CreateInstance <ImageRecorderSettings>();

            settings.AddRecorderSettings(imageRecorder);
            var recorderController = new RecorderController(settings);

            recorderController.PrepareRecording();
            Assert.IsTrue(recorderController.StartRecording());
            Assert.IsTrue(recorderController.IsRecording());

            recorderController.StopRecording();
            Assert.IsFalse(recorderController.IsRecording());

            Object.DestroyImmediate(imageRecorder);
            Object.DestroyImmediate(settings);
        }
    // Update is called once per frame
    private void Update()
    {
        if (configOn)
        {
            StartAfterConfig();
        }


        KinectDevice.turnOnOffSkeletons(DrawSkeleton);



        if (!configured || !isRealTime || !animationOn)
        {
            return;
        }

        if (resizeAvatar) //resize avatar
        {
            resizeAvatar = false;
            ResizeAvatar();
        }

        if (startRecording)
        {
            createAnimationRecorder();
            recorder.PrepareRecording();
            recorder.StartRecording();
            startRecording = false;
            isrecording    = true;
        }

        if (stopRecording)
        {
            recorder.StopRecording();
            stopRecording = false;
            isrecording   = false;
        }
    }
Пример #4
0
        internal void Initialize()
        {
            var controllerSettings = ScriptableObject.CreateInstance <RecorderControllerSettings>();

            m_RecorderController = new RecorderController(controllerSettings);

            var mediaOutputFolder = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "SampleRecordings"));

            // Video
            m_Settings         = ScriptableObject.CreateInstance <MovieRecorderSettings>();
            m_Settings.name    = "My Video Recorder";
            m_Settings.Enabled = true;

            // This example performs an MP4 recording
            m_Settings.OutputFormat     = MovieRecorderSettings.VideoRecorderOutputFormat.MP4;
            m_Settings.VideoBitRateMode = VideoBitrateMode.High;

            m_Settings.ImageInputSettings = new GameViewInputSettings
            {
                OutputWidth  = 1920,
                OutputHeight = 1080
            };

            m_Settings.AudioInputSettings.PreserveAudio = m_RecordAudio;

            // Simple file name (no wildcards) so that FileInfo constructor works in OutputFile getter.
            m_Settings.OutputFile = mediaOutputFolder.FullName + "/" + "video";

            // Setup Recording
            controllerSettings.AddRecorderSettings(m_Settings);
            controllerSettings.SetRecordModeToManual();
            controllerSettings.FrameRate = 60.0f;

            RecorderOptions.VerboseMode = false;
            m_RecorderController.PrepareRecording();
            m_RecorderController.StartRecording();

            Debug.Log($"Started recording for file {OutputFile.FullName}");
        }
    // This function gets called when entering Play Mode. We configure the Recorder and start it.
    private void OnEnable()
    {
        if (renderTexture == null)
        {
            //Debug.LogError($"You must assign a valid renderTexture before entering Play Mode");
            renderTexture = new RenderTexture(512, 512, 32);
        }

        RecorderOptions.VerboseMode = true;

        var controllerSettings = ScriptableObject.CreateInstance <RecorderControllerSettings>();

        recorderController = new RecorderController(controllerSettings);

        var videoRecorder = ScriptableObject.CreateInstance <MovieRecorderSettings>();

        videoRecorder.name         = "My Video Recorder";
        videoRecorder.Enabled      = true;
        videoRecorder.OutputFile   = "recording";
        videoRecorder.OutputFormat = MovieRecorderSettings.VideoRecorderOutputFormat.MP4;

        videoRecorder.ImageInputSettings = new RenderTextureInputSettings()
        {
            OutputWidth     = renderTexture.width,
            OutputHeight    = renderTexture.height,
            FlipFinalOutput = false,
            RenderTexture   = renderTexture
        };
        RecorderOptions.VerboseMode = false;
        videoRecorder.AudioInputSettings.PreserveAudio = true;

        controllerSettings.AddRecorderSettings(videoRecorder);
        //controllerSettings.SetRecordModeToFrameInterval(0, 59); // 2s @ 30 FPS
        controllerSettings.SetRecordModeToManual();
        controllerSettings.FrameRate = 60;
        recorderController.PrepareRecording();
        recorderController.StartRecording();
    }
    private static IEnumerator RecordOneLevel(LevelData level, RecorderLevelEntryPoint entry)
    {
        // Enable the starting UI
        entry.StartingUI.SetActive(true);
        entry.LevelTitle.text = $"Next Level: '{level.Name}'";

        for (int i = entry.CountdownTime; i >= 1; i--)
        {
            entry.CountdownText.text = i.ToString();

            // Set time of current count and create a function to detect when one second has passed
            yield return(new WaitForSeconds(1f));
        }

        // Setup the matrix
        entry.StartingUI.SetActive(false);
        entry.MatrixUI.Setup(level);

        // Start the recording
        RecorderController recorder = GetRecorder(level.Name);

        recorder.PrepareRecording();

        if (!recorder.StartRecording())
        {
            Debug.Log("Failed to start the recording!");
        }

        // Wait until the current matrix is identity
        yield return(new WaitUntil(() => entry.MatrixUI.CurrentMatrix.isIdentity));

        yield return(new WaitForSeconds(entry.EndingTime));

        // Stop the recording
        recorder.StopRecording();
    }
Пример #7
0
        public void SceneHookGameObject_AfterStartRecording_ShouldBeVisible()
        {
            var settings = ScriptableObject.CreateInstance <RecorderControllerSettings>();
            var recorder = ScriptableObject.CreateInstance <ImageRecorderSettings>();

            settings.AddRecorderSettings(recorder);
            var recorderController = new RecorderController(settings);

            RecorderOptions.VerboseMode = false;             // Make sure visibility is not toggled on because of debugMode.

            recorderController.PrepareRecording();
            Assert.IsTrue(recorderController.StartRecording());
            Assert.IsTrue(recorderController.IsRecording());

            var gameObject = GameObject.Find("Unity-RecorderSessions");

            Assert.IsNotNull(gameObject);
            Assert.IsTrue(gameObject.hideFlags == HideFlags.None);

            recorderController.StopRecording();

            Object.DestroyImmediate(recorder);
            Object.DestroyImmediate(settings);
        }
Пример #8
0
        public IEnumerator StartingAndEndingRecording_IncreasesTakeByOne()
        {
            yield return(new EnterPlayMode());

            var settings = ScriptableObject.CreateInstance <RecorderControllerSettings>();

            settings.SetRecordModeToTimeInterval(0, 20);
            var movSettings = ScriptableObject.CreateInstance <ImageRecorderSettings>();

            settings.AddRecorderSettings(movSettings);
            var recorderController = new RecorderController(settings);

            recorderController.PrepareRecording();
            Assert.AreEqual(1, movSettings.Take);
            recorderController.StartRecording();
            yield return(null);

            recorderController.StopRecording();
            yield return(new ExitPlayMode());

            Assert.AreEqual(2, movSettings.Take);
            UnityObject.DestroyImmediate(settings);
            UnityObject.DestroyImmediate(movSettings);
        }
        void OnEnable()
        {
            var controllerSettings = ScriptableObject.CreateInstance <RecorderControllerSettings>();

            m_RecorderController = new RecorderController(controllerSettings);

            var mediaOutputFolder = Path.Combine(Application.dataPath, "..", "SampleRecordings");
            // animation output is an asset that must be created in Assets folder
            var animationOutputFolder = Path.Combine(Application.dataPath, "SampleRecordings");

            // Video
            var videoRecorder = ScriptableObject.CreateInstance <MovieRecorderSettings>();

            videoRecorder.name    = "My Video Recorder";
            videoRecorder.Enabled = true;

            videoRecorder.OutputFormat     = MovieRecorderSettings.VideoRecorderOutputFormat.MP4;
            videoRecorder.VideoBitRateMode = VideoBitrateMode.Low;

            videoRecorder.ImageInputSettings = new GameViewInputSettings
            {
                OutputWidth  = 1920,
                OutputHeight = 1080
            };

            videoRecorder.AudioInputSettings.PreserveAudio = true;

            videoRecorder.OutputFile = Path.Combine(mediaOutputFolder, "video_v" + DefaultWildcard.Take);

            // Animation
            var animationRecorder = ScriptableObject.CreateInstance <AnimationRecorderSettings>();

            animationRecorder.name    = "My Animation Recorder";
            animationRecorder.Enabled = true;

            var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            animationRecorder.AnimationInputSettings = new AnimationInputSettings
            {
                gameObject = sphere,
                Recursive  = true,
            };

            animationRecorder.AnimationInputSettings.AddComponentToRecord(typeof(Transform));

            animationRecorder.OutputFile = Path.Combine(animationOutputFolder, "anim_" + DefaultWildcard.GeneratePattern("GameObject") + "_v" + DefaultWildcard.Take);

            // Image Sequence
            var imageRecorder = ScriptableObject.CreateInstance <ImageRecorderSettings>();

            imageRecorder.name    = "My Image Recorder";
            imageRecorder.Enabled = true;

            imageRecorder.OutputFormat = ImageRecorderSettings.ImageRecorderOutputFormat.PNG;
            imageRecorder.CaptureAlpha = true;

            imageRecorder.OutputFile = Path.Combine(mediaOutputFolder, "_png", "image_v" + DefaultWildcard.Take + "." + DefaultWildcard.Frame);

            imageRecorder.imageInputSettings = new CameraInputSettings
            {
                Source       = ImageSource.MainCamera,
                OutputWidth  = 1920,
                OutputHeight = 1080,
                CaptureUI    = true
            };

            // Setup Recording
            controllerSettings.AddRecorderSettings(videoRecorder);
            controllerSettings.AddRecorderSettings(animationRecorder);
            controllerSettings.AddRecorderSettings(imageRecorder);

            controllerSettings.SetRecordModeToManual();
            controllerSettings.FrameRate = 60.0f;

            RecorderOptions.VerboseMode = false;
            m_RecorderController.PrepareRecording();
            m_RecorderController.StartRecording();
        }