Unosquare.FFmpegMediaElement.FFmpegMediaFrameCache.GetFrame C# (CSharp) Method

GetFrame() public method

Gets a frame at the given render time.
public GetFrame ( decimal renderTime, bool checkBounds ) : FFmpegMediaFrame
renderTime decimal The render time.
checkBounds bool
return FFmpegMediaFrame
        public FFmpegMediaFrame GetFrame(decimal renderTime, bool checkBounds)
        {
            lock (SyncLock)
            {
                if (Frames.Count <= 0) return null;
                if (checkBounds && renderTime < this.StartTime) return null;
                if (checkBounds && renderTime > this.EndTime) return null;

                if (renderTime < Frames[0].StartTime) return Frames[0];

                return SearchFrame(renderTime);
            }

        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Renders the video image. This method is called on a Dispatcher timer.
        /// It is responsible for rendering the decoded video image continuously.
        /// It also avoids rendering the same image again.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void RenderVideoImage(object sender, EventArgs e)
        {
            MediaFramesExtractedDone.Wait(Constants.FrameExtractorWaitMs);
            var renderTime = RealtimeClock.PositionSeconds;

            try
            {
                var videoFrame = VideoFramesCache.GetFrame(renderTime, false);
                if (videoFrame == null || videoFrame == LastRenderedVideoFrame)
                {
                    return;
                }
                if (videoFrame.PictureBufferPtr != IntPtr.Zero)
                {
                    VideoRenderer.Lock();
                    Helper.NativeMethods.RtlMoveMemory(VideoRenderer.BackBuffer, videoFrame.PictureBufferPtr, videoFrame.PictureBufferLength);
                    VideoRenderer.AddDirtyRect(new Int32Rect(0, 0, VideoRenderer.PixelWidth, VideoRenderer.PixelHeight));
                    VideoRenderer.Unlock();
                    LastRenderedVideoFrame = videoFrame;
                }
            }
            finally
            {
                this.Position = renderTime;
            }
        }
All Usage Examples Of Unosquare.FFmpegMediaElement.FFmpegMediaFrameCache::GetFrame