private void CreateGUI() { try { if (!AVProMovieCapturePlugin.Init()) { Debug.LogError("[AVProMovieCapture] Failed to initialise"); return; } } catch (System.DllNotFoundException e) { _isFailedInit = true; Debug.LogError("[AVProMovieCapture] Unity couldn't find the plugin DLL, please move the 'Plugins' folder to the root of your project."); throw e; } // Video codec enumeration int numVideoCodecs = Mathf.Max(0, AVProMovieCapturePlugin.GetNumAVIVideoCodecs()); _videoCodecNames = new string[numVideoCodecs + 2]; _videoCodecNames[0] = "Uncompressed"; _videoCodecNames[1] = null; _videoCodecConfigurable = new bool[numVideoCodecs + 2]; _videoCodecConfigurable[0] = false; _videoCodecConfigurable[1] = false; for (int i = 0; i < numVideoCodecs; i++) { _videoCodecNames[i + 2] = i.ToString("D2") + ") " + AVProMovieCapturePlugin.GetAVIVideoCodecName(i).Replace("/", "_"); _videoCodecConfigurable[i + 2] = AVProMovieCapturePlugin.IsConfigureVideoCodecSupported(i); } // Audio device enumeration int numAudioDevices = Mathf.Max(0, AVProMovieCapturePlugin.GetNumAVIAudioInputDevices()); _audioDeviceNames = new string[numAudioDevices + 2]; _audioDeviceNames[0] = "Unity"; _audioDeviceNames[1] = null; for (int i = 0; i < numAudioDevices; i++) { _audioDeviceNames[i + 2] = i.ToString("D2") + ") " + AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(i).Replace("/", "_"); } // Audio codec enumeration int numAudioCodecs = Mathf.Max(0, AVProMovieCapturePlugin.GetNumAVIAudioCodecs()); _audioCodecNames = new string[numAudioCodecs + 2]; _audioCodecNames[0] = "Uncompressed"; _audioCodecNames[1] = null; _audioCodecConfigurable = new bool[numAudioCodecs + 2]; _audioCodecConfigurable[0] = false; _audioCodecConfigurable[1] = false; for (int i = 0; i < numAudioCodecs; i++) { _audioCodecNames[i + 2] = i.ToString("D2") + ") " + AVProMovieCapturePlugin.GetAVIAudioCodecName(i).Replace("/", "_"); _audioCodecConfigurable[i + 2] = AVProMovieCapturePlugin.IsConfigureAudioCodecSupported(i); } _isInit = true; }
private void OnRenderImage(RenderTexture source, RenderTexture dest) { if (_capturing && !_paused) { while (_handle >= 0 && !AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(1); } if (_handle >= 0) { RenderTexture buffer = RenderTexture.GetTemporary(_texture.width, _texture.height, 0); // Resize and convert pixel format // TODO perhaps we should pad instead of resizing to stop blurring due to resampling Graphics.Blit(source, buffer, _materialConversion); RenderTexture old = RenderTexture.active; RenderTexture.active = buffer; _texture.ReadPixels(new Rect(0, 0, buffer.width, buffer.height), 0, 0, false); EncodeTexture(_texture); RenderTexture.active = old; RenderTexture.ReleaseTemporary(buffer); UpdateFPS(); } } // Pass-through Graphics.Blit(source, dest); }
void Capture() { if (_capturing && !_paused && _sourceTexture) { while (!AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(1); } RenderTexture old = RenderTexture.active; RenderTexture buffer = RenderTexture.GetTemporary(_texture.width, _texture.height, 0); // Resize and convert pixel format // TODO: copy a region based on AREA //Graphics.Blit(_sourceTexture, buffer, _materialConversion); RenderTexture.active = buffer; GL.PushMatrix(); GL.LoadPixelMatrix(0, _texture.width, _texture.height, 0); Graphics.DrawTexture(new Rect(0, 0, _texture.width, _texture.height), _sourceTexture, _sourceTextureArea, 0, 0, 0, 0, _materialConversion); GL.PopMatrix(); // Read out the pixels and send the frame to the encoder RenderTexture.active = buffer; _texture.ReadPixels(new Rect(0, 0, buffer.width, buffer.height), 0, 0, false); EncodeTexture(_texture); RenderTexture.ReleaseTemporary(buffer); RenderTexture.active = old; UpdateFPS(); } }
public void StartCapture() { if (_capturing) { return; } if (_handle < 0) { PrepareCapture(); } if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio) { _audioCapture.FlushBuffer(); _audioCapture.enabled = true; } if (_handle >= 0) { AVProMovieCapturePlugin.Start(_handle); ResetFPS(); _capturing = true; _paused = false; } }
public virtual void UpdateFrame() { if (Input.GetKeyDown(_captureKey)) { ToggleCapture(); } if (_handle >= 0 && !_paused) { _numDroppedFrames = AVProMovieCapturePlugin.GetNumDroppedFrames(_handle); _numDroppedEncoderFrames = AVProMovieCapturePlugin.GetNumDroppedEncoderFrames(_handle); _numEncodedFrames = AVProMovieCapturePlugin.GetNumEncodedFrames(_handle); _totalEncodedSeconds = AVProMovieCapturePlugin.GetEncodedSeconds(_handle); } if (_queuedStopCapture) { _queuedStopCapture = false; _queuedStartCapture = false; StopCapture(); } if (_queuedStartCapture) { _queuedStartCapture = false; StartCapture(); } }
public void SelectAudioCodec(bool listCodecs) { // Enumerate audio codecs int numAudioCodecs = AVProMovieCapturePlugin.GetNumAVIAudioCodecs(); if (listCodecs) { for (int i = 0; i < numAudioCodecs; i++) { Debug.Log("AudioCodec " + i + ": " + AVProMovieCapturePlugin.GetAVIAudioCodecName(i)); } } // The user has specified their own codec index if (_forceAudioCodecIndex >= 0) { if (_forceAudioCodecIndex < numAudioCodecs) { _audioCodecName = AVProMovieCapturePlugin.GetAVIAudioCodecName(_forceAudioCodecIndex); _audioCodecIndex = _forceAudioCodecIndex; } } else { // Try to find the codec based on the priority list if (_audioCodecPriority != null) { foreach (string codec in _audioCodecPriority) { string codecName = codec.Trim(); // Empty string means uncompressed if (string.IsNullOrEmpty(codecName)) { break; } for (int i = 0; i < numAudioCodecs; i++) { if (codecName == AVProMovieCapturePlugin.GetAVIAudioCodecName(i)) { _audioCodecName = codecName; _audioCodecIndex = i; break; } } if (_audioCodecIndex >= 0) { break; } } } } if (_audioCodecIndex < 0) { _audioCodecName = "Uncompressed"; Debug.LogWarning("[AVProMovieCapture] Codec not found. Audio will be uncompressed."); } }
public bool StartCapture() { if (_capturing) { return(false); } if (_handle < 0) { if (!PrepareCapture()) { return(false); } } if (_handle >= 0) { if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio) { _audioCapture.FlushBuffer(); } AVProMovieCapturePlugin.Start(_handle); ResetFPS(); _capturing = true; _paused = false; } if (_startPaused) { PauseCapture(); } return(_capturing); }
private IEnumerator FinalRenderCapture() { yield return(new WaitForEndOfFrame()); while (_handle >= 0 && !AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(8); } if (_handle >= 0) { // Grab final RenderTexture into texture and encode #if AVPRO_MOVIECAPTURE_GLISSUEEVENT if (_useNativeGrabber) { if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio) { AVProMovieCapturePlugin.EncodeAudio(_handle, _audioCapture.BufferPtr, (uint)_audioCapture.BufferLength); _audioCapture.FlushBuffer(); } GL.IssuePluginEvent(AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); } #endif if (!_useNativeGrabber) { ConvertAndEncode(); //_texture.ReadPixels(new Rect(0, 0, _texture.width, _texture.height), 0, 0, false); //EncodeTexture(_texture); } UpdateFPS(); } yield return(null); }
public void Awake() { try { if (AVProMovieCapturePlugin.Init()) { Debug.Log("[AVProMovieCapture] Init plugin version: " + AVProMovieCapturePlugin.GetPluginVersion().ToString("F2") + " with GPU " + SystemInfo.graphicsDeviceVersion); #if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52 _renderEventFunction = AVProMovieCapturePlugin.GetRenderEventFunc(); _freeEventFunction = AVProMovieCapturePlugin.GetFreeResourcesEventFunc(); #endif } else { Debug.LogError("[AVProMovieCapture] Failed to initialise plugin version: " + AVProMovieCapturePlugin.GetPluginVersion().ToString("F2") + " with GPU " + SystemInfo.graphicsDeviceVersion); } } catch (DllNotFoundException e) { Debug.LogError("[AVProMovieCapture] Unity couldn't find the DLL, did you move the 'Plugins' folder to the root of your project?"); throw e; } _isDirectX11 = SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11"); SelectCodec(_listVideoCodecsOnStart); SelectAudioCodec(_listVideoCodecsOnStart); SelectAudioDevice(_listVideoCodecsOnStart); }
public void ResumeCapture() { if (_capturing && _paused) { AVProMovieCapturePlugin.Start(_handle); _paused = false; } }
private void OnRenderImage(RenderTexture source, RenderTexture dest) { if (_capturing && !_paused) { #if true while (_handle >= 0 && !AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(1); } if (_handle >= 0) { if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio && _isRealTime) { int audioDataLength = 0; System.IntPtr audioDataPtr = _audioCapture.ReadData(out audioDataLength); if (audioDataLength > 0) { AVProMovieCapturePlugin.EncodeAudio(_handle, audioDataPtr, (uint)audioDataLength); } } // In Direct3D the RT can be flipped vertically /*if (source.texelSize.y < 0) * { * * }*/ Graphics.Blit(source, dest); _lastSource = source; _lastDest = dest; if (dest != _originalTarget) { Graphics.Blit(dest, _originalTarget); } #if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52 GL.IssuePluginEvent(AVProMovieCapturePlugin.GetRenderEventFunc(), AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #else GL.IssuePluginEvent(AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #endif GL.InvalidateState(); UpdateFPS(); return; } #endif } // Pass-through Graphics.Blit(source, dest); _lastSource = source; _lastDest = dest; }
public override void UnprepareCapture() { AVProMovieCapturePlugin.SetTexturePointer(_handle, System.IntPtr.Zero); if (_target != null) { _target.DiscardContents(); } }
public void PauseCapture() { if (_capturing && !_paused) { AVProMovieCapturePlugin.Pause(_handle); _paused = true; ResetFPS(); } }
public void SelectAudioDevice(bool display) { // Enumerate int num = AVProMovieCapturePlugin.GetNumAVIAudioInputDevices(); if (display) { for (int i = 0; i < num; i++) { Debug.Log("AudioDevice " + i + ": " + AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(i)); } } // The user has specified their own device index if (_forceAudioDeviceIndex >= 0) { if (_forceAudioDeviceIndex < num) { _audioDeviceName = AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(_forceAudioDeviceIndex); _audioDeviceIndex = _forceAudioDeviceIndex; } } else { /*_audioDeviceIndex = -1; * // Try to find one of the loopback devices * for (int i = 0; i < num; i++) * { * StringBuilder sbName = new StringBuilder(512); * if (AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(i, sbName)) * { * string[] loopbackNames = { "Stereo Mix", "What U Hear", "What You Hear", "Waveout Mix", "Mixed Output" }; * for (int j = 0; j < loopbackNames.Length; j++) * { * if (sbName.ToString().Contains(loopbackNames[j])) * { * _audioDeviceIndex = i; * _audioDeviceName = sbName.ToString(); * } * } * } * if (_audioDeviceIndex >= 0) * break; * } * * if (_audioDeviceIndex < 0) * { * // Resort to the no recording device * _audioDeviceName = "Unity"; * _audioDeviceIndex = -1; * }*/ _audioDeviceName = "Unity"; _audioDeviceIndex = -1; } }
private void ConfigureCodec() { AVProMovieCapturePlugin.Init(); SelectCodec(false); if (_codecIndex >= 0) { AVProMovieCapturePlugin.ConfigureVideoCodec(_codecIndex); } //AVProMovieCapture.Deinit(); }
public virtual void EncodePointer(System.IntPtr ptr) { if (_audioCapture == null || (_audioDeviceIndex >= 0 || _noAudio)) { AVProMovieCapturePlugin.EncodeFrame(_handle, ptr); } else { AVProMovieCapturePlugin.EncodeFrameWithAudio(_handle, ptr, _audioCapture.BufferPtr, (uint)_audioCapture.BufferLength); _audioCapture.FlushBuffer(); } }
public override void UnprepareCapture() { AVProMovieCapturePlugin.SetTexturePointer(_handle, System.IntPtr.Zero); if (_renderTexture != null) { RenderTexture.ReleaseTemporary(_renderTexture); _renderTexture = null; } base.UnprepareCapture(); }
void Start() { if (AVProMovieCapturePlugin.Init()) { // Find the index for the video codec _videoCodecIndex = FindVideoCodecIndex(X264CodecName); } else { this.enabled = false; } }
private void OnRenderImage(RenderTexture source, RenderTexture dest) { #if false if (_capturing && !_paused) { while (_handle >= 0 && !AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(1); } if (_handle >= 0) { if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio) { uint bufferLength = (uint)_audioCapture.BufferLength; if (bufferLength > 0) { AVProMovieCapturePlugin.EncodeAudio(_handle, _audioCapture.BufferPtr, bufferLength); _audioCapture.FlushBuffer(); } } // In Direct3D the RT can be flipped vertically /*if (source.texelSize.y < 0) * { * * }*/ Graphics.Blit(_cubeTarget, _target, _cubemapToEquirectangularMaterial); #if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52 GL.IssuePluginEvent(_renderEventFunction, AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #else GL.IssuePluginEvent(AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #endif GL.InvalidateState(); UpdateFPS(); } } #endif // Pass-through if (_cubeTarget != null) { Graphics.Blit(_cubeTarget, dest, _cubemapToEquirectangularMaterial); } else { Graphics.Blit(source, dest); } }
public void ResumeCapture() { if (_capturing && _paused) { if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio) { _audioCapture.FlushBuffer(); } AVProMovieCapturePlugin.Start(_handle); _paused = false; } }
public override void UpdateFrame() { if (_capturing && !_paused) { if (_cubeTarget != null && _camera != null) { while (_handle >= 0 && !AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(1); } if (_handle >= 0) { if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio && _isRealTime) { uint bufferLength = (uint)_audioCapture.BufferLength; if (bufferLength > 0) { AVProMovieCapturePlugin.EncodeAudio(_handle, _audioCapture.BufferPtr, bufferLength); _audioCapture.FlushBuffer(); } } // In Direct3D the RT can be flipped vertically /*if (source.texelSize.y < 0) * { * * }*/ _cubeCamera.transform.position = _camera.transform.position; _cubeCamera.transform.rotation = _camera.transform.rotation; _cubeCamera.RenderToCubemap(_cubeTarget, 63); Graphics.Blit(_cubeTarget, _target, _cubemapToEquirectangularMaterial); AVProMovieCapturePlugin.SetTexturePointer(_handle, _target.GetNativeTexturePtr()); #if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52 GL.IssuePluginEvent(_renderEventFunction, AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #else GL.IssuePluginEvent(AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #endif GL.InvalidateState(); UpdateFPS(); } } } base.UpdateFrame(); }
private static int FindVideoCodecIndex(string name) { int result = -1; int numVideoCodecs = AVProMovieCapturePlugin.GetNumAVIVideoCodecs(); for (int i = 0; i < numVideoCodecs; i++) { if (AVProMovieCapturePlugin.GetAVIVideoCodecName(i) == name) { result = i; break; } } return(result); }
private IEnumerator FinalRenderCapture() { yield return(new WaitForEndOfFrame()); bool canGrab = true; if (IsUsingMotionBlur()) { // If the motion blur is still accumulating, don't grab this frame canGrab = _motionBlur.IsFrameAccumulated; } if (canGrab) { // Wait for the encoder to require a new frame to be sent while (_handle >= 0 && !AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(NewFrameSleepTimeMs); } // Send the new frame to encode if (_handle >= 0) { // Grab final RenderTexture into texture and encode if (IsRecordingUnityAudio()) { int audioDataLength = 0; System.IntPtr audioDataPtr = _audioCapture.ReadData(out audioDataLength); if (audioDataLength > 0) { AVProMovieCapturePlugin.EncodeAudio(_handle, audioDataPtr, (uint)audioDataLength); } } #if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52 GL.IssuePluginEvent(_renderEventFunction, AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #else GL.IssuePluginEvent(AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); #endif GL.InvalidateState(); UpdateFPS(); } } yield return(null); }
private IEnumerator FinalRenderCapture() { yield return(new WaitForEndOfFrame()); //System.Threading.Thread.Sleep(1000); while (!AVProMovieCapturePlugin.IsNewFrameDue(_handle)) { System.Threading.Thread.Sleep(8); } /*int frame = Time.frameCount; * if (frame - _lastFrame != 1) * { * Debug.Log("dropped: " + (frame - _lastFrame)); * } * _lastFrame = frame;*/ //System.Threading.Thread.Sleep(100); //if (IsNewFrameDue(_handle)) { // Grab final RenderTexture into texture and encode #if UNITY_3_5 || UNITY_4_1 || UNITY_4_0_1 || UNITY_4_0 if (!_isDirectX11) { if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio) { AVProMovieCapturePlugin.EncodeAudio(_handle, _audioCapture.BufferPtr, (uint)_audioCapture.BufferLength); _audioCapture.FlushBuffer(); } GL.IssuePluginEvent(AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle); } else { _texture.ReadPixels(new Rect(0, 0, _texture.width, _texture.height), 0, 0, false); EncodeTexture(_texture); } #else _texture.ReadPixels(new Rect(0, 0, _texture.width, _texture.height), 0, 0, false); EncodeTexture(_texture); #endif UpdateFPS(); } yield return(null); }
public void CreateVideoFromByteArray(string filePath, int width, int height, int frameRate) { byte[] frameData = new byte[width * height * 4]; GCHandle frameHandle = GCHandle.Alloc(frameData, GCHandleType.Pinned); // Start the recording session int encoderHandle = AVProMovieCapturePlugin.CreateRecorderAVI(filePath, (uint)width, (uint)height, frameRate, (int)AVProMovieCapturePlugin.PixelFormat.RGBA32, false, _videoCodecIndex, false, 0, 0, -1, -1, false, false, false); if (encoderHandle >= 0) { AVProMovieCapturePlugin.Start(encoderHandle); // Write out 100 frames int numFrames = 100; for (int i = 0; i < numFrames; i++) { // TODO: update the byte array with your data :) // Wait for the encoder to be ready for the next frame int numAttempts = 32; while (numAttempts > 0) { if (AVProMovieCapturePlugin.IsNewFrameDue(encoderHandle)) { // Encode the new frame AVProMovieCapturePlugin.EncodeFrame(encoderHandle, frameHandle.AddrOfPinnedObject()); break; } System.Threading.Thread.Sleep(1); numAttempts--; } } // End the session AVProMovieCapturePlugin.Stop(encoderHandle, false); AVProMovieCapturePlugin.FreeRecorder(encoderHandle); } if (frameHandle.IsAllocated) { frameHandle.Free(); } }
public void Awake() { try { AVProMovieCapturePlugin.Init(); Debug.Log("Using AVProMovieCapture plugin version: " + AVProMovieCapturePlugin.GetPluginVersion().ToString("F2")); } catch (DllNotFoundException e) { Debug.Log("Unity couldn't find the DLL, did you move the 'Plugins' folder to the root of your project?"); throw e; } _isDirectX11 = SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11"); SelectCodec(_listVideoCodecsOnStart); SelectAudioCodec(_listVideoCodecsOnStart); SelectAudioDevice(_listVideoCodecsOnStart); }
public virtual void EncodePointer(System.IntPtr ptr) { if (_audioCapture == null || (_audioDeviceIndex >= 0 || _noAudio) && !_isRealTime) { AVProMovieCapturePlugin.EncodeFrame(_handle, ptr); } else { int audioDataLength = 0; System.IntPtr audioDataPtr = _audioCapture.ReadData(out audioDataLength); if (audioDataLength > 0) { AVProMovieCapturePlugin.EncodeFrameWithAudio(_handle, ptr, audioDataPtr, (uint)audioDataLength); } else { AVProMovieCapturePlugin.EncodeFrame(_handle, ptr); } } }
protected void EncodeTexture(Texture2D texture) { Color32[] bytes = texture.GetPixels32(); GCHandle _frameHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned); if (_audioCapture == null || (_audioDeviceIndex >= 0 || _noAudio)) { AVProMovieCapturePlugin.EncodeFrame(_handle, _frameHandle.AddrOfPinnedObject()); } else { AVProMovieCapturePlugin.EncodeFrameWithAudio(_handle, _frameHandle.AddrOfPinnedObject(), _audioCapture.BufferPtr, (uint)_audioCapture.BufferLength); _audioCapture.FlushBuffer(); } if (_frameHandle.IsAllocated) { _frameHandle.Free(); } }
public virtual void EncodePointer(System.IntPtr ptr) { if (!IsRecordingUnityAudio()) { AVProMovieCapturePlugin.EncodeFrame(_handle, ptr); } else { int audioDataLength = 0; System.IntPtr audioDataPtr = _audioCapture.ReadData(out audioDataLength); if (audioDataLength > 0) { AVProMovieCapturePlugin.EncodeFrameWithAudio(_handle, ptr, audioDataPtr, (uint)audioDataLength); } else { AVProMovieCapturePlugin.EncodeFrame(_handle, ptr); } } }
public virtual void PrepareCapture() { // Disable vsync if (QualitySettings.vSyncCount > 0) { _oldVSyncCount = QualitySettings.vSyncCount; //Debug.LogWarning("For best results vsync should be disabled during video capture. Disabling vsync."); QualitySettings.vSyncCount = 0; } if (_isRealTime) { Application.targetFrameRate = (int)_frameRate; } else { Time.captureFramerate = (int)_frameRate; } Debug.Log("[AVProMovieCapture] New movie capture: (" + _targetWidth + "x" + _targetHeight + " @ " + ((int)_frameRate).ToString() + "fps) to file '" + _filePath + "'"); Debug.Log("[AVProMovieCapture] Using video codec: '" + _codecName + "' audio device: '" + _audioDeviceName + "'"); int audioDeviceIndex = _audioDeviceIndex; int audioCodecIndex = _audioCodecIndex; bool noAudio = _noAudio; if (_noAudio || (_audioCapture == null && _audioCodecIndex < 0)) { audioCodecIndex = audioDeviceIndex = -1; noAudio = true; } _handle = AVProMovieCapturePlugin.CreateRecorderAVI(_filePath, (uint)_targetWidth, (uint)_targetHeight, (int)_frameRate, (int)(_pixelFormat), _isTopDown, _codecIndex, !noAudio, audioDeviceIndex, audioCodecIndex, _isRealTime); if (_handle < 0) { Debug.LogWarning("[AVProMovieCapture] Failed to create recorder"); StopCapture(); } }