Esempio n. 1
0
        public static void StopRecording()
        {
            if (!Recording)
            {
                return;
            }

            Duration += (Time.time - StartTime);

            if (!Recording)
            {
                return;
            }

            Recording = false;

            //while(FfmpegFrameSent < FfmpegFrameRendered)
            //{
            //    Thread.Sleep(50);
            //}

            FfmpegStream.Close();
            FfmpegStream = null;
            FfmpegProcess.Close();
            FfmpegProcess = null;

            Time.captureFramerate = 0;

            RecordingStopped();
        }
Esempio n. 2
0
        public static void RenderedFrame(RenderTexture rt)
        {
            if (!Recording)
            {
                return;
            }

            var prevRt = RenderTexture.active;

            RenderTexture.active = rt;

            if (img == null)
            {
                img = new Texture2D(rt.width, rt.height);
            }
            img.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
            img.Apply();

            RenderTexture.active = prevRt;

            //Instance.StartCoroutine(SendToFfmpeg(img, FfmpegFrameRendered++));

            var bytes = img.EncodeToJPG(JpegQuality);

            FfmpegStream.Write(bytes, 0, bytes.Length);
            FfmpegStream.Flush();

            FrameTotal++;
        }