Exemple #1
0
        protected async override void OnShown(EventArgs e)
        {
            base.OnShown(e);
            if (!FFmpegService.FFmpegExists)
            {
                this.Enabled = false;
                await FFmepgDownload.DownloadArchive((i) =>
                {
                    this.Text = $"下载中{i}%";
                }, cancellationTokenSource.Token);

                this.Enabled = true;
            }
            videoFileReader = new VideoFileReader()
            {
                FPS = 25
            };
            videoFileReader.Open("Videos/girl.mp4");
            await Task.Run(() =>
            {
                foreach (var frame in videoFileReader.ReadVideoFrames(size: this.ClientSize, readByNativeFrame: true, cancellationToken: cancellationTokenSource.Token))
                {
                    using (frame.FrameBitmap)
                        using (Graphics g = this.CreateGraphics())
                        {
                            g.DrawImage(frame.FrameBitmap, 0, 0);
                        }
                }
            });
        }