Exemplo n.º 1
0
        public bool TryDecode(ref VideoPacket packet, out VideoFrame frame)
        {
            if (_videoDecoder == null)
                _videoDecoder = new VideoDecoder();

            frame = new VideoFrame();
            FFmpegNative.AVFrame avFrame;
            if (_videoDecoder.TryDecode(ref packet.Data, out avFrame))
            {
                if (_videoConverter == null)
                    _videoConverter = new VideoConverter(PixelFormatHelper.ToAVPixelFormat(_pixelFormat));

                frame.Timestamp = packet.Timestamp;
                frame.FrameNumber = packet.FrameNumber;
                frame.PixelFormat = _pixelFormat;
                frame.Data = _videoConverter.ConvertFrame(avFrame);

                return true;
            }
            return false;
        }
Exemplo n.º 2
0
        public bool TryDecode(ref VideoPacket packet, out VideoFrame frame)
        {
            if (_videoDecoder == null)
                _videoDecoder = new VideoDecoder();

            frame = new VideoFrame();
            AVFrame avFrame;
            if (_videoDecoder.TryDecode(ref packet.Data, out avFrame))
            {
                if (_videoConverter == null)
                    _videoConverter = new VideoConverter(_pixelFormat.ToAVPixelFormat());

                frame.Timestamp = packet.Timestamp;
                frame.FrameNumber = packet.FrameNumber;
                frame.Width = packet.Width;
                frame.Height = packet.Height;
                frame.PixelFormat = _pixelFormat;
                frame.Data = _videoConverter.ConvertFrame(avFrame);

                return true;
            }
            return false;
        }