Ejemplo n.º 1
0
        /// <summary>
        /// if input is a track number (of the form, "::&lt;number&gt;::")
        /// then it returns the file path of that track number. Otherwise,
        /// it returns the string only
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private string ConvertTrackNumberToFile(string input, ref int delay)
        {
            if (String.IsNullOrEmpty(input))
            {
                log.Warn("Couldn't find audio file. Skipping track.");
                return(null);
            }

            if (input.StartsWith("::") && input.EndsWith("::") && input.Length > 4)
            {
                string sub = input.Substring(2, input.Length - 4);
                try
                {
                    int    t = int.Parse(sub);
                    string s = audioFiles[t];
                    if (PrettyFormatting.getDelay(s) != null)
                    {
                        delay = PrettyFormatting.getDelay(s) ?? 0;
                    }
                    return(s);
                }
                catch (Exception)
                {
                    log.Warn(string.Format("Couldn't find audio file for track {0}. Skipping track.", input));
                    return(null);
                }
            }

            return(input);
        }
Ejemplo n.º 2
0
        private void input_FileSelected(FileBar sender, FileBarEventArgs args)
        {
            audioDelay.Value = PrettyFormatting.getDelayAndCheck(input.Filename) ?? 0;

            bool bFound = false;

            foreach (KeyValuePair <string, string> strLanguage in LanguageSelectionContainer.Languages)
            {
                if (input.Filename.ToLower(System.Globalization.CultureInfo.InvariantCulture).Contains(strLanguage.Key.ToLower(System.Globalization.CultureInfo.InvariantCulture)))
                {
                    SetLanguage(strLanguage.Key);
                    bFound = true;
                    break;
                }
            }
            if (!bFound && input.Filename.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".idx"))
            {
                List <SubtitleInfo> subTracks;
                idxReader.readFileProperties(input.Filename, out subTracks);
                if (subTracks.Count > 0)
                {
                    SetLanguage(LanguageSelectionContainer.Short2FullLanguageName(subTracks[0].Name));
                }
            }
            raiseEvent();
        }
Ejemplo n.º 3
0
        public void openAudioFile(string fileName)
        {
            AudioInput = fileName;

            AudioOutput = FileUtil.AddToFileName(fileName, MainForm.Instance.Settings.AudioExtension);
            audioContainer_SelectedIndexChanged(null, null);

            delay.Value = PrettyFormatting.getDelay(fileName);
        }
Ejemplo n.º 4
0
        public string verifyAudioSettings()
        {
            int inputDelay = PrettyFormatting.getDelay(AudioInput) ?? 0;
            int?delay      = PrettyFormatting.getDelay(AudioOutput);

            if (delay != null && delay.Value != (inputDelay - (int)this.delay.Value))
            {
                if (MessageBox.Show(string.Format(
                                        "The output filename suggests the audio delay is {0}ms. " +
                                        "However, the input delay is {1}ms and the delay correction is {2}ms, " +
                                        "so a delay of {3}ms is more appropriate. Do you want MeGUI to correct " +
                                        "the output filename before adding the job?", delay.Value, inputDelay,
                                        this.delay.Value, (inputDelay - (int)this.delay.Value)),
                                    "Output filename suggests wrong delay", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    AudioOutput = PrettyFormatting.ReplaceDelay(AudioOutput, (inputDelay - (int)this.delay.Value));
                }
            }

            AudioJob stream;

            try
            {
                stream = AudioJob;
            }
            catch (MeGUIException m)
            {
                return(m.Message);
            }

            if (stream == null)
            {
                return("Audio input, audio output, and audio settings must all be configured");
            }

            string fileErr = MainForm.verifyInputFile(this.AudioInput);

            if (fileErr != null)
            {
                return("Problem with audio input filename:\n" + fileErr);
            }

            fileErr = MainForm.verifyOutputFile(this.AudioOutput);
            if (fileErr != null)
            {
                return("Problem with audio output filename:\n" + fileErr);
            }
            AudioType aot = this.audioContainer.SelectedItem as AudioType;

            // test output file extension
            if (!Path.GetExtension(this.AudioOutput).Replace(".", "").Equals(aot.Extension, StringComparison.InvariantCultureIgnoreCase))
            {
                return("Audio output filename does not have the correct extension.\nBased on current settings, it should be "
                       + aot.Extension);
            }
            return(null);
        }
Ejemplo n.º 5
0
        private void input_SelectionChanged(object sender, string val)
        {
            // get language
            bool bFound = false;

            foreach (KeyValuePair <string, string> strLanguage in LanguageSelectionContainer.Languages)
            {
                if (input.SelectedText.ToLower(System.Globalization.CultureInfo.InvariantCulture).Contains(strLanguage.Key.ToLower(System.Globalization.CultureInfo.InvariantCulture)))
                {
                    SetLanguage(strLanguage.Key);
                    bFound = true;
                    break;
                }
            }
            if (!bFound && input.SelectedText.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".idx"))
            {
                List <SubtitleInfo> subTracks;
                idxReader.readFileProperties(input.SelectedText, out subTracks);
                if (subTracks.Count > 0)
                {
                    SetLanguage(LanguageSelectionContainer.Short2FullLanguageName(subTracks[0].Name));
                    bFound = true;
                }
            }
            if (!bFound && this.SelectedItem != null && this.SelectedStreamIndex > 0)
            {
                SetLanguage(defaultLanguage);
            }

            // get delay & track name
            delay.Value = 0;
            if (this.SelectedItem != null && this.SelectedStreamIndex > 0 && this.SelectedItem.Tag is OneClickStream)
            {
                delay.Value  = ((OneClickStream)this.SelectedItem.Tag).Delay;
                subName.Text = ((OneClickStream)this.SelectedItem.Tag).Name;
            }
            if (PrettyFormatting.getDelayAndCheck(input.SelectedText) != null)
            {
                delay.Value = PrettyFormatting.getDelayAndCheck(input.SelectedText) ?? 0;
            }

            if (showDefaultStream)
            {
                chkDefaultStream.Checked = this.SelectedStream.DefaultStream;
            }

            if (showForceStream)
            {
                chkForceStream.Checked = this.SelectedStream.ForcedStream;
            }

            raiseEvent();
        }
Ejemplo n.º 6
0
        private void openInput(string fileName)
        {
            input.Filename = fileName;
            Dar?ar;
            int maxHorizontalResolution;
            List <AudioTrackInfo> audioTracks;
            List <SubtitleInfo>   subtitles;

            vUtil.openVideoSource(fileName, out audioTracks, out subtitles, out ar, out maxHorizontalResolution);

            List <object> trackNames = new List <object>();

            trackNames.Add("None");
            foreach (object o in audioTracks)
            {
                trackNames.Add(o);
            }

            foreach (FileSCBox b in audioTrack)
            {
                b.StandardItems = trackNames.ToArray();
            }

            foreach (AudioTrackInfo ati in audioTracks)
            {
                if (ati.Language.ToLower().Equals(mainForm.Settings.DefaultLanguage1.ToLower()) &&
                    audioTrack1.SelectedIndex == 0)
                {
                    audioTrack1.SelectedObject = ati;
                    continue;
                }
                if (ati.Language.ToLower().Equals(mainForm.Settings.DefaultLanguage2.ToLower()) &&
                    audioTrack2.SelectedIndex == 0)
                {
                    audioTrack2.SelectedObject = ati;
                    continue;
                }
            }

            horizontalResolution.Maximum = maxHorizontalResolution;

            string chapterFile = VideoUtil.getChapterFile(fileName);

            if (File.Exists(chapterFile))
            {
                this.chapterFile.Filename = chapterFile;
            }

            workingDirectory.Filename = Path.GetDirectoryName(fileName);
            workingName.Text          = PrettyFormatting.ExtractWorkingName(fileName);
            this.updateFilename();
            this.ar.Value = ar;
        }
Ejemplo n.º 7
0
        private void input_SelectionChanged(object sender, string val)
        {
            // get language
            bool   bFound      = false;
            string strLanguage = LanguageSelectionContainer.GetLanguageFromFileName(System.IO.Path.GetFileNameWithoutExtension(input.SelectedText));

            if (!String.IsNullOrEmpty(strLanguage))
            {
                SetLanguage(strLanguage);
                bFound = true;
            }
            else if (input.SelectedText.ToLowerInvariant().EndsWith(".idx"))
            {
                List <SubtitleInfo> subTracks;
                idxReader.readFileProperties(input.SelectedText, out subTracks);
                if (subTracks.Count > 0)
                {
                    SetLanguage(LanguageSelectionContainer.LookupISOCode(subTracks[0].Name));
                    bFound = true;
                }
            }
            if (!bFound && this.SelectedItem != null && this.SelectedStreamIndex > 0)
            {
                SetLanguage(MainForm.Instance.Settings.DefaultLanguage1);
            }

            // get delay & track name
            delay.Value = 0;
            if (this.SelectedItem != null && this.SelectedStreamIndex > 0 && this.SelectedItem.Tag is OneClickStream)
            {
                delay.Value  = ((OneClickStream)this.SelectedItem.Tag).Delay;
                subName.Text = ((OneClickStream)this.SelectedItem.Tag).Name;
            }
            if (PrettyFormatting.getDelayAndCheck(input.SelectedText) != null)
            {
                delay.Value = PrettyFormatting.getDelayAndCheck(input.SelectedText) ?? 0;
            }

            if (showDefaultStream)
            {
                chkDefaultStream.Checked = this.SelectedStream.DefaultStream;
            }

            if (showForceStream)
            {
                chkForceStream.Checked = this.SelectedStream.ForcedStream;
            }

            raiseEvent();
        }
Ejemplo n.º 8
0
        public void openAudioFile(string fileName)
        {
            AudioInput  = fileName;
            delay.Value = PrettyFormatting.getDelay(fileName);

            try
            {
                AudioOutput = FileUtil.AddToFileName(fileName, MainForm.Instance.Settings.AudioExtension);
            }
            catch (Exception e)
            {
                throw new ApplicationException("The value detected as delay in your filename seems to be too high/low for MeGUI." +
                                               "Try to recreate it with the appropriate tools." + e.Message, e);
            }

            audioContainer_SelectedIndexChanged(null, null);
        }
Ejemplo n.º 9
0
        public void openAudioFile(string fileName)
        {
            AudioInput = fileName;
            delay.Value = PrettyFormatting.getDelayAndCheck(fileName) ?? 0;

            try
            {
                AudioOutput = FileUtil.AddToFileName(PrettyFormatting.ReplaceDelay(fileName, 0), MainForm.Instance.Settings.AudioExtension);
            }
            catch (Exception e)
            {
               throw new ApplicationException("The value detected as delay in your filename seems to be too high/low for MeGUI." +
                                              "Try to recreate it with the appropriate tools." + e.Message, e);
            }

            string projectPath = FileUtil.GetOutputFolder(fileName);
            AudioOutput = Path.Combine(projectPath, Path.GetFileName(AudioOutput));
            
            audioContainer_SelectedIndexChanged(null, null);         
        }
Ejemplo n.º 10
0
        /// <summary>
        /// if input is a track number (of the form, "::&lt;number&gt;::")
        /// then it returns the file path of that track number. Otherwise,
        /// it returns the string only
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private string convertTrackNumberToFile(string input, ref int delay)
        {
            if (input.StartsWith("::") && input.EndsWith("::") && input.Length > 4)
            {
                string sub = input.Substring(2, input.Length - 4);
                try
                {
                    int    t = int.Parse(sub);
                    string s = audioFiles[t];
                    delay = PrettyFormatting.getDelay(s);
                    return(s);
                }
                catch (Exception)
                {
                    mainForm.addToLog("Couldn't find audio file for track {0}. Skipping track.", input);
                    return(null);
                }
            }

            return(input);
        }
Ejemplo n.º 11
0
        private void input_FileSelected(FileBar sender, FileBarEventArgs args)
        {
            audioDelay.Value = PrettyFormatting.getDelayAndCheck(input.Filename) ?? 0;

            string strLanguage = LanguageSelectionContainer.GetLanguageFromFileName(System.IO.Path.GetFileNameWithoutExtension(input.Filename));

            if (!String.IsNullOrEmpty(strLanguage))
            {
                SetLanguage(strLanguage);
            }
            else if (input.Filename.ToLowerInvariant().EndsWith(".idx"))
            {
                List <SubtitleInfo> subTracks;
                idxReader.readFileProperties(input.Filename, out subTracks);
                if (subTracks.Count > 0)
                {
                    SetLanguage(LanguageSelectionContainer.LookupISOCode(subTracks[0].Name));
                }
            }

            raiseEvent();
        }
Ejemplo n.º 12
0
 public void openAudioFile(string p)
 {
     delay.Value = PrettyFormatting.getDelayAndCheck(p) ?? 0;
 }
Ejemplo n.º 13
0
 public void TestPrettyFormatting()
 {
     Expect(PrettyFormatting.ExtractWorkingName(@"D:\Encode\Satellite\FileName.mpg"), EqualTo("Filename"));
 }
Ejemplo n.º 14
0
 private void input_FileSelected(FileBar sender, FileBarEventArgs args)
 {
     audioDelay.Value = PrettyFormatting.getDelayAndCheck(input.Filename) ?? 0;
     raiseEvent();
 }
Ejemplo n.º 15
0
 public void openAudioFile(string p)
 {
     delay.Value = PrettyFormatting.getDelay(p);
 }