Exemple #1
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            var FFMPEGPath      = ffmpegPath.Get(context);
            var FFMPEGDirectory = FFMPEGPath.Substring(0, FFMPEGPath.LastIndexOf('\\'));

            FFMPEGPath = '"' + FFMPEGPath + '"';
            var inputFile       = InputFile.Get(context);
            var outputFolder    = OutputFolder.Get(context);
            var outputContainer = OutputContainer.Get(context);
            var command         = Command.Get(context);
            var lutFile         = LUTFile.Get(context);
            var debuggingMode   = DebuggingMode.Get(context);

            var startInfo = new ProcessStartInfo(FFMPEGPath);

            startInfo.WindowStyle      = ProcessWindowStyle.Normal;
            startInfo.WorkingDirectory = FFMPEGDirectory;

            string inputContainer = inputFile.Substring(inputFile.LastIndexOf('.'));

            if (outputContainer == "")
            {
                outputContainer = inputContainer;
            }

            string fileNameWithoutExtensions = inputFile.Replace(inputContainer, "");
            var    fileName = fileNameWithoutExtensions.Substring(fileNameWithoutExtensions.LastIndexOf(@"\"));

            fileName = fileName.Replace(@"\", "");

            lutFile = lutFile.Replace(@"\", @"/");
            lutFile = lutFile.Replace(@":", @"\\:");

            var uniqueId = (DateTime.Now.Ticks - new DateTime(2016, 1, 1).Ticks).ToString("x");

            startInfo.Arguments = "-i " + '"' + inputFile + '"' + " " + "-vf lut3d=" + '"' + lutFile + '"' + " " + command + " " + '"' + outputFolder + @"\" + uniqueId + "." + outputContainer + '"';


            if (debuggingMode)
            {
                var processn = new Process();
                processn.StartInfo           = startInfo;
                processn.EnableRaisingEvents = true;
                processn.StartInfo.FileName  = "CMD.EXE";
                processn.StartInfo.Arguments = "/K " + '"' + @FFMPEGPath + " " + startInfo.Arguments + '"';
                processn.Start();
                processn.WaitForExit();
            }
            else
            {
                var processn = Process.Start(startInfo);
                processn.EnableRaisingEvents = true;

                processn.WaitForExit();
            }

            // Outputs
            return((ctx) => {
            });
        }
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            var FFMPEGPath      = ffmpegPath.Get(context);
            var FFMPEGDirectory = FFMPEGPath.Substring(0, FFMPEGPath.LastIndexOf('\\'));

            FFMPEGPath = '"' + FFMPEGPath + '"';
            var videoFile       = VideoFile.Get(context);
            var outputFolder    = OutputFolder.Get(context);
            var outputContainer = OutputContainer.Get(context);
            var command         = Command.Get(context);
            var audioFile       = AudioFile.Get(context);
            var debuggingMode   = DebuggingMode.Get(context);

            var startInfo = new ProcessStartInfo(FFMPEGPath);

            startInfo.WindowStyle      = ProcessWindowStyle.Normal;
            startInfo.WorkingDirectory = FFMPEGDirectory;

            /*
             * string inputContainer = videoFile.Substring(videoFile.LastIndexOf('.'));
             * if (outputContainer == "")
             * {
             *  outputContainer = inputContainer;
             * }*/

            /*
             * string fileNameWithoutExtensions = videoFile.Replace(inputContainer, "");
             * var fileName = fileNameWithoutExtensions.Substring(fileNameWithoutExtensions.LastIndexOf(@"\"));
             * fileName = fileName.Replace(@"\", "");*/


            var uniqueId = (DateTime.Now.Ticks - new DateTime(2016, 1, 1).Ticks).ToString("x");

            startInfo.Arguments = "-i " + '"' + videoFile + '"' + " " + "-i " + '"' + audioFile + '"' + " -c copy -map 0:v -map 1:a -shortest " + '"' + outputFolder + @"\" + uniqueId + "." + outputContainer + '"'; // DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss");

            if (debuggingMode)
            {
                var processn = new Process();
                processn.StartInfo           = startInfo;
                processn.EnableRaisingEvents = true;
                processn.StartInfo.FileName  = "CMD.EXE";
                processn.StartInfo.Arguments = "/K " + '"' + @FFMPEGPath + " " + startInfo.Arguments + '"';
                processn.Start();
                processn.WaitForExit();
            }
            else
            {
                var processn = Process.Start(startInfo);
                processn.EnableRaisingEvents = true;

                processn.WaitForExit();
            }

            // Outputs
            return((ctx) => {
            });
        }
Exemple #3
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            var FFMPEGPath      = ffmpegPath.Get(context);
            var FFMPEGDirectory = FFMPEGPath.Substring(0, FFMPEGPath.LastIndexOf('\\'));

            FFMPEGPath = '"' + FFMPEGPath + '"';
            var inputFile       = InputFile.Get(context);
            var outputFolder    = OutputFolder.Get(context);
            var outputContainer = OutputContainer.Get(context);
            var command         = Command.Get(context);
            var fontFile        = FontFile.Get(context);
            var debuggingMode   = DebuggingMode.Get(context);
            var text            = Text.Get(context);


            string tempPath     = Path.GetTempPath();
            var    fontFileName = fontFile.Substring(fontFile.LastIndexOf(@"\"));

            fontFileName = fontFileName.Replace(@"\", "");

            String fontFilePath = Path.Combine(tempPath, fontFileName);

            if (!System.IO.File.Exists(fontFilePath))
            {
                System.IO.File.Copy(fontFile, fontFilePath, true);
            }

            var startInfo = new ProcessStartInfo(FFMPEGPath);

            startInfo.WindowStyle      = ProcessWindowStyle.Normal;
            startInfo.WorkingDirectory = tempPath;

            string inputContainer = inputFile.Substring(inputFile.LastIndexOf('.'));

            if (outputContainer == "")
            {
                outputContainer = inputContainer;
            }

            string fileNameWithoutExtensions = inputFile.Replace(inputContainer, "");
            var    fileName = fileNameWithoutExtensions.Substring(fileNameWithoutExtensions.LastIndexOf(@"\"));

            fileName = fileName.Replace(@"\", "");

            var uniqueId = (DateTime.Now.Ticks - new DateTime(2016, 1, 1).Ticks).ToString("x");

            startInfo.Arguments = "-i " + '"' + inputFile + '"' + " " + "-vf drawtext=enable='between(t,2,8)':\"fontfile = " + fontFileName + '"' + ":text=\"" + text + "\":fontcolor=white:fontsize=124:x=(w-text_w)/2:y=(h-text_h)/2 " + command + " " + '"' + outputFolder + @"\" + uniqueId + "." + outputContainer + '"';

            if (debuggingMode)
            {
                var processn = new Process();
                processn.StartInfo           = startInfo;
                processn.EnableRaisingEvents = true;
                processn.StartInfo.FileName  = "CMD.EXE";
                processn.StartInfo.Arguments = "/K " + '"' + @FFMPEGPath + " " + startInfo.Arguments + '"';
                processn.Start();
                processn.WaitForExit();
            }
            else
            {
                var processn = Process.Start(startInfo);
                processn.EnableRaisingEvents = true;

                processn.WaitForExit();
            }

            // Outputs
            return((ctx) => {
            });
        }