コード例 #1
0
 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();
     }
 }
コード例 #2
0
    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();
        }
    }
コード例 #3
0
 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);
         }
     }
 }
コード例 #4
0
 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);
         }
     }
 }
コード例 #5
0
    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();
        }
    }