Exemplo n.º 1
0
        public ImageOverlayFileConfig ImageOverlayConfigCal(ImageOverlayFileConfig f)
        {
            var arr = _videoScale.Split(':');

            var w    = int.Parse(arr[0]);
            var h    = int.Parse(arr[1]);
            var temp = new ImageOverlayFileConfig();

            temp.FullPathFile = f.FullPathFile;
            temp.FromSeconds  = f.FromSeconds;
            temp.Duration     = f.Duration;

            if (f.X == 0 || f.Y == 0)
            {
                temp.X = _rnd.Next(0, w / 2);
                temp.Y = _rnd.Next(0, h / 2);
            }
            else
            {
                temp.Y = f.Y;
                temp.X = f.X;
            }

            temp.Width  = f.Width;
            temp.Height = f.Width;

            if (f.Width == 0 && f.Height == 0)
            {
                temp.Scale = _gifScaleConst[_rnd.Next(0, _gifScaleConst.Count - 1)];
            }
            else
            {
                temp.Scale = "320:240";

                if (f.Width == 0 && f.Height != 0)
                {
                    temp.Width = temp.Height * w / h;
                }
                if (f.Width != 0 && f.Height == 0)
                {
                    temp.Height = temp.Width * h / w;
                }

                temp.Scale = $"{temp.Width}:{temp.Height}";
            }

            if (temp.Scale == _videoScale)
            {
                temp.X = 0;
                temp.Y = 0;
            }

            return(temp);
        }
Exemplo n.º 2
0
        public FFmpegCommandBuilder AddImageOverLay(string file, int fromSenconds, int duration = 2, int positionX = 0, int positionY = 0, int width = 0, int height = 0)
        {
            var itm = new ImageOverlayFileConfig
            {
                FullPathFile = file,
                FromSeconds  = fromSenconds,
                Duration     = duration,
                Height       = height,
                Width        = width,
                X            = positionX,
                Y            = positionY,
                IsGif        = false
            };

            _fileImageOverlay.Add(itm);
            return(this);
        }