Пример #1
0
        void ClosePipe()
        {
            var camera = GetComponent <Camera>();

            // Destroy the blitter object.
            if (_tempBlitter != null)
            {
                Destroy(_tempBlitter);
                _tempBlitter = null;
            }

            // Release the temporary render target.
            if (_tempTarget != null && _tempTarget == camera.targetTexture)
            {
                camera.targetTexture = null;
                RenderTexture.ReleaseTemporary(_tempTarget);
                _tempTarget = null;
            }

            // Close the output stream.
            if (_pipe != null)
            {
                Debug.Log("Capture ended (" + _pipe.Filename + ")");

                _pipe.Close();
                _activePipeCount--;

                if (!string.IsNullOrEmpty(_pipe.Error))
                {
                    Debug.LogWarning(
                        "ffmpeg returned with a warning or an error message. " +
                        "See the following lines for details:\n" + _pipe.Error
                        );
                }

                _pipe = null;

                // Reset the application frame rate on the last pipe.
                if (_activePipeCount == 0)
                {
                    if (_allowSlowDown)
                    {
                        Time.captureFramerate = 0;
                    }
                    else
                    {
                        Application.targetFrameRate = -1;
                    }
                }
            }
        }
Пример #2
0
        void OpenPipe()
        {
            if (_pipe != null)
            {
                return;
            }

            var camera = GetComponent <Camera>();
            var width  = _width;
            var height = _height;

            // Apply the screen resolution settings.
            if (_setResolution)
            {
                _tempTarget          = RenderTexture.GetTemporary(width, height, 24);
                camera.targetTexture = _tempTarget;
                _tempBlitter         = Blitter.CreateGameObject(camera);
            }
            else
            {
                width  = camera.pixelWidth;
                height = camera.pixelHeight;
            }

            // Open an output stream.
            _pipe = new FFmpegPipe(name, width, height, _frameRate, _preset);
            _activePipeCount++;

            // Change the application frame rate on the first pipe.
            if (_activePipeCount == 1)
            {
                if (_allowSlowDown)
                {
                    Time.captureFramerate = _frameRate;
                }
                else
                {
                    Application.targetFrameRate = _frameRate;
                }
            }

            Debug.Log("Capture started (" + _pipe.Filename + ")");
        }