private void StartCapture() { _lastFileSize = 0; _lastEncodedMinutes = _lastEncodedSeconds = 0; if (_whenRecordingAutoHideUI) { _showUI = false; } _movieCapture.StartCapture(); }
private void recordVideoState(bool flag) { if (flag) { Debug.Log("start record video"); if (_capture != null && !_capture.IsCapturing()) { _capture.StartCapture(); } } else { Debug.Log("stop record video"); if (_capture != null && _capture.IsCapturing()) { _capture.StopCapture(); } } }
/// <summary> /// 点击开始播放 /// </summary> private void OnClickBtn_Recorde() { OpenFileName openFileName = new OpenFileName(); openFileName.structSize = Marshal.SizeOf(openFileName); openFileName.filter = "AVI文件(*.avi)\0*.avi"; openFileName.file = new string(new char[256]); openFileName.maxFile = openFileName.file.Length; openFileName.fileTitle = new string(new char[64]); openFileName.maxFileTitle = openFileName.fileTitle.Length; openFileName.initialDir = UnityEngine.Application.dataPath.Replace('/', '\\');//默认路径 openFileName.title = "选择文件存放位置"; openFileName.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008; if (LocalDialog.GetSaveFileName(openFileName)) { filePath = openFileName.file.Replace(openFileName.fileTitle, null); movieCapture._outputFolderPath = filePath; movieCapture._autoFilenamePrefix = openFileName.fileTitle; fileName = movieCapture._autoFilenamePrefix; Debug.Log(filePath + fileName); movieCapture.StartCapture(); } }
public void StartCaptureButton() { // _textureCapture.PrepareCapture (); //if (!_movieCapture.IsCapturing ()) _movieCapture.StartCapture(); }
void MyWindow(int id) { GUILayout.BeginVertical(); if (_movieCapture != null) { GUILayout.Label("Resolution:"); GUILayout.BeginHorizontal(); _downScaleIndex = GUILayout.SelectionGrid(_downScaleIndex, _downScales, _downScales.Length); switch (_downScaleIndex) { case 0: _movieCapture._downScale = AVProMovieCaptureBase.DownScale.Original; break; case 1: _movieCapture._downScale = AVProMovieCaptureBase.DownScale.Half; break; case 2: _movieCapture._downScale = AVProMovieCaptureBase.DownScale.Quarter; break; case 3: _movieCapture._downScale = AVProMovieCaptureBase.DownScale.Eighth; break; case 4: _movieCapture._downScale = AVProMovieCaptureBase.DownScale.Sixteenth; break; case 5: _movieCapture._downScale = AVProMovieCaptureBase.DownScale.Specific; break; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.Width(256)); if (_movieCapture._downScale == AVProMovieCaptureBase.DownScale.Specific) { string maxWidthString = GUILayout.TextField(Mathf.FloorToInt(_movieCapture._maxVideoSize.x).ToString(), 4); int maxWidth = 0; if (int.TryParse(maxWidthString, out maxWidth)) { _movieCapture._maxVideoSize.x = Mathf.Clamp(maxWidth, 0, 4096); } GUILayout.Label("x", GUILayout.Width(20)); string maxHeightString = GUILayout.TextField(Mathf.FloorToInt(_movieCapture._maxVideoSize.y).ToString(), 4); int maxHeight = 0; if (int.TryParse(maxHeightString, out maxHeight)) { _movieCapture._maxVideoSize.y = Mathf.Clamp(maxHeight, 0, 4096); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Frame Rate:"); _frameRateIndex = GUILayout.SelectionGrid(_frameRateIndex, _frameRates, _frameRates.Length); switch (_frameRateIndex) { case 0: _movieCapture._frameRate = AVProMovieCaptureBase.FrameRate.Fifteen; break; case 1: _movieCapture._frameRate = AVProMovieCaptureBase.FrameRate.TwentyFour; break; case 2: _movieCapture._frameRate = AVProMovieCaptureBase.FrameRate.TwentyFive; break; case 3: _movieCapture._frameRate = AVProMovieCaptureBase.FrameRate.Thirty; break; case 4: _movieCapture._frameRate = AVProMovieCaptureBase.FrameRate.Fifty; break; case 5: _movieCapture._frameRate = AVProMovieCaptureBase.FrameRate.Sixty; break; } GUILayout.EndHorizontal(); GUILayout.Space(16f); _movieCapture._isRealTime = GUILayout.Toggle(_movieCapture._isRealTime, "RealTime"); GUILayout.Space(16f); // Video Codec GUILayout.BeginHorizontal(); if (_shownSection != 0) { if (GUILayout.Button("+", GUILayout.Width(24))) { _shownSection = 0; } } else { if (GUILayout.Button("-", GUILayout.Width(24))) { _shownSection = -1; } } GUILayout.Label("Using Video Codec: " + _movieCapture._codecName); if (_movieCapture._codecIndex >= 0 && _videoCodecConfigurable[_movieCapture._codecIndex]) { GUILayout.Space(16f); if (GUILayout.Button("Configure Codec")) { AVProMovieCapturePlugin.ConfigureVideoCodec(_movieCapture._codecIndex); } } GUILayout.EndHorizontal(); if (_videoCodecNames != null && _shownSection == 0) { GUILayout.Label("Select Video Codec:"); _videoPos = GUILayout.BeginScrollView(_videoPos, GUILayout.Height(100)); int newCodecIndex = GUILayout.SelectionGrid(-1, _videoCodecNames, 1) - 1; GUILayout.EndScrollView(); if (newCodecIndex >= -1) { _movieCapture._codecIndex = newCodecIndex; if (_movieCapture._codecIndex >= 0) { _movieCapture._codecName = _videoCodecNames[_movieCapture._codecIndex + 1]; } else { _movieCapture._codecName = "Uncompressed"; } _shownSection = -1; } GUILayout.Space(16f); } _movieCapture._noAudio = !GUILayout.Toggle(!_movieCapture._noAudio, "Record Audio"); GUI.enabled = !_movieCapture._noAudio; // Audio Device GUILayout.BeginHorizontal(); if (_shownSection != 1) { if (GUILayout.Button("+", GUILayout.Width(24))) { _shownSection = 1; } } else { if (GUILayout.Button("-", GUILayout.Width(24))) { _shownSection = -1; } } GUILayout.Label("Using Audio Source: " + _movieCapture._audioDeviceName); GUILayout.EndHorizontal(); if (_audioDeviceNames != null && _shownSection == 1) { GUILayout.Label("Select Audio Source:"); _audioPos = GUILayout.BeginScrollView(_audioPos, GUILayout.Height(100)); int newAudioIndex = GUILayout.SelectionGrid(-1, _audioDeviceNames, 1) - 1; GUILayout.EndScrollView(); if (newAudioIndex >= -1) { _movieCapture._audioDeviceIndex = newAudioIndex; if (_movieCapture._audioDeviceIndex >= 0) { _movieCapture._audioDeviceName = _audioDeviceNames[_movieCapture._audioDeviceIndex + 1]; } else { _movieCapture._audioDeviceName = "Unity"; } _shownSection = -1; } GUILayout.Space(16f); } // Audio Codec GUILayout.BeginHorizontal(); if (_shownSection != 2) { if (GUILayout.Button("+", GUILayout.Width(24))) { _shownSection = 2; } } else { if (GUILayout.Button("-", GUILayout.Width(24))) { _shownSection = -1; } } GUILayout.Label("Using Audio Codec: " + _movieCapture._audioCodecName); if (_movieCapture._audioCodecIndex >= 0 && _audioCodecConfigurable[_movieCapture._audioCodecIndex]) { GUILayout.Space(16f); if (GUILayout.Button("Configure Codec")) { AVProMovieCapturePlugin.ConfigureAudioCodec(_movieCapture._audioCodecIndex); } } GUILayout.EndHorizontal(); if (_audioCodecNames != null && _shownSection == 2) { GUILayout.Label("Select Audio Codec:"); _audioCodecPos = GUILayout.BeginScrollView(_audioCodecPos, GUILayout.Height(100)); int newCodecIndex = GUILayout.SelectionGrid(-1, _audioCodecNames, 1) - 1; GUILayout.EndScrollView(); if (newCodecIndex >= -1) { _movieCapture._audioCodecIndex = newCodecIndex; if (_movieCapture._audioCodecIndex >= 0) { _movieCapture._audioCodecName = _audioCodecNames[_movieCapture._audioCodecIndex + 1]; } else { _movieCapture._audioCodecName = "Uncompressed"; } _shownSection = -1; } GUILayout.Space(16f); } GUI.enabled = true; GUILayout.Space(16f); GUILayout.BeginHorizontal(); GUILayout.Label("Filename Prefix & Ext: "); _movieCapture._autoFilenamePrefix = GUILayout.TextField(_movieCapture._autoFilenamePrefix, 64); _movieCapture._autoFilenameExtension = GUILayout.TextField(_movieCapture._autoFilenameExtension, 8); GUILayout.EndHorizontal(); GUILayout.Space(16f); GUILayout.Space(16f); GUILayout.Label("(Press Esc or CTRL-F5 to stop capture)"); GUILayout.BeginHorizontal(); if (!_movieCapture.IsCapturing()) { if (GUILayout.Button("Start Capture")) { if (_whenRecordingAutoHideUI) { _showUI = false; } _movieCapture.StartCapture(); } } else { if (!_movieCapture.IsPaused()) { if (GUILayout.Button("Pause Capture")) { _movieCapture.PauseCapture(); } } else { if (GUILayout.Button("Resume Capture")) { _movieCapture.ResumeCapture(); } } if (GUILayout.Button("Stop Capture")) { _movieCapture.StopCapture(); } } GUILayout.EndHorizontal(); if (_movieCapture.IsCapturing()) { if (!string.IsNullOrEmpty(_movieCapture.LastFilePath)) { GUILayout.Label("Writing file: '" + System.IO.Path.GetFileName(_movieCapture.LastFilePath) + "'"); } } else { if (!string.IsNullOrEmpty(_movieCapture.LastFilePath)) { GUILayout.Label("Last file written: '" + System.IO.Path.GetFileName(_movieCapture.LastFilePath) + "'"); } } } GUILayout.EndVertical(); }