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 + ")."); // Write pupil timestamps to a file string timeStampFileName = "Unity_" + PupilSettings.Instance.currentCamera.name; byte[] timeStampByteArray = timeStampList.ToArray(); File.WriteAllBytes(_pipe.FilePath + "/" + timeStampFileName + ".time", timeStampByteArray); PupilTools.SaveRecording(_pipe.FilePath); _pipe.Close(); 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; } }