Esempio n. 1
0
        public void StartRecording()
        {
            // First make sure recording microphone is only on MP4
            recordMicrophone &= container == Container.MP4;
            // Create recording configurations // Clamp video width to 720
            var width       = 720;
            var height      = width * Screen.height / Screen.width;
            var framerate   = container == Container.GIF ? 10 : 30;
            var videoFormat = new VideoFormat(width, (int)height, framerate);
            var audioFormat = recordMicrophone ? AudioFormat.Unity: AudioFormat.None;

            // Start recording
            NatCorder.StartRecording(container, videoFormat, audioFormat, OnReplay);
            videoRecorder = CameraRecorder.Create(Camera.main);
            // If recording GIF, skip a few frames to give a real GIF look
            if (container == Container.GIF)
            {
                videoRecorder.recordEveryNthFrame = 5;
            }
            // Start microphone and create audio recorder
            if (recordMicrophone)
            {
                StartMicrophone();
                audioRecorder = AudioRecorder.Create(microphoneSource, true);
            }
        }
Esempio n. 2
0
 void StartRecording()
 {
     Debug.Log("start recording method");
     // Start recording
     format = new VideoFormat(960, 540);
     NatCorder.StartRecording(Container.MP4, format, AudioFormat.None, OnReplay);
     // Create a camera recorder to record the main camera
     clock         = new RealtimeClock();
     videoRecorder = CameraRecorder.Create(mainCamera, clock);
     // audioRecorder = AudioRecorder.Create(sourceAudio);
 }
Esempio n. 3
0
    public void StartRecording()
    {
        // Start the microphone
        var microphoneFormat = Format.Default;

        NatMic.StartRecording(microphoneFormat, OnSampleBuffer);
        // Start recording
        recordingClock = new RealtimeClock();
        var audioFormat = new AudioFormat(microphoneFormat.sampleRate, microphoneFormat.channelCount);

        NatCorder.StartRecording(Container.MP4, VideoFormat.Screen, audioFormat, OnRecording);
        // Create a camera recorder for the main cam
        cameraRecorder = CameraRecorder.Create(recordingCamera, recordingClock);
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        float targetaspect = 1f;

        // determine the game window's current aspect ratio
        float windowaspect = (float)Screen.width / (float)Screen.height;

        // current viewport height should be scaled by this amount
        float scaleheight = windowaspect / targetaspect;

        // obtain camera component so we can modify its viewport
        Camera camera = GetComponent <Camera>();

        Debug.Log(Screen.height + " " + camera.orthographicSize);

        //camera.orthographicSize = Screen.height / 2f;

        float width = camera.orthographicSize * 2f * camera.aspect;

        camera.aspect = 1;

        camera.orthographicSize = width / 2f;

        //camera.pixelRect = new Rect(0, 0, Screen.width, Screen.width);

        // if scaled height is less than current height, add letterbox
        //if (scaleheight < 1.0f)
        //{
        //    Rect rect = camera.rect;

        //    rect.width = scaleheight;
        //    rect.height = 1.0f;
        //    rect.x = 0;
        //    rect.y = (1.0f - scaleheight) / 2.0f;

        //    camera.rect = rect;
        //}
        //else // add pillarbox
        //{
        //    float scalewidth = 1.0f / scaleheight;

        //    Rect rect = camera.rect;

        //    rect.width = scalewidth;
        //    rect.height = 1.0f;
        //    rect.x = (1.0f - scalewidth) / 2.0f;
        //    rect.y = 0;

        //    camera.rect = rect;
        //}

        VideoFormat videoFormat = new VideoFormat(GetComponent <Camera>().pixelWidth, GetComponent <Camera>().pixelWidth, 60);

        NatCorder.StartRecording(Container.MP4, videoFormat, AudioFormat.Unity, OnRecording);
        var videoRecorder = CameraRecorder.Create(GetComponent <Camera>());

        videoRecorder.recordEveryNthFrame = 4;
        var audioRecorder = AudioRecorder.Create(GetComponent <AudioListener>());

        timeLeft = 20f;
        StartCoroutine(startWait());
    }
Esempio n. 5
0
        } //END CallEvent

        //------------------------------//
        private void CallStartRecordingUnityCameraEvent()
        //------------------------------//
        {

#if NATCORDER
            //We can only record one source at a time
            if( NatCorder.IsRecording ) { return; }

            if( useDefaultSettings )
            {
                if( showDebug ) { Debug.Log( "BlockEventRecorder.cs Calling StartRecording() for default Unity Camera" ); }
                NatCorder.StartRecording( Container.MP4, VideoFormat.Screen, AudioFormat.Unity, OnRecordingComplete );
            }
            else
            {
                
                //Set our AudioFormat to the defaults
                int _sampleRate = AudioFormat.Unity.sampleRate;
                int _channelCount = AudioFormat.Unity.channelCount;

                //Check if we need to override our default AudioFormat
                if( IsUseDefaultAudioSettingsFalse() )
                {
                    _sampleRate = sampleRate;
                    _channelCount = channelCount;
                }

                //If our Video Container format is GIF, we cannot allow any kind of audio recording
                if( IsVideoContainerGIF() )
                {
                    NatCorder.StartRecording(
                    container,
                    GetVideoFormatForUnityCamera(),
                    AudioFormat.None,
                    OnRecordingComplete );
                }

                //Otherwise our audio should be based on the settings we selected
                else
                {
                    //Use the customized audio settings
                    if( IsUseDefaultAudioSettingsFalse() )
                    {
                        NatCorder.StartRecording(
                        container,
                        GetVideoFormatForUnityCamera(),
                        new AudioFormat( _sampleRate, _channelCount ),
                        OnRecordingComplete );
                    }

                    //Use the default audio settings
                    else
                    {
                        if( audioFormat == AudioRecordFormat.None )
                        {
                            NatCorder.StartRecording(
                            container,
                            GetVideoFormatForUnityCamera(),
                            AudioFormat.None,
                            OnRecordingComplete );
                        }
                        else if( audioFormat == AudioRecordFormat.Unity )
                        {
                            NatCorder.StartRecording(
                            container,
                            GetVideoFormatForUnityCamera(),
                            AudioFormat.Unity,
                            OnRecordingComplete );
                        }
                        
                    }
                }
            }

            //Start sending the texture data from the passed in camera to the recorder
            if( cameraToRecord != null )
            {
                cameraRecorder = null;
                cameraRecorder = CameraRecorder.Create( cameraToRecord );
            }

            //Start sending the audio data from the scene's AudioListener to the recorder
            if( audioListener != null )
            {
                audioRecorder = null;
                audioRecorder = AudioRecorder.Create( audioListener );
            }

            if( onRecordingStarted != null ) { onRecordingStarted.Invoke(); }
#else
            Debug.LogError( "BlockEventRecorder.cs CallStartRecordingUnityCameraEvent() missing NATCORDER scripting define symbol under project settings" );
#endif

        } //END CallStartRecordingUnityCameraEvent