Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        private void Init(MediaFrame frame, bool reinit = false)
        {
            if (_inited && !reinit)
            {
                return;
            }

            if (_ffimp != null)
            {
                _ffimp.Release();
            }

            _inited = true;
            _width  = frame.nWidth;
            _height = frame.nHeight;
            _ffimp  = new FFImp(AVCodecCfg.CreateVideo(_width, _height), true, true);
            if (_yuvDraw == null && _control != null)
            {
                _yuvDraw = new YUVGDIDraw(_control);
            }
            _yuvDraw.SetSize(_width, _height);

            _yuvDataBuffer = new byte[_width * _height * 3 / 2];

            _drawHandle = new Action <byte[]>(Draw);
        }
Ejemplo n.º 3
0
        public static VideoEncodeCfg GetDefaule(IYUVDraw _Draw = null)
        {
            VideoEncodeCfg encCfg = new VideoEncodeCfg();

            encCfg.SetEncoder("H264");
            encCfg.VideoBitRate = 256 * 1000;
            encCfg.FrameRate    = 10;
            encCfg.Height       = 240;
            encCfg.Width        = 320;
            encCfg.CameraId     = 0;
            encCfg.Draw         = _Draw;
            return(encCfg);
        }
Ejemplo n.º 4
0
 public MediaPlayer(IYUVDraw yuvDraw, bool isRealPlay = true, bool isCachePlay = false)
 {
     //if (System.Configuration.ConfigurationSettings.AppSettings["AudioPlayMode"] == "SDL")
     //    _ap = new SDLAudioPlayer();
     //else
     _ap        = new WaveAudioPlayer();
     _vp        = new VideoPlayer(yuvDraw);
     IsReadPlay = isRealPlay;
     BuffTime   = 0;
     if (isCachePlay)
     {
         _IgnoreVideoPlay = true;
     }
 }
Ejemplo n.º 5
0
        public static VideoEncodeCfg GetDefaule(IYUVDraw _Draw = null)
        {
            VideoEncodeCfg encCfg = new VideoEncodeCfg
            {
                VideoBitRate = 256 * 1000,
                FrameRate    = 10,
                Height       = 240,
                Width        = 320,
                CameraId     = 0,
                Draw         = _Draw
            };

            encCfg.SetEncoder("H264");
            return(encCfg);
        }
Ejemplo n.º 6
0
 public VideoPlayer(IYUVDraw draw)
 {
     _yuvDraw = draw;
 }