public VSPipeInfo(string vsScriptPath) { VideoInfoJob j = new VideoInfoJob(vsScriptPath); IJobProcessor processor = VSPipeProcessor.NewVSPipeProcessor(j); processor.start(); videoInfo = (processor as VSPipeProcessor).VideoInfo; UpdateVideoInfo(); }
/// <summary> /// starts the job provided as parameters /// </summary> /// <param name="job">the Job object containing all the parameters</param> /// <returns>success / failure indicator</returns> private bool startEncoding(TaggedJob job) { try { log = mainForm.Log.Info(string.Format("Log for {0} ({1}, {2} -> {3})", job.Name, job.Job.EncodingMode, job.InputFileName, job.OutputFileName)); log.LogEvent("Started handling job"); log.Expand(); status = JobWorkerStatus.Running; //Check to see if output file already exists before encoding. if (File.Exists(job.Job.Output) && !mainForm.DialogManager.overwriteJobOutput(job.Job.Output)) { throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip); } // Get IJobProcessor currentProcessor = getProcessor(job.Job); if (currentProcessor == null) { throw new JobStartException("No processor could be found", ExceptionType.Error); } // Preprocess preprocessJob(job.Job); // Setup try { currentProcessor.setup(job.Job, new StatusUpdate(job.Name), log); } catch (JobRunException e) { throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error); } // Do JobControl setup currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus); // Progress window pw.setPriority(mainForm.Settings.DefaultPriority); if (mainForm.Settings.OpenProgressWindow && mainForm.Visible) { this.ShowProcessWindow(); } job.Status = JobStatus.PROCESSING; job.Start = DateTime.Now; status = JobWorkerStatus.Running; pauseStatus = PauseState.Encoding; currentJob = job; // Start try { currentProcessor.start(); } catch (JobRunException e) { throw new JobStartException("starting encoder failed with error '" + e.Message + "'", ExceptionType.Error); } log.LogEvent("Encoding started"); refreshAll(); return(true); } catch (JobStartException e) { mainForm.Log.LogValue("Error starting job", e); if (e.type == ExceptionType.Error) { job.Status = JobStatus.ERROR; } else // ExceptionType.UserSkip { job.Status = JobStatus.SKIP; } currentProcessor = null; currentJob = null; status = JobWorkerStatus.Idle; pauseStatus = PauseState.NotEncoding; refreshAll(); return(false); } }
/// <summary> /// starts the job provided as parameters /// </summary> /// <param name="job">the Job object containing all the parameters</param> /// <returns>success / failure indicator</returns> private bool startEncoding(TaggedJob job) { try { status = JobWorkerStatus.Running; //Check to see if output file already exists before encoding. if (File.Exists(job.Job.Output) && !mainForm.DialogManager.overwriteJobOutput(job.Job.Output)) { throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip); } // Get IJobProcessor currentProcessor = getProcessor(job.Job); if (currentProcessor == null) { throw new JobStartException("No processor could be found", ExceptionType.Error); } addToLog("\r\n\r\n------------------------------------------------------\r\n\r\n"); addToLog("Starting job " + job.Name + " at " + DateTime.Now.ToLongTimeString() + "\r\n"); // Preprocess preprocessJob(job.Job); // Setup try { currentProcessor.setup(job.Job, new StatusUpdate(job.Name)); } catch (JobRunException e) { throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error); } // Do JobControl setup //addToLog("encoder commandline:\r\n" + job.Commandline + "\r\n"); currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus); // Progress window pw.setPriority(mainForm.Settings.DefaultPriority); if (mainForm.Settings.OpenProgressWindow && mainForm.Visible) { this.ShowProcessWindow(); } job.Status = JobStatus.PROCESSING; job.Start = DateTime.Now; status = JobWorkerStatus.Running; pauseStatus = PauseState.Encoding; currentJob = job; // Start try { currentProcessor.start(); } catch (JobRunException e) { throw new JobStartException("starting encoder failed with error '" + e.Message + "'", ExceptionType.Error); } addToLog("successfully started encoding\r\n"); refreshAll(); return(true); } catch (JobStartException e) { addToLog("Job not started. Reason: " + e.Message + "\r\n"); if (e.type == ExceptionType.Error) { job.Status = JobStatus.ERROR; } else // ExceptionType.UserSkip { job.Status = JobStatus.SKIP; } currentProcessor = null; currentJob = null; status = JobWorkerStatus.Idle; pauseStatus = PauseState.NotEncoding; refreshAll(); return(false); } }
public void Start() { // TODO: 只考虑完整的视频压制流程 if (job.JobType != "video") { return; } VideoJob vjob = job as VideoJob; // 抽取音轨 FileInfo eacInfo = new FileInfo(".\\tools\\eac3to\\eac3to.exe"); if (!eacInfo.Exists) { throw new Exception("Eac3to 不存在"); } EACDemuxer eac = new EACDemuxer(eacInfo.FullName, vjob.config.InputFile); var audioTracks = eac.Extract((double progress, EACProgressType type) => { switch (type) { case EACProgressType.Analyze: vjob.config.Status = "轨道分析中"; vjob.config.ProgressValue = progress; break; case EACProgressType.Process: vjob.config.Status = "抽取音轨中"; vjob.config.ProgressValue = progress; break; case EACProgressType.Completed: vjob.config.Status = "音轨抽取完毕"; vjob.config.ProgressValue = progress; break; default: return; } }); // 默认列表是按照顺序来 string audioTrack = audioTracks[0].OutFileName; // 音频转码 List <string> audioFile = new List <string>(); foreach (var track in vjob.config.AudioTracks) { var audioOutput = audioTracks[track.TrackId]; string audioOutpath = audioOutput.OutFileName; if (track.Format.ToUpper() == "AAC") { vjob.config.Status = "音轨转码中"; vjob.config.ProgressValue = -1; if (audioOutput.FileExtension == ".flac") { AudioJob aDecode = new AudioJob("WAV"); aDecode.Input = audioOutput.OutFileName; aDecode.Output = "-"; FLACDecoder flac = new FLACDecoder(".\\tools\\flac\\flac.exe", aDecode); AudioJob aEncode = new AudioJob("AAC"); aEncode.Input = "-"; aEncode.Output = Path.ChangeExtension(audioOutpath, ".aac"); QAACEncoder qaac = new QAACEncoder(".\\tools\\qaac\\qaac.exe", aEncode, track.Bitrate); CMDPipeJobProcessor cmdpipe = CMDPipeJobProcessor.NewCMDPipeJobProcessor(flac, qaac); cmdpipe.start(); cmdpipe.waitForFinish(); audioOutpath = aEncode.Output; } } var audioFileInfo = new FileInfo(audioOutpath); if (audioFileInfo.Length < 1024) { // 无效音轨 // TODO: 提示用户不能封装 File.Move(audioOutpath, Path.ChangeExtension(audioOutpath, ".bak") + audioFileInfo.Extension); continue; } if (!track.SkipMuxing) { audioFile.Add(audioOutpath); } } vjob.config.Status = "获取信息中"; IJobProcessor processor = x265Encoder.init(vjob, vjob.config.EncoderParam); vjob.config.Status = "压制中"; vjob.config.ProgressValue = 0.0; processor.start(); processor.waitForFinish(); if (vjob.config.ContainerFormat != "") { // 封装 vjob.config.Status = "封装中"; FileInfo mkvInfo = new FileInfo(".\\tools\\mkvtoolnix\\mkvmerge.exe"); if (!mkvInfo.Exists) { throw new Exception("mkvmerge不存在"); } FileInfo lsmash = new FileInfo(".\\tools\\l-smash\\muxer.exe"); if (!lsmash.Exists) { throw new Exception("l-smash 封装工具不存在"); } AutoMuxer muxer = new AutoMuxer(mkvInfo.FullName, lsmash.FullName); muxer.ProgressChanged += progress => vjob.config.ProgressValue = progress; List <string> mergeList = new List <string> { vjob.config.InputFile + ".hevc", Path.ChangeExtension(vjob.config.InputFile, ".txt"), }; mergeList.AddRange(audioFile); muxer.StartMerge(mergeList, vjob.Output); } vjob.config.Status = "完成"; vjob.config.ProgressValue = 100; }
/// <summary> /// starts the job provided as parameters /// </summary> /// <param name="job">the Job object containing all the parameters</param> /// <returns>success / failure indicator</returns> private bool startEncoding(Job job) { Debug.Assert(status == JobWorkerStatus.Idle); try { //Check to see if output file already exists before encoding. if (File.Exists(job.Output) && !mainForm.DialogManager.overwriteJobOutput(job.Output)) throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip); // Get IJobProcessor currentProcessor = getProcessor(job); if (currentProcessor == null) throw new JobStartException("No processor could be found", ExceptionType.Error); addToLog("\r\n\r\n------------------------------------------------------\r\n\r\n"); addToLog("Starting job " + job.Name + " at " + DateTime.Now.ToLongTimeString() + "\r\n"); // Preprocess preprocessJob(job); // Setup try { currentProcessor.setup(job); } catch (JobRunException e) { throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error); } // Do JobControl setup addToLog("encoder commandline:\r\n" + job.Commandline + "\r\n"); currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus); // Progress window pw = new ProgressWindow(job.JobType); pw.WindowClosed += new WindowClosedCallback(pw_WindowClosed); pw.Abort += new AbortCallback(pw_Abort); pw.setPriority(job.Priority); pw.PriorityChanged += new PriorityChangedCallback(pw_PriorityChanged); if (mainForm.Settings.OpenProgressWindow && mainForm.Visible) pw.Show(); job.Status = JobStatus.PROCESSING; job.Start = DateTime.Now; status = JobWorkerStatus.Running; pauseStatus = PauseState.Encoding; currentJob = job; // Start try { currentProcessor.start(); } catch (JobRunException e) { throw new JobStartException("starting encoder failed with error '" + e.Message +"'", ExceptionType.Error); } addToLog("successfully started encoding\r\n"); refreshAll(); return true; } catch (JobStartException e) { addToLog("Job not started. Reason: " + e.Message + "\r\n"); if (e.type == ExceptionType.Error) job.Status = JobStatus.ERROR; else // ExceptionType.UserSkip job.Status = JobStatus.SKIP; currentProcessor = null; currentJob = null; status = JobWorkerStatus.Idle; pauseStatus = PauseState.NotEncoding; refreshAll(); return false; } }
/// <summary> /// starts the job provided as parameters /// </summary> /// <param name="job">the Job object containing all the parameters</param> /// <returns>success / failure indicator</returns> private bool StartEncoding(TaggedJob job) { try { log = mainForm.Log.Info(string.Format("Log for {0} ({1}, {2} -> {3})", job.Name, job.Job.EncodingMode, job.InputFileName, job.OutputFileName)); log.LogEvent("Started handling job"); log.Expand(); //Check to see if output file already exists before encoding. if (File.Exists(job.Job.Output) && (!Path.GetExtension(job.Job.Output).Equals(".lwi") && !Path.GetExtension(job.Job.Output).Equals(".ffindex") && !Path.GetExtension(job.Job.Output).Equals(".d2v") && !Path.GetExtension(job.Job.Output).Equals(".dgi")) && !mainForm.DialogManager.overwriteJobOutput(job.Job.Output)) { throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip); } // Get IJobProcessor currentProcessor = GetProcessor(job.Job); if (currentProcessor == null) { throw new JobStartException("No processor could be found", ExceptionType.Error); } // Preprocess PreprocessJob(job.Job); // Setup try { currentProcessor.setup(job.Job, new StatusUpdate(job.Name), log); } catch (JobRunException e) { throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error); } if (currentProcessor == null) { throw new JobStartException("starting job failed", ExceptionType.Error); } // Do JobControl setup currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus); // Progress window WorkerPriority.GetJobPriority(job.Job, out WorkerPriorityType oPriority, out bool lowIOPriority); pw.setPriority(oPriority); if (mainForm.Settings.OpenProgressWindow && mainForm.Visible) { this.ShowProcessWindow(); } job.Start = DateTime.Now; currentJob = job; // Start try { currentProcessor.start(); } catch (JobRunException e) { throw new JobStartException("starting job failed with error '" + e.Message + "'", ExceptionType.Error); } RefreshAll(); MeGUI.core.util.WindowUtil.PreventSystemPowerdown(); return(true); } catch (JobStartException e) { this.HideProcessWindow(); log.LogValue("Error starting job", e); if (e.type == ExceptionType.Error) { job.Status = JobStatus.ERROR; } else // ExceptionType.UserSkip { job.Status = JobStatus.SKIP; } currentProcessor = null; currentJob = null; RefreshAll(); return(false); } }
public virtual bool start(out string error) { error = null; return(encoder.start(out error)); }