Esempio n. 1
0
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            if (RecordingLord.IsPaused())
            {
                RecordingLord.ResumeRecording();
                Time.timeScale = 1.0f;
                //Debug.Log("UnPauseMutator: Resuming recording at frame " + Time.frameCount);
            }

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
Esempio n. 2
0
        public bool Execute()
        {
            var videoCodecSet = false;

            //var videoCodecIndex = -1;

            if (SetVideoCodecOption.IsPresent)
            {
                var name = (string)SetVideoCodecOption.Arguments[0].Value;
                if (RecordingLord.CheckCodec(name))
                {
                    videoCodecSet        = true;
                    RecordingLord.Vcodec = name;
                }

                else
                {
                    Debug.Log("Error:  No match found for video codec \"" + name + "\"");
                    return(false);
                }
            }

            if (SetVideoCodecFromCmdLineArgOption.IsPresent)
            {
                var videoCodecString = CommandLineArgs.GetArgumentValue((string)SetVideoCodecFromCmdLineArgOption.Arguments[0].Value);

                if (string.IsNullOrEmpty(videoCodecString))
                {
                    // Commenting this out to help avoid confusion
                    //Debug.Log("Error:  Cannot set video codec because that command line argument was not found or had no value");
                    return(true);    // Don't report this as an error
                }

                if (RecordingLord.CheckCodec(videoCodecString))
                {
                    videoCodecSet        = true;
                    RecordingLord.Vcodec = videoCodecString;
                }
                else
                {
                    Debug.Log("Error:  No match found for video codec \"" + videoCodecString + "\"");
                    return(false);
                }
            }

            if (videoCodecSet)
            {
                Debug.Log("Video codec index set to " + RecordingLord.Vcodec);
            }

            var frameRateSet = false;
            var frameRate    = 30;

            if (FrameRateOption.IsPresent)
            {
                frameRate    = (int)FrameRateOption.Arguments[0].Value;
                frameRateSet = true;
            }

            if (FrameRateFromCmdLineArgOption.IsPresent)
            {
                var frameRateString = CommandLineArgs.GetArgumentValue((string)FrameRateFromCmdLineArgOption.Arguments[0].Value);

                if (string.IsNullOrEmpty(frameRateString))
                {
                    //Debug.Log("Error:  Cannot set frame rate because that command line argument was not found or had no value");
                    return(false);
                }

                object value = null;
                if (!frameRateString.StringToValueOfType(typeof(int), ref value, true))
                {
                    return(false);
                }

                frameRate    = (int)value;
                frameRateSet = true;
            }

            if (frameRateSet)
            {
                RecordingLord.FrameRate = frameRate;
                Debug.Log("Movie frame rate set to " + RecordingLord.FrameRate);
            }

            var jqualitySet = false;
            var jquality    = 100;

            if (JpegQualityOption.IsPresent)
            {
                jquality    = (int)JpegQualityOption.Arguments[0].Value;
                jqualitySet = true;
            }

            if (JpegQualityFromCmdLineArgOption.IsPresent)
            {
                var jqualityString = CommandLineArgs.GetArgumentValue((string)JpegQualityFromCmdLineArgOption.Arguments[0].Value);

                if (string.IsNullOrEmpty(jqualityString))
                {
                    //Debug.Log("Error:  Cannot set frame rate because that command line argument was not found or had no value");
                    return(false);
                }

                object value = null;
                if (!jqualityString.StringToValueOfType(typeof(int), ref value, true))
                {
                    return(false);
                }

                jquality    = (int)value;
                jqualitySet = true;
            }

            if (jqualitySet)
            {
                RecordingLord.JpegQuality = jquality;
                Debug.Log("Movie JPEG quality set to " + RecordingLord.JpegQuality);
            }

            if (StartOption.IsPresent)
            {
                if (!RecordingLord.IsRecording())
                {
                    // We start recording in a job, which happens as a coroutine.  This fixes (11/10/2015) an issue where videos
                    // were black for several seconds at the beginning, which I think was related to choreography-triggered
                    // video recording that were also being started in jobs.

                    var filename = (string)StartOption.Arguments[0].Value;
                    JobManager.Instance.StartJob(StartRecordingMovie(filename), jobName: "RecordMovieFromDevCmd");
                }
                else
                {
                    Debug.Log("Error:  Movie already being captured");
                    return(false);
                }
            }

            if (StopOption.IsPresent)
            {
                if (RecordingLord.IsRecording())
                {
                    RecordingLord.StopRecording();
                    Debug.Log("Frames captured: " + RecordingLord.FrameTotal + "; total duration " + RecordingLord.Duration + " seconds");
                }
                else
                {
                    Debug.Log("Error:  No movie being captured");
                    return(false);
                }
            }

            if (PauseOption.IsPresent)
            {
                if (!RecordingLord.IsRecording())
                {
                    Debug.Log("Error:  No movie being captured");
                    return(false);
                }
                if (RecordingLord.IsPaused())
                {
                    Debug.Log("Warning:  Pause request made but movie recording is already paused");
                    return(true);
                }
                RecordingLord.PauseRecording();
                Debug.Log("Movie recording paused; duration so far is " + RecordingLord.Duration + " seconds");
            }

            if (ResumeOption.IsPresent)
            {
                if (!RecordingLord.IsRecording())
                {
                    Debug.Log("Error:  No movie being captured");
                    return(false);
                }
                if (!RecordingLord.IsPaused())
                {
                    Debug.Log("Warning:  Resume request made but movie recording is not paused");
                    return(true);
                }
                RecordingLord.ResumeRecording();
                Debug.Log("Movie recording resumed");
            }

            return(true);
        }