Beispiel #1
0
        /// <summary>
        ///     ''' Performs the whole job.
        ///     ''' </summary>
        ///     ''' <returns>True if job was successful</returns>
        public bool Run()
        {
            bool successful = false;

            if (JobReady)
            {
                Console.WriteLine("-------------Starting Job...-------------");
                // Extract Audio
                successful = InputContainer.ExtractAudio(SourceVideo, SourceAudio, TempFolder);
                if (!successful)
                {
                    WriteInfo(this.GetType().Name + "." + GetMethodName(), "ExtractAudio was unsuccessful.", DEBUGLEVEL.ERROR);
                    return(false);
                }
                Console.WriteLine("-------------Finished audio extraction...-------------");
                // Encode video
                _encoder.StartProcess();
                successful = _tempVideo.Exists;
                if (!successful)
                {
                    WriteInfo(this.GetType().Name + "." + GetMethodName(), "Video encoding was unsuccessful.", DEBUGLEVEL.ERROR);
                    return(false);
                }
                Console.WriteLine("-------------Finished video encoding...-------------");
                // Mux audio
                successful = OutputContainer.MuxAudio(TempVideo, SourceAudio, OutputVideo, TempFolder);
                if (!successful)
                {
                    WriteInfo(this.GetType().Name + "." + GetMethodName(), "MuxAudio was unsuccessful.", DEBUGLEVEL.ERROR);
                    return(false);
                }
                Console.WriteLine("-------------Finished audio mux...-------------");
                // Archive source video
                Console.WriteLine("-------------Moving source video...-------------");
                // Clean up temp files
                Console.WriteLine("Cleaning up temp files...");
                CleanUp();
            }
            else
            {
                string notReadyReason = "";
                if (!_encoderReady)
                {
                    notReadyReason = "encoder isn't ready, ";
                }
                if (!_pathsGenerated)
                {
                    notReadyReason = "paths not generated, ";
                }
                notReadyReason = notReadyReason.Substring(0, notReadyReason.LastIndexOf(", ")) + ".";
                WriteInfo(this.GetType().Name + "." + GetMethodName(), "Job could not start because " + notReadyReason, DEBUGLEVEL.ERROR);
            }
            return(successful);
        }