Exemple #1
0
        private TextWriter OpenOutput()
        {
            if (OutputPath == null || OutputPath.Equals("STDOUT"))
            {
                return(Console.Out);
            }

            return(new StreamWriter(File.Open(OutputPath, FileMode.Create)));
        }
Exemple #2
0
        /// <summary>
        /// Start processing the compositions.
        /// </summary>
        /// <returns>Number of successful conversions</returns>
        public int Process()
        {
            if (Compositions == null || FFmpegPath == null)
            {
                return(0);
            }
            int finished = 0;

            failures = new StringBuilder();
            foreach (string composition in Compositions)
            {
                if (!File.Exists(composition))
                {
                    continue;
                }
                string title = Finder.GetCPLTitle(composition);
                OnStatusUpdate?.Invoke($"Processing {title}...");
                string finalOutput = OutputPath, sourceFolder = composition.Substring(0, composition.LastIndexOf('\\'));
                if (!string.IsNullOrEmpty(OutputPath) && OutputPath.Equals(parentMarker))
                {
                    int index = sourceFolder.LastIndexOf('\\');
                    if (index < 0)
                    {
                        failures.AppendLine("Drive root is an invalid directory: " + title);
                        continue;
                    }
                    finalOutput = sourceFolder.Substring(0, index);
                }
                CompositionProcessor processor = new CompositionProcessor(FFmpegPath, composition)
                {
                    ForcePath         = finalOutput,
                    Overwrite         = Overwrite,
                    VideoFormat       = VideoFormat,
                    ChromaSubsampling = ChromaSubsampling,
                    CRF         = CRF,
                    CRF3D       = CRF3D,
                    StereoMode  = StereoMode,
                    AudioFormat = AudioFormat
                };
                if (processor.ProcessComposition(Force2K))
                {
                    ++finished;
                    if (ZipAfter)
                    {
                        OnStatusUpdate?.Invoke($"Zipping {title}...");
                        Finder.ZipAssets(sourceFolder, $"{finalOutput}\\{title}.zip", textOut => OnStatusUpdate(textOut));
                    }
                    if (DeleteAfter)
                    {
                        Finder.DeleteAssets(sourceFolder);
                    }
                }
                else
                {
                    failures.AppendLine("Conversion error: " + title);
                }
            }
            OnStatusUpdate?.Invoke("Finished!");
            OnCompletion?.Invoke(finished);
            return(finished);
        }