Ejemplo n.º 1
0
        static void UpdateFrame(object sender, ElapsedEventArgs e)
        {
            if (updateFrameProcessing)
            {
                WriteLog("Skip UpdateFrame. UpdateFrameProcessing...");
                return;
            }
            try
            {
                updateFrameProcessing = true;
                var frame = videoInputStream.Read();
                if (frame != null)
                {
                    lastOriginalFrame = frame.Clone();

                    if (frame.Size() != GetOutputSize(frame.Size()))
                    {
                        var x = frame;
                        frame = frame.Resize(GetOutputSize(frame.Size()));
                        x.Dispose();
                    }
                    if (!string.IsNullOrEmpty(caption?.Caption))
                    {
                        var x = frame;
                        frame = PutCaption(frame, caption, captionFont);
                        x.Dispose();
                    }
                    videoLiveStream.Write(frame.Clone());
                    lock (syncOutput)
                    {
                        if (videoOutputStream != null)
                        {
                            //WriteLog($"videoOutputStream.Write");
                            videoOutputStream.Write(frame);
                        }
                    }
                    lastFrame = frame;
                }
            }
            finally
            {
                updateFrameProcessing = false;
            }
        }