示例#1
0
        public CameraEncoder(VideoEncodeCfg cfgVideo, Action <MediaFrame> callBack, Canvas canvas = null)
        {
            _cfgVideo   = cfgVideo;
            _fps        = cfgVideo.FrameRate;
            this.Canvas = canvas;
            _capturer   = CreateCapturer();
            var @params = new X264Params(_cfgVideo.Width, _cfgVideo.Height, _fps, cfgVideo.VideoBitRate);

            if (cfgVideo.Params.ContainsKey("X264Encode"))
            {
                @params.method = (int)cfgVideo.Params["X264Encode"];
            }

            if (cfgVideo.Params.ContainsKey("KeyFrameRate"))
            {
                @params.key_frame_max = (int)cfgVideo.Params["KeyFrameRate"];
            }


            _x264 = new X264Native(@params);
            _x264.Init();
            _ffscale = new FFScale(_cfgVideo.Width, _cfgVideo.Height, 0, 12, _cfgVideo.Width, _cfgVideo.Height, 12, 12);
            _draw    = cfgVideo.Draw;
            _draw.SetSize(_cfgVideo.Width, _cfgVideo.Height);
            _callBack = callBack;
        }
示例#2
0
 public X264Native(X264Params p)
 {
     Bitrate = p.bitrate;
     _outBuf = new byte[p.width * p.height * 4];
     byte[] b = FunctionEx.StructToBytes(p);
     obj = X264Native_New(b);
     _DLastX264Native = this;
 }