public void Dispose()
        {
            if (_readingTask != null)
            {
                try
                {
                    _readingTask.Abort();
                }
                catch
                {
                }
                _readingTask = null;
            }

            if (_filereader != null)
            {
                try
                {
                    _filereader.Abort();
                }
                catch
                {
                }
                _filereader = null;
            }

            if (FrameDecoder != null)
            {
                FrameDecoder.ClearBuffer();

                try
                {
                    FrameDecoder.Dispose();
                }
                catch
                {
                }
                FrameDecoder = null;
            }
        }
        public void Start(bool open = true, string customArgs = "", int?FrameBufferCapacity = null, int?MinimumWorkingFrames = null)
        {
            if (open)
            {
                Open(VideoPath);
            }

            _filereader = new FFMpegConverter();

            if (FrameDecoder != null)
            {
                FrameDecoder.ClearBuffer();
            }

            //Set the format of the output bitmap
            FrameDecoder = new FrameDecoder
                           (
                PlayerOutputWidth,
                PlayerOutputHeight,
                PixelFormat.Format24bppRgb
                           );

            if (FrameBufferCapacity != null)
            {
                FrameDecoder.FrameBufferCapacity = (int)FrameBufferCapacity;
            }

            if (MinimumWorkingFrames != null)
            {
                FrameDecoder.MinimumWorkingFrames = (int)MinimumWorkingFrames;
            }

            BufferInitialized?.Invoke(this, null);

            FrameDecoder.Processor       = Processor;
            FrameDecoder.FrameReady     += OnFrameReady;
            _filereader.LogReceived     += OnLogReceived;
            _filereader.ConvertProgress += _filereader_ConvertProgress;

            //Set conversion settings
            _settings = new ConvertSettings
            {
                VideoFrameSize   = PlayerOutputWidth + "x" + PlayerOutputHeight,
                CustomOutputArgs = " -pix_fmt bgr24 " + customArgs,
            };

            //Set start time
            if (PlayStartTimeInSec > 0)
            {
                //Adjust frame index for seeking
                CurrentFrame = (int)Math.Round(PlayStartTimeInSec * VideoInfo.FPS, 0);

                _settings.Seek = (float?)PlayStartTimeInSec;
            }

            //Set end time (if valid)
            if (PlayEndTimeInSec != null && PlayEndTimeInSec > PlayStartTimeInSec)
            {
                _settings.MaxDuration = (float?)(PlayEndTimeInSec - PlayStartTimeInSec);
            }

            //Setup to convert from the file into the bitmap intercepting stream
            _readingTask = _filereader.ConvertLiveMedia
                           (
                VideoPath,
                null,     // autodetect stream format
                FrameDecoder,
                "rawvideo",
                _settings
                           );

            _readingThread = new Thread(StartDecoding)
            {
                IsBackground = true
            };
            _readingThread.Start();
        }