コード例 #1
0
        public static void CreateSlideShow(FFMpegSlideShowTask joiner)
        {
            var handler = new ConsoleApplicationHandler();

            handler.ExePath          = EnvironmentInfo.GetExecutablePath("ffmpeg");
            handler.WorkingDirectory = joiner.WorkingFolder;
            var    sb      = new StringBuilder();
            int    rate    = (int)joiner.SlidesPerSecond;
            string ratestr = rate.ToString();

            if (joiner.SlidesPerSecond < 1)
            {
                rate    = System.Convert.ToInt32(1 / joiner.SlidesPerSecond);
                ratestr = "1/" + rate;
            }
            sb.Append(" -framerate ");
            sb.Append(ratestr);
            sb.Append(" -i ");
            sb.Append(joiner.FileNameBase);
            sb.Append("%0");
            sb.Append(joiner.DigitCount);
            sb.Append("d.png");
            sb.Append(" -c:v libx264 -y ");
            var fps = joiner.Fps.ToString();

            if (0 == joiner.Fps)
            {
                fps = "25";
            }
            sb.Append(" -r ");
            sb.Append(fps);
            sb.Append(" -pix_fmt yuv420p ");
            if (joiner.Height != 0 && joiner.Width != 0)
            {
                sb.Append(" -s ");
                sb.Append(joiner.Width);
                sb.Append("x");
                sb.Append(joiner.Height);
            }
            sb.Append(" \"");
            sb.Append(joiner.TargetFile);
            sb.Append("\"");
            handler.Arguments = sb.ToString();
            var result = handler.RunSync();

            if (!result.IsOK)
            {
                throw new Exception(result.Output + result.Error, result.Exception);
            }
        }
コード例 #2
0
 public static void SplitImages(FFMpegVideoSplitTask splitter)
 {
     if (string.IsNullOrWhiteSpace(splitter.WorkingFolder))
     {
         splitter.WorkingFolder = Path.GetDirectoryName(splitter.SourceFile);
     }
     Directory.CreateDirectory(splitter.WorkingFolder);
     for (var i = 0; i < splitter.Frames.Count; i++)
     {
         var frame    = splitter.Frames[i];
         var num      = (i + 1).ToString("00");
         var filename = splitter.FileNameBase + num + ".png";
         if (splitter.DigitCount == 0 && splitter.Frames.Count == 1)
         {
             filename = splitter.FileNameBase + ".png";
         }
         filename = Path.Combine(splitter.WorkingFolder, filename);
         var handler = new ConsoleApplicationHandler();
         handler.ExePath = EnvironmentInfo.GetExecutablePath("ffmpeg");
         var sb = new StringBuilder();
         sb.Append(" -ss ");
         sb.Append(frame.StartTime);
         sb.Append(" -i ");
         sb.Append("\"");
         sb.Append(splitter.SourceFile);
         sb.Append("\" ");
         sb.Append(" -vframes 1 ");
         if (splitter.Height != 0 && splitter.Width != 0)
         {
             sb.Append(" -s ");
             sb.Append(splitter.Width);
             sb.Append("x");
             sb.Append(splitter.Height);
         }
         sb.Append(" -y -f image2 ");
         sb.Append("\"");
         sb.Append(filename);
         sb.Append("\"");
         handler.Arguments = sb.ToString();
         var result = handler.RunSync();
         if (!result.IsOK)
         {
             throw new Exception(result.Output + result.Error, result.Exception);
         }
     }
 }
コード例 #3
0
        private BSharpFileBasedClassProvider GetOldStyleClsProvider(string rev)
        {
            var clsProvider = new BSharpFileBasedClassProvider();

            if (rev == "HEAD")
            {
                rev = _context.GitBranch;
            }
            if (!string.IsNullOrWhiteSpace(rev))
            {
                _context.Log.Trace("reset GIT pre " + rev);
                _githelper.Reset(true);
                _githelper.Clean(true);
                _context.Log.Trace("begin checkout " + rev);
                _githelper.Checkout(rev);
                _context.ResolvedUpdateRevision = _githelper.GetCommitId();

                _context.Log.Trace("end checkout " + rev);
                var bscStarter = new ConsoleApplicationHandler();
                bscStarter.ExePath          = "bsc";
                bscStarter.WorkingDirectory = Path.Combine(_context.RootDirectory, _context.ProjectDirectory);
                if (!string.IsNullOrWhiteSpace(_context.ProjectName))
                {
                    bscStarter.Arguments = _context.ProjectName;
                }
                _context.Log.Trace("start bsc");
                var bscResult = bscStarter.RunSync();
                _context.Log.Trace("finish bsc");

                if (bscResult.IsOK)
                {
                    _context.Log.Trace("ok bsc");

                    clsProvider = new BSharpFileBasedClassProvider {
                        RootDirectory = Path.Combine(_context.RootDirectory, _context.OutputDirectory)
                    };
                }
                else
                {
                    _context.Log.Error("error in bsc " + bscResult.Error, bscResult.Exception);
                    throw new Exception("bsharp compile exception " + bscResult.Error, bscResult.Exception);
                }
            }
            return(clsProvider);
        }
コード例 #4
0
        /// <summary>
        ///     Выполняет компиляцию директории и/или проекта с возвратом XML
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="projectname"></param>
        /// <returns></returns>
        public static XElement ExecuteXml(string dir, string projectname = null)
        {
            var consoleCall = new ConsoleApplicationHandler {
                ExePath          = EnvironmentInfo.GetExecutablePath("bsc"),
                Encoding         = Encoding.UTF8,
                WorkingDirectory =
                    string.IsNullOrWhiteSpace(dir) ? EnvironmentInfo.RootDirectory : EnvironmentInfo.ResolvePath(dir),
                Arguments = string.Format(" {0} --console-mode", projectname),
                NoWindow  = true,
                Timeout   = 20000,
                Redirect  = true
            };
            var result = consoleCall.RunSync();

            if (result.IsOK)
            {
                return(XElement.Parse(result.Output));
            }
            throw new Exception(result.Error + " " + result.Exception);
        }
コード例 #5
0
        public static void Convert(FFMpegConvertTask task)
        {
            var handler = new ConsoleApplicationHandler();

            handler.ExePath = EnvironmentInfo.GetExecutablePath("ffmpeg");

            var sb = new StringBuilder();

            sb.Append(" -i ");
            sb.Append(task.SourceFile);
            sb.Append(" -acodec aac -strict -2 -b:a 128k -vcodec libx264 -b:v 1200k -y ");
            if (task.Height != 0 && task.Width != 0)
            {
                sb.Append(" -s ");
                sb.Append(task.Width);
                sb.Append("x");
                sb.Append(task.Height);
            }
            sb.Append(" -ss ");
            sb.Append(task.StartTime);
            sb.Append(" -t ");
            if (task.Duration.TotalMilliseconds < 100)
            {
                sb.Append("05:00:00");
            }
            else
            {
                sb.Append(task.Duration);
            }
            sb.Append(" -flags +aic+mv4 ");
            sb.Append(" \"");
            sb.Append(task.TargetFile);
            sb.Append("\"");
            handler.Arguments = sb.ToString();
            var result = handler.RunSync();

            if (!result.IsOK)
            {
                throw new Exception(result.Output + result.Error, result.Exception);
            }
        }
コード例 #6
0
        public static void Join(FFMpegVideoJoinTask joiner)
        {
            var joinfile = CreateConcatFile(joiner);
            var handler  = new ConsoleApplicationHandler();

            handler.ExePath = EnvironmentInfo.GetExecutablePath("ffmpeg");
            var sb = new StringBuilder();

            sb.Append(" -f concat");
            sb.Append(" -i \"" + joinfile + "\" ");
            sb.Append(" -c copy ");
            sb.Append(" \"");
            sb.Append(joiner.TargetFile);
            sb.Append("\"");
            handler.Arguments = sb.ToString();
            var result = handler.RunSync();

            if (!result.IsOK)
            {
                throw new Exception(result.Output + result.Error, result.Exception);
            }
        }