protected virtual MuxJob generateMuxJob() { MuxJob job = new MuxJob(); string chapters; MuxStream[] aStreams, sStreams; getAdditionalStreams(out aStreams, out sStreams, out chapters); job.Settings.AudioStreams.AddRange(aStreams); job.Settings.SubtitleStreams.AddRange(sStreams); job.Settings.ChapterFile = this.chapters.Filename; job.Settings.VideoName = this.videoName.Text; job.Settings.VideoInput = vInput.Filename; job.Settings.MuxedOutput = output.Filename; job.Settings.MuxedInput = this.muxedInput.Filename; job.Settings.DAR = base.dar; if (string.IsNullOrEmpty(job.Settings.VideoInput)) { job.Input = job.Settings.MuxedInput; } else { job.Input = job.Settings.VideoInput; } job.Output = job.Settings.MuxedOutput; job.MuxType = muxer.MuxerType; job.ContainerType = getContainerType(job.Settings.MuxedOutput); job.Settings.Framerate = fps.Value; Debug.Assert(!splitting.Value.HasValue || splitting.Value.Value >= new FileSize(Unit.MB, 1)); job.Settings.SplitSize = splitting.Value; return(job); }
private void queueVideoButton_Click(object sender, System.EventArgs e) { fileType_SelectedIndexChanged(sender, e); // to select always correct output file extension string settingsError = verifyVideoSettings(); // basic input, logfile and output file settings are okay if (settingsError != null) { MessageBox.Show(settingsError, "Unsupported configuration", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } VideoCodecSettings vSettings = this.CurrentSettings.Clone(); string videoOutput = info.VideoOutput; if ((MainForm.Instance.Settings.UseExternalMuxerX264 || fileType.Text.Equals("MP4")) && (!fileType.Text.StartsWith("RAW") && vSettings.SettingsID.StartsWith("x26"))) { if (vSettings.SettingsID.Equals("x264")) { videoOutput = Path.ChangeExtension(videoOutput, "264"); } else if (vSettings.SettingsID.Equals("x265")) { videoOutput = Path.ChangeExtension(videoOutput, "hevc"); } } JobChain prepareJobs = mainForm.JobUtil.AddVideoJobs(info.VideoInput, videoOutput, this.CurrentSettings.Clone(), info.IntroEndFrame, info.CreditsStartFrame, info.DAR, PrerenderJob, true, info.Zones); if ((MainForm.Instance.Settings.UseExternalMuxerX264 || fileType.Text.Equals("MP4")) && (!fileType.Text.StartsWith("RAW") && vSettings.SettingsID.StartsWith("x26"))) { // create job MuxJob mJob = new MuxJob(); mJob.Input = videoOutput; if (fileType.Text.Equals("MKV")) { mJob.MuxType = MuxerType.MKVMERGE; mJob.Output = Path.ChangeExtension(videoOutput, "mkv"); } else { mJob.MuxType = MuxerType.MP4BOX; mJob.Output = Path.ChangeExtension(videoOutput, "mp4"); } mJob.Settings.MuxAll = true; mJob.Settings.Framerate = decimal.Round((decimal)FrameRate, 3, MidpointRounding.AwayFromZero); mJob.Settings.MuxedInput = mJob.Input; mJob.Settings.MuxedOutput = mJob.Output; mJob.FilesToDelete.Add(videoOutput); // add job to queue prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(mJob)); } mainForm.Jobs.addJobsWithDependencies(prepareJobs, true); }
void setProjectedFileSize() { MuxJob mjob = (MuxJob)job; try { FileInfo fi = new FileInfo(job.Settings.VideoInput); videoSize = fi.Length; } catch (Exception) { videoSize = 0; } try { FileInfo fi2 = new FileInfo(job.Settings.MuxedInput); muxedInputSize = fi2.Length; } catch (Exception) { } su.ProjectedFileSize = (int)((videoSize + muxedInputSize) / 1024L); int count = 0; foreach (object o in mjob.Settings.AudioStreams) { SubStream audioStream = (SubStream)o; int fileLength = 0; try { FileInfo fi = new FileInfo(audioStream.path); fileLength = (int)(fi.Length / 1024); } catch (Exception) { } su.ProjectedFileSize += fileLength; if (count == 0) { audioSize1 = fileLength; } else if (count == 1) { audioSize2 = fileLength; } count++; } foreach (object o in mjob.Settings.SubtitleStreams) { SubStream subtitleStream = (SubStream)o; try { FileInfo fi = new FileInfo(subtitleStream.path); su.ProjectedFileSize += (int)(fi.Length / 1024); subtitleSize += fi.Length; } catch (Exception) { } } }
protected virtual MuxJob generateMuxJob() { MuxJob job = new MuxJob(); convertLanguagesToISO(); foreach (SubStream stream in audioStreams) { job.Settings.AudioStreams.Add(stream); } foreach (SubStream stream in subtitleStreams) { job.Settings.SubtitleStreams.Add(stream); } job.Settings.ChapterFile = this.chaptersInput.Text; job.Settings.VideoName = this.videoName.Text; job.Settings.VideoInput = this.videoInput.Text; job.Settings.MuxedOutput = muxedOutput.Text; job.Settings.MuxedInput = this.muxedInput.Text; job.Settings.PARX = base.parX; job.Settings.PARY = base.parY; if (string.IsNullOrEmpty(job.Settings.VideoInput)) { job.Input = job.Settings.MuxedInput; } else { job.Input = job.Settings.VideoInput; } job.Output = job.Settings.MuxedOutput; job.MuxType = muxer.MuxerType; job.ContainerType = cot; if ((!job.Settings.MuxedInput.Equals("") || !job.Settings.VideoInput.Equals("")) && !job.Settings.MuxedOutput.Equals("")) { if (this.muxFPS.SelectedIndex != -1) { job.Settings.Framerate = Double.Parse(muxFPS.Text); } if (this.muxFPS.SelectedIndex != -1 || !isFPSRequired()) { if (this.enableSplit.Checked && !splitSize.Text.Equals("")) { job.Settings.SplitSize = Int32.Parse(this.splitSize.Text) * 1024; } job.Commandline = CommandLineGenerator.generateMuxCommandline(job.Settings, job.MuxType, mainForm); } } return(job); }
/// <summary> /// sets up the muxer /// checks the input for validity and sets some internal variables /// </summary> /// <param name="job">the job to be processed</param> /// <param name="error">feedback variable for errors</param> /// <returns>true if the setup succeeded, false if it failed</returns> public override bool setup(Job job, out string error) { error = null; MuxJob mjob = (MuxJob)job; if (base.setup(job, out error)) { double overhead = mjob.Overhead * (double)mjob.NbOfFrames; su.ProjectedFileSize += (int)(overhead / 1024); return(true); } else { return(false); } }
protected virtual void muxButton_Click(object sender, System.EventArgs e) { if (muxButton.DialogResult != DialogResult.OK) { if (string.IsNullOrEmpty(vInput.Filename)) { MessageBox.Show("You must configure a video input file", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else if (string.IsNullOrEmpty(output.Filename)) { MessageBox.Show("You must configure an output file", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else if (MainForm.verifyOutputFile(output.Filename) != null) { MessageBox.Show("Invalid output file", "Invalid output", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!fps.Value.HasValue) { MessageBox.Show("You must select a framerate", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } else { if (this.muxButton.Text.Equals("Update")) { this.Close(); } else { MuxJob job = this.Job; mainForm.Jobs.AddJobsToQueue(job); if (chkCloseOnQueue.Checked) { this.Close(); } else { output.Filename = String.Empty; } } } }
public override bool setup(Job job, out string error) { error = null; MuxJob mjob = (MuxJob)job; this.numberOfAudioTracks = mjob.Settings.AudioStreams.Count; this.numberOfSubtitleTracks = mjob.Settings.SubtitleStreams.Count; if (base.setup(job, out error)) { if (!Path.GetExtension(job.Input).ToLower().Equals(".mp4")) { double overhead = mjob.Overhead * (double)mjob.NbOfFrames; su.ProjectedFileSize += (int)(overhead / 1024); } return(true); } else { return(false); } }
private static Job ReconfigureJob(Job j) { if (!(j is MuxJob)) { return(null); } MuxJob m = (MuxJob)j; MuxWindow w = new MuxWindow( MainForm.Instance.MuxProvider.GetMuxer(m.MuxType), MainForm.Instance); w.Job = m; if (w.ShowDialog() == DialogResult.OK) { return(w.Job); } else { return(m); } }
private string writeScript(MuxJob job) { MuxSettings settings = job.Settings; // First, generate the script StringBuilder script = new StringBuilder(); script.AppendLine("CLEAR"); int fileNum = 1; // the number of the file at the top int audioNum = 1; // the audio track number // add the audio streams foreach (MuxStream s in settings.AudioStreams) { script.AppendFormat("LOAD {1}{0}", Environment.NewLine, s.path); script.AppendLine("SET OUTPUT OPTIONS"); if (!string.IsNullOrEmpty(s.name)) script.AppendFormat("SET OPTION AUDIO NAME {0} {1}{2}", audioNum, s.name, Environment.NewLine); if (!string.IsNullOrEmpty(s.language)) script.AppendFormat("SET OPTION AUDIO LNGCODE {0} {1}{2}", audioNum, s.language, Environment.NewLine); if (s.delay != 0) script.AppendFormat("SET OPTION DELAY {0} {1}{2}", audioNum, s.delay, Environment.NewLine); audioNum++; fileNum++; } int subtitleNum = 1; // the subtitle track number // add the subtitle streams foreach (MuxStream s in settings.SubtitleStreams) { script.AppendFormat("LOAD {1}{0}", Environment.NewLine, s.path); script.AppendLine("SET OUTPUT OPTIONS"); if (!string.IsNullOrEmpty(s.name)) script.AppendFormat("SET OPTION SUBTITLE NAME {0} {1}{2}", subtitleNum, s.name, Environment.NewLine); subtitleNum++; fileNum++; } // add the video stream if it exists if (!string.IsNullOrEmpty(settings.VideoInput)) { script.AppendFormat("LOAD {1}{0}SELECT FILE {2}{0}ADD VIDEOSOURCE{0}DESELECT FILE {2}{0}", Environment.NewLine, settings.VideoInput, fileNum); fileNum++; } // mux in the rest if it exists if (!string.IsNullOrEmpty(settings.MuxedInput)) { script.AppendFormat("LOAD {1}{0}SELECT FILE {2}{0}ADD VIDEOSOURCE{0}DESELECT FILE {2}{0}", Environment.NewLine, settings.MuxedInput, fileNum); fileNum++; } // AR can't be signalled in AVI // split size script.AppendLine("SET OUTPUT OPTIONS"); if (settings.SplitSize.HasValue) { script.AppendLine("SET OPTION NUMBERING ON"); script.AppendLine("SET OPTION MAXFILESIZE ON"); script.AppendFormat("SET OPTION MAXFILESIZE {0}{1}", ((MeGUI.core.util.FileSize)settings.SplitSize).MB, Environment.NewLine); } else { script.AppendLine("SET OPTION NUMBERING OFF"); script.AppendLine("SET OPTION MAXFILESIZE OFF"); } // Now do the rest of the setup script.AppendLine( @"SET INPUT OPTIONS SET OPTION MP3 VERIFY CBR ALWAYS SET OPTION MP3 VERIFY RESDLG OFF SET OPTION AVI FIXDX50 1 SET OPTION CHAPTERS IMPORT 1 SET OUTPUT OPTIONS SET OPTION ALL SUBTITLES 1 SET OPTION ALL AUDIO 1 SET OPTION CLOSEAPP 1 SET OPTION DONEDLG 0 SET OPTION OVERWRITEDLG 0 SET OPTION STDIDX AUTO"); script.AppendFormat("START {0}{1}", settings.MuxedOutput, Environment.NewLine); /// the script is now created; let's write it to a temp file string filename = Path.GetTempFileName(); using (StreamWriter output = new StreamWriter(File.OpenWrite(filename), System.Text.Encoding.UTF8)) { output.Write(script.ToString()); } return filename; }
private string writeScript(MuxJob job) { MuxSettings settings = job.Settings; // First, generate the script StringBuilder script = new StringBuilder(); script.AppendLine("CLEAR"); int fileNum = 1; // the number of the file at the top int audioNum = 1; // the audio track number // add the audio streams foreach (MuxStream s in settings.AudioStreams) { script.AppendFormat("LOAD {1}{0}", Environment.NewLine, s.path); script.AppendLine("SET OUTPUT OPTIONS"); if (!string.IsNullOrEmpty(s.name)) { script.AppendFormat("SET OPTION AUDIO NAME {0} {1}{2}", audioNum, s.name, Environment.NewLine); } if (!string.IsNullOrEmpty(s.language)) { script.AppendFormat("SET OPTION AUDIO LNGCODE {0} {1}{2}", audioNum, s.language, Environment.NewLine); } if (s.delay != 0) { script.AppendFormat("SET OPTION DELAY {0} {1}{2}", audioNum, s.delay, Environment.NewLine); } audioNum++; fileNum++; } int subtitleNum = 1; // the subtitle track number // add the subtitle streams foreach (MuxStream s in settings.SubtitleStreams) { script.AppendFormat("LOAD {1}{0}", Environment.NewLine, s.path); script.AppendLine("SET OUTPUT OPTIONS"); if (!string.IsNullOrEmpty(s.name)) { script.AppendFormat("SET OPTION SUBTITLE NAME {0} {1}{2}", subtitleNum, s.name, Environment.NewLine); } subtitleNum++; fileNum++; } // add the video stream if it exists if (!string.IsNullOrEmpty(settings.VideoInput)) { script.AppendFormat("LOAD {1}{0}SELECT FILE {2}{0}ADD VIDEOSOURCE{0}DESELECT FILE {2}{0}", Environment.NewLine, settings.VideoInput, fileNum); fileNum++; } // mux in the rest if it exists if (!string.IsNullOrEmpty(settings.MuxedInput)) { script.AppendFormat("LOAD {1}{0}SELECT FILE {2}{0}ADD VIDEOSOURCE{0}DESELECT FILE {2}{0}", Environment.NewLine, settings.MuxedInput, fileNum); fileNum++; } // AR can't be signalled in AVI script.AppendLine("SET OUTPUT OPTIONS"); // split size if (settings.SplitSize.HasValue) { script.AppendFormat("SET OPTION MAXFILESIZE {0}{1}", settings.SplitSize, Environment.NewLine); } // Now do the rest of the setup script.AppendLine( @"SET INPUT OPTIONS SET OPTION MP3 VERIFY CBR ALWAYS SET OPTION MP3 VERIFY RESDLG OFF SET OPTION AVI FIXDX50 1 SET OPTION CHAPTERS IMPORT 1 SET OUTPUT OPTIONS SET OPTION ALL SUBTITLES 1 SET OPTION ALL AUDIO 1 SET OPTION CLOSEAPP 1 SET OPTION DONEDLG 0 SET OPTION OVERWRITEDLG 0 SET OPTION STDIDX AUTO"); script.AppendFormat("START {0}{1}", settings.MuxedOutput, Environment.NewLine); /// the script is now created; let's write it to a temp file string filename = Path.GetTempFileName(); using (StreamWriter output = new StreamWriter(File.OpenWrite(filename))) { output.Write(script.ToString()); } return(filename); }
private string writeScript(MuxJob job) { MuxSettings settings = job.Settings; // First, generate the script StringBuilder script = new StringBuilder(); script.AppendLine("CLEAR"); int fileNum = 1; // the number of the file at the top int audioNum = 1; // the audio track number // add the audio streams foreach (MuxStream s in settings.AudioStreams) { script.AppendFormat("LOAD {1}{0}", Environment.NewLine, s.path); script.AppendLine("SET OUTPUT OPTIONS"); if (!string.IsNullOrEmpty(s.name)) { script.AppendFormat("SET OPTION AUDIO NAME {0} {1}{2}", audioNum, s.name, Environment.NewLine); } if (!string.IsNullOrEmpty(s.language)) { script.AppendFormat("SET OPTION AUDIO LNGCODE {0} {1}{2}", audioNum, s.language, Environment.NewLine); } if (s.delay != 0) { script.AppendFormat("SET OPTION DELAY {0} {1}{2}", audioNum, s.delay, Environment.NewLine); } audioNum++; fileNum++; } int subtitleNum = 1; // the subtitle track number // add the subtitle streams foreach (MuxStream s in settings.SubtitleStreams) { script.AppendFormat("LOAD {1}{0}", Environment.NewLine, s.path); script.AppendLine("SET OUTPUT OPTIONS"); if (!string.IsNullOrEmpty(s.name)) { script.AppendFormat("SET OPTION SUBTITLE NAME {0} {1}{2}", subtitleNum, s.name, Environment.NewLine); } subtitleNum++; fileNum++; } // add the video stream if it exists if (!string.IsNullOrEmpty(settings.VideoInput)) { script.AppendFormat("LOAD {1}{0}SELECT FILE {2}{0}ADD VIDEOSOURCE{0}DESELECT FILE {2}{0}", Environment.NewLine, settings.VideoInput, fileNum); fileNum++; } // mux in the rest if it exists if (!string.IsNullOrEmpty(settings.MuxedInput)) { script.AppendFormat("LOAD {1}{0}SELECT FILE {2}{0}ADD VIDEOSOURCE{0}DESELECT FILE {2}{0}", Environment.NewLine, settings.MuxedInput, fileNum); fileNum++; } // AR can't be signalled in AVI // split size script.AppendLine("SET OUTPUT OPTIONS"); if (settings.SplitSize.HasValue || String.IsNullOrEmpty(settings.DeviceType) || settings.DeviceType == "Standard") { script.AppendLine("SET OPTION NUMBERING ON"); script.AppendLine("SET OPTION MAXFILESIZE ON"); if ((String.IsNullOrEmpty(settings.DeviceType) || settings.DeviceType == "Standard") && (!settings.SplitSize.HasValue || ((MeGUI.core.util.FileSize)settings.SplitSize).MB > 2000)) { log.LogValue("The output file will be splitted every 2GB. If this is not intended select the device type \"PC\" - but this will reduce compatibility for hardware players.", script); script.AppendFormat("SET OPTION MAXFILESIZE {0}{1}", 2000, Environment.NewLine); } else { script.AppendFormat("SET OPTION MAXFILESIZE {0}{1}", ((MeGUI.core.util.FileSize)settings.SplitSize).MB, Environment.NewLine); } } else { script.AppendLine("SET OPTION NUMBERING OFF"); script.AppendLine("SET OPTION MAXFILESIZE OFF"); } // Now do the rest of the setup script.AppendLine( @"SET INPUT OPTIONS SET OPTION MP3 VERIFY CBR ALWAYS SET OPTION MP3 VERIFY RESDLG OFF SET OPTION AVI FIXDX50 1 SET OPTION CHAPTERS IMPORT 1 SET OUTPUT OPTIONS SET OPTION ALL SUBTITLES 1 SET OPTION ALL AUDIO 1 SET OPTION CLOSEAPP 1 SET OPTION DONEDLG 0 SET OPTION OVERWRITEDLG 0 SET OPTION PRELOAD 200"); if (String.IsNullOrEmpty(settings.DeviceType) || settings.DeviceType == "Standard") { script.AppendLine( @"SET OPTION OPENDML 0 SET OPTION RECLISTS 0 SET OPTION AVI ADDJUNKBEFOREHEADERS 0 SET OPTION AUDIO INTERLEAVE 4 FR"); } else { script.AppendLine( @"SET OPTION OPENDML 1 SET OPTION RECLISTS 1 SET OPTION AUDIO INTERLEAVE 100 KB SET OPTION AVI RIFFAVISIZE 1 SET OPTION AVI ADDJUNKBEFOREHEADERS 1 SET OPTION AVI HAALIMODE 0 SET OPTION STDIDX 10000 FRAMES SET OPTION LEGACY 1"); } script.AppendFormat("START {0}{1}", settings.MuxedOutput, Environment.NewLine); /// the script is now created; let's write it to a temp file string filename = Path.ChangeExtension(job.Output, ".mux"); using (StreamWriter output = new StreamWriter(File.OpenWrite(filename), System.Text.Encoding.UTF8)) { output.Write(script.ToString()); } log.LogValue("mux script", script); return(filename); }
protected virtual MuxJob generateMuxJob() { MuxJob job = new MuxJob(); string chapters; MuxStream[] aStreams, sStreams; getAdditionalStreams(out aStreams, out sStreams, out chapters); job.Settings.AudioStreams.AddRange(aStreams); job.Settings.SubtitleStreams.AddRange(sStreams); job.Settings.ChapterFile = this.chapters.Filename; job.Settings.VideoName = this.videoName.Text; job.Settings.VideoInput = vInput.Filename; job.Settings.MuxedOutput = output.Filename; job.Settings.MuxedInput = this.muxedInput.Filename; job.Settings.DAR = base.dar; job.Settings.DeviceType = this.cbType.Text; if (string.IsNullOrEmpty(job.Settings.VideoInput)) job.Input = job.Settings.MuxedInput; else job.Input = job.Settings.VideoInput; job.Output = job.Settings.MuxedOutput; job.MuxType = muxer.MuxerType; job.ContainerType = getContainerType(job.Settings.MuxedOutput); job.Settings.Framerate = fps.Value; Debug.Assert(!splitting.Value.HasValue || splitting.Value.Value >= new FileSize(Unit.MB, 1)); job.Settings.SplitSize = splitting.Value; return job; }
public JobChain GenerateMuxJobs(VideoStream video, decimal?framerate, MuxStream[] audioStreamsArray, MuxableType[] audioTypes, MuxStream[] subtitleStreamsArray, MuxableType[] subTypes, string chapterFile, MuxableType chapterInputType, ContainerType container, string output, FileSize?splitSize, List <string> inputsToDelete, string deviceType, MuxableType deviceOutputType, bool alwaysMuxOutput) { Debug.Assert(splitSize == null || splitSize.Value != FileSize.Empty); MuxProvider prov = mainForm.MuxProvider; List <MuxableType> allTypes = new List <MuxableType>(); List <MuxableType> tempTypes = new List <MuxableType>(); List <MuxableType> duplicateTypes = new List <MuxableType>(); tempTypes.AddRange(audioTypes); tempTypes.AddRange(subTypes); allTypes.Add(video.VideoType); // remove duplicate entries to speed up the process foreach (MuxableType oType in tempTypes) { bool bFound = false; foreach (MuxableType oAllType in allTypes) { if (oType.outputType.ID.Equals(oAllType.outputType.ID)) { bFound = true; break; } } if (!bFound) { allTypes.Add(oType); } else { duplicateTypes.Add(oType); } } if (chapterInputType != null) { allTypes.Add(chapterInputType); } if (deviceOutputType != null) { allTypes.Add(deviceOutputType); } // get mux path MuxPath muxPath = prov.GetMuxPath(container, alwaysMuxOutput || splitSize.HasValue, allTypes.ToArray()); // add duplicate entries back into the mux path muxPath.InitialInputTypes.AddRange(duplicateTypes); while (duplicateTypes.Count > 0) { int iPath = 0; for (int i = 0; i < muxPath.Length; i++) { foreach (MuxableType oType in muxPath[i].handledInputTypes) { if (oType.outputType.ID.Equals(duplicateTypes[0].outputType.ID)) { iPath = i; } } } muxPath[iPath].handledInputTypes.Add(duplicateTypes[0]); duplicateTypes.RemoveAt(0); } List <MuxJob> jobs = new List <MuxJob>(); List <MuxStream> subtitleStreams = new List <MuxStream>(subtitleStreamsArray); List <MuxStream> audioStreams = new List <MuxStream>(audioStreamsArray); int index = 0; int tempNumber = 1; string previousOutput = null; foreach (MuxPathLeg mpl in muxPath) { List <string> filesToDeleteThisJob = new List <string>(); MuxJob mjob = new MuxJob(); if (previousOutput != null) { mjob.Settings.MuxedInput = previousOutput; filesToDeleteThisJob.Add(previousOutput); } if (video.Settings != null) { mjob.NbOfBFrames = video.Settings.NbBframes; mjob.Codec = video.Settings.Codec.ToString(); mjob.Settings.VideoName = video.Settings.VideoName; } mjob.NbOfFrames = video.NumberOfFrames; string fpsFormated = String.Format("{0:##.###}", framerate); // this formating is required for mkvmerge at least to avoid fps rounding error mjob.Settings.Framerate = Convert.ToDecimal(fpsFormated); string tempOutputName = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output) + tempNumber + "."); tempNumber++; foreach (MuxableType o in mpl.handledInputTypes) { if (o.outputType is VideoType) { mjob.Settings.VideoInput = video.Output; if (inputsToDelete.Contains(video.Output)) { filesToDeleteThisJob.Add(video.Output); } mjob.Settings.DAR = video.DAR; } else if (o.outputType is AudioType) { MuxStream stream = audioStreams.Find(delegate(MuxStream m) { return(VideoUtil.guessAudioType(m.path) == o.outputType); }); if (stream != null) { mjob.Settings.AudioStreams.Add(stream); audioStreams.Remove(stream); if (inputsToDelete.Contains(stream.path)) { filesToDeleteThisJob.Add(stream.path); } } } else if (o.outputType is SubtitleType) { MuxStream stream = subtitleStreams.Find(delegate(MuxStream m) { return(VideoUtil.guessSubtitleType(m.path) == o.outputType); }); if (stream != null) { mjob.Settings.SubtitleStreams.Add(stream); subtitleStreams.Remove(stream); if (inputsToDelete.Contains(stream.path)) { filesToDeleteThisJob.Add(stream.path); } } } else if (o.outputType is ChapterType) { if ((VideoUtil.guessChapterType(chapterFile) == o.outputType)) { mjob.Settings.ChapterFile = chapterFile; } if (inputsToDelete.Contains(chapterFile)) { filesToDeleteThisJob.Add(chapterFile); } } else if (o.outputType is DeviceType) { if ((VideoUtil.guessDeviceType(deviceType) == o.outputType)) { mjob.Settings.DeviceType = deviceType; } } } foreach (MuxStream s in mjob.Settings.AudioStreams) { audioStreams.Remove(s); } foreach (MuxStream s in mjob.Settings.SubtitleStreams) { subtitleStreams.Remove(s); } mjob.FilesToDelete.AddRange(filesToDeleteThisJob); if (index == muxPath.Length - 1) { mjob.Settings.MuxedOutput = output; mjob.Settings.SplitSize = splitSize; mjob.Settings.DAR = video.DAR; mjob.ContainerType = container; } else { ContainerType cot = mpl.muxerInterface.GetContainersInCommon(muxPath[index + 1].muxerInterface)[0]; mjob.Settings.MuxedOutput = tempOutputName + cot.Extension; mjob.ContainerType = cot; } previousOutput = mjob.Settings.MuxedOutput; index++; jobs.Add(mjob); if (string.IsNullOrEmpty(mjob.Settings.VideoInput)) { mjob.Input = mjob.Settings.MuxedInput; } else { mjob.Input = mjob.Settings.VideoInput; } mjob.Output = mjob.Settings.MuxedOutput; mjob.MuxType = mpl.muxerInterface.MuxerType; } return(new SequentialChain(jobs.ToArray())); }
public JobChain GenerateMuxJobs(VideoStream video, decimal?framerate, MuxStream[] audioStreamsArray, MuxableType[] audioTypes, MuxStream[] subtitleStreamsArray, MuxableType[] subTypes, string chapterFile, MuxableType chapterInputType, ContainerType container, string output, FileSize?splitSize, List <string> inputsToDelete) { Debug.Assert(splitSize == null || splitSize.Value != FileSize.Empty); MuxProvider prov = mainForm.MuxProvider; List <MuxableType> allTypes = new List <MuxableType>(); allTypes.Add(video.VideoType); allTypes.AddRange(audioTypes); allTypes.AddRange(subTypes); if (chapterInputType != null) { allTypes.Add(chapterInputType); } MuxPath muxPath = prov.GetMuxPath(container, allTypes.ToArray()); List <MuxJob> jobs = new List <MuxJob>(); List <MuxStream> subtitleStreams = new List <MuxStream>(subtitleStreamsArray); List <MuxStream> audioStreams = new List <MuxStream>(audioStreamsArray); int index = 0; int tempNumber = 1; string previousOutput = null; foreach (MuxPathLeg mpl in muxPath) { List <string> filesToDeleteThisJob = new List <string>(); MuxJob mjob = new MuxJob(); if (previousOutput != null) { mjob.Settings.MuxedInput = previousOutput; filesToDeleteThisJob.Add(previousOutput); } mjob.NbOfFrames = video.NumberOfFrames; mjob.NbOfBFrames = video.Settings.NbBframes; mjob.Codec = video.Settings.Codec.ToString(); mjob.Settings.Framerate = framerate; string tempOutputName = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output) + tempNumber + "."); tempNumber++; foreach (MuxableType o in mpl.handledInputTypes) { if (o.outputType is VideoType) { mjob.Settings.VideoInput = video.Output; if (inputsToDelete.Contains(video.Output)) { filesToDeleteThisJob.Add(video.Output); } mjob.Settings.DAR = video.DAR; } else if (o.outputType is AudioType) { MuxStream stream = audioStreams.Find(delegate(MuxStream m) { return(VideoUtil.guessAudioType(m.path) == o.outputType); }); if (stream != null) { mjob.Settings.AudioStreams.Add(stream); audioStreams.Remove(stream); if (inputsToDelete.Contains(stream.path)) { filesToDeleteThisJob.Add(stream.path); } } } else if (o.outputType is SubtitleType) { MuxStream stream = subtitleStreams.Find(delegate(MuxStream m) { return(VideoUtil.guessSubtitleType(m.path) == o.outputType); }); if (stream != null) { mjob.Settings.SubtitleStreams.Add(stream); subtitleStreams.Remove(stream); if (inputsToDelete.Contains(stream.path)) { filesToDeleteThisJob.Add(stream.path); } } } else if (o.outputType is ChapterType) { if ((VideoUtil.guessChapterType(chapterFile) == o.outputType)) { mjob.Settings.ChapterFile = chapterFile; } if (inputsToDelete.Contains(chapterFile)) { filesToDeleteThisJob.Add(chapterFile); } } } foreach (MuxStream s in mjob.Settings.AudioStreams) { audioStreams.Remove(s); } foreach (MuxStream s in mjob.Settings.SubtitleStreams) { subtitleStreams.Remove(s); } mjob.FilesToDelete.AddRange(filesToDeleteThisJob); if (index == muxPath.Length - 1) { mjob.Settings.MuxedOutput = output; mjob.Settings.SplitSize = splitSize; mjob.Settings.DAR = video.DAR; mjob.ContainerType = container; } else { ContainerType cot = mpl.muxerInterface.GetContainersInCommon(muxPath[index + 1].muxerInterface)[0]; mjob.Settings.MuxedOutput = tempOutputName + cot.Extension; mjob.ContainerType = cot; } previousOutput = mjob.Settings.MuxedOutput; index++; jobs.Add(mjob); if (string.IsNullOrEmpty(mjob.Settings.VideoInput)) { mjob.Input = mjob.Settings.MuxedInput; } else { mjob.Input = mjob.Settings.VideoInput; } mjob.Output = mjob.Settings.MuxedOutput; mjob.MuxType = mpl.muxerInterface.MuxerType; } return(new SequentialChain(jobs.ToArray())); }
private void queueVideoButton_Click(object sender, System.EventArgs e) { fileType_SelectedIndexChanged(sender, e); // to select always correct output file extension string settingsError = verifyVideoSettings(); // basic input, logfile and output file settings are okay if (settingsError != null) { MessageBox.Show(settingsError, "Unsupported configuration", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } VideoCodecSettings vSettings = this.CurrentSettings.Clone(); string videoOutput = info.VideoOutput; // special handling as the encoders cannot output all desired container types if (!fileType.Text.StartsWith("RAW") && (!vSettings.SettingsID.Equals("x264") || !fileType.Text.Equals("MKV") || MainForm.Instance.Settings.UseExternalMuxerX264)) { if (vSettings.SettingsID.Equals("x264")) { videoOutput = Path.ChangeExtension(videoOutput, "264"); } else if (vSettings.SettingsID.Equals("x265")) { videoOutput = Path.ChangeExtension(videoOutput, "hevc"); } else if (vSettings.SettingsID.Equals("XviD")) { videoOutput = Path.ChangeExtension(videoOutput, "m4v"); } } JobUtil.GetInputProperties(info.VideoInput, out ulong frameCount, out double frameRate); JobChain prepareJobs = JobUtil.AddVideoJobs(info.VideoInput, videoOutput, this.CurrentSettings.Clone(), info.IntroEndFrame, info.CreditsStartFrame, info.DAR, PrerenderJob, info.Zones, (int)frameCount); if (!fileType.Text.StartsWith("RAW") && vSettings.VideoEncodingType != MeGUI.VideoCodecSettings.VideoEncodingMode.twopass1 && vSettings.VideoEncodingType != MeGUI.VideoCodecSettings.VideoEncodingMode.threepass1 && (!vSettings.SettingsID.Equals("x264") || !fileType.Text.Equals("MKV") || MainForm.Instance.Settings.UseExternalMuxerX264)) { // create mux job MuxJob mJob = new MuxJob(); mJob.Input = videoOutput; if (vSettings.SettingsID.Equals("XviD")) { mJob.MuxType = MuxerType.FFMPEG; mJob.Output = Path.ChangeExtension(videoOutput, "avi"); if (fileType.Text.Equals("MKV")) { mJob.Output = Path.ChangeExtension(videoOutput, "mkv"); } } else if (fileType.Text.Equals("MKV")) { mJob.MuxType = MuxerType.MKVMERGE; mJob.Output = Path.ChangeExtension(videoOutput, "mkv"); } else { mJob.MuxType = MuxerType.MP4BOX; mJob.Output = Path.ChangeExtension(videoOutput, "mp4"); } mJob.Settings.MuxAll = true; mJob.Settings.MuxedInput = mJob.Input; mJob.Settings.MuxedOutput = mJob.Output; mJob.FilesToDelete.Add(videoOutput); // add job to queue prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(mJob)); } MainForm.Instance.Jobs.AddJobsWithDependencies(prepareJobs, true); }
public JobChain GenerateMuxJobs(VideoStream video, decimal? framerate, MuxStream[] audioStreamsArray, MuxableType[] audioTypes, MuxStream[] subtitleStreamsArray, MuxableType[] subTypes, string chapterFile, MuxableType chapterInputType, ContainerType container, string output, FileSize? splitSize, List<string> inputsToDelete, string deviceType, MuxableType deviceOutputType) { Debug.Assert(splitSize == null || splitSize.Value != FileSize.Empty); MuxProvider prov = mainForm.MuxProvider; List<MuxableType> allTypes = new List<MuxableType>(); allTypes.Add(video.VideoType); allTypes.AddRange(audioTypes); allTypes.AddRange(subTypes); if (chapterInputType != null) allTypes.Add(chapterInputType); if (deviceOutputType != null) allTypes.Add(deviceOutputType); MuxPath muxPath = prov.GetMuxPath(container, splitSize.HasValue, allTypes.ToArray()); List<MuxJob> jobs = new List<MuxJob>(); List<MuxStream> subtitleStreams = new List<MuxStream>(subtitleStreamsArray); List<MuxStream> audioStreams = new List<MuxStream>(audioStreamsArray); int index = 0; int tempNumber = 1; string previousOutput = null; foreach (MuxPathLeg mpl in muxPath) { List<string> filesToDeleteThisJob = new List<string>(); MuxJob mjob = new MuxJob(); if (previousOutput != null) { mjob.Settings.MuxedInput = previousOutput; filesToDeleteThisJob.Add(previousOutput); } mjob.NbOfFrames = video.NumberOfFrames; mjob.NbOfBFrames = video.Settings.NbBframes; mjob.Codec = video.Settings.Codec.ToString(); string fpsFormated = String.Format("{0:##.###}", framerate); // this formating is required for mkvmerge at least to avoid fps rounding error mjob.Settings.Framerate = Convert.ToDecimal(fpsFormated); mjob.Settings.VideoName = video.Settings.VideoName; string tempOutputName = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output) + tempNumber + "."); tempNumber++; foreach (MuxableType o in mpl.handledInputTypes) { if (o.outputType is VideoType) { mjob.Settings.VideoInput = video.Output; if (inputsToDelete.Contains(video.Output)) filesToDeleteThisJob.Add(video.Output); mjob.Settings.DAR = video.DAR; } else if (o.outputType is AudioType) { MuxStream stream = audioStreams.Find(delegate(MuxStream m) { return (VideoUtil.guessAudioType(m.path) == o.outputType); }); if (stream != null) { mjob.Settings.AudioStreams.Add(stream); audioStreams.Remove(stream); if (inputsToDelete.Contains(stream.path)) filesToDeleteThisJob.Add(stream.path); } } else if (o.outputType is SubtitleType) { MuxStream stream = subtitleStreams.Find(delegate(MuxStream m) { return (VideoUtil.guessSubtitleType(m.path) == o.outputType); }); if (stream != null) { mjob.Settings.SubtitleStreams.Add(stream); subtitleStreams.Remove(stream); if (inputsToDelete.Contains(stream.path)) filesToDeleteThisJob.Add(stream.path); } } else if (o.outputType is ChapterType) { if ((VideoUtil.guessChapterType(chapterFile) == o.outputType)) mjob.Settings.ChapterFile = chapterFile; if (inputsToDelete.Contains(chapterFile)) filesToDeleteThisJob.Add(chapterFile); } else if (o.outputType is DeviceType) { if ((VideoUtil.guessDeviceType(deviceType) == o.outputType)) mjob.Settings.DeviceType = deviceType; } } foreach (MuxStream s in mjob.Settings.AudioStreams) { audioStreams.Remove(s); } foreach (MuxStream s in mjob.Settings.SubtitleStreams) { subtitleStreams.Remove(s); } mjob.FilesToDelete.AddRange(filesToDeleteThisJob); if (index == muxPath.Length - 1) { mjob.Settings.MuxedOutput = output; mjob.Settings.SplitSize = splitSize; mjob.Settings.DAR = video.DAR; mjob.ContainerType = container; } else { ContainerType cot = mpl.muxerInterface.GetContainersInCommon(muxPath[index + 1].muxerInterface)[0]; mjob.Settings.MuxedOutput = tempOutputName + cot.Extension; mjob.ContainerType = cot; } previousOutput = mjob.Settings.MuxedOutput; index++; jobs.Add(mjob); if (string.IsNullOrEmpty(mjob.Settings.VideoInput)) mjob.Input = mjob.Settings.MuxedInput; else mjob.Input = mjob.Settings.VideoInput; mjob.Output = mjob.Settings.MuxedOutput; mjob.MuxType = mpl.muxerInterface.MuxerType; } return new SequentialChain(jobs.ToArray()); }