Ejemplo n.º 1
0
        void proxy_NewFrame(object sender, NewFrameEventArgs e)
        {
            FFMPEGProxy proxy = sender as FFMPEGProxy;
            var         frame = e.NewFrame;

            if (proxy == null || frame == null)
            {
                return;
            }

            Dispatcher.Invoke(new Action
                                  (() =>
            {
                if (!IsBitmapValid(frame))
                {
                    double ratio = proxy.GuessAspectRatio(frame);
                    if (ratio == 0)
                    {
                        ratio = 16 / 9;
                    }
                    bitmapFrame = new WriteableBitmap(
                        frame.Width,
                        frame.Height, 96, 96 * ratio, PixelFormats.Pbgra32
                        , null
                        );
                    videodest.Source = bitmapFrame;
                }

                bitmapFrame.Lock();
                proxy.CopyToBuffer(frame, bitmapFrame.BackBuffer, bitmapFrame.BackBufferStride);
                bitmapFrame.AddDirtyRect(new Int32Rect(0, 0, frame.Width, frame.Height));
                bitmapFrame.Unlock();
            }));
            //  e.NewFrame
        }
Ejemplo n.º 2
0
        void GuessAspectRatio()
        {
            FFMPEGProxy testProxy = new FFMPEGProxy();

            Assert.ThrowsAny <ArgumentNullException>(() => testProxy.GuessAspectRatio(null));
        }