Exemple #1
0
 public void setConfig(string input, string output, bool indexAllTracks, List <int> trackIDs, int pgc)
 {
     this.dialogMode  = true;
     queueButton.Text = "Update";
     this.input.Text  = input;
     openVideo(input);
     this.projectName.Text = output;
     checkIndexIO();
     if (indexAllTracks)
     {
         keepAllTracks.Checked = true;
     }
     else
     {
         demuxSelectedTracks.Checked = true;
         int        index        = 0;
         List <int> checkedItems = new List <int>();
         foreach (object item in subtitleTracks.Items)
         {
             SubtitleInfo si = (SubtitleInfo)item;
             if (trackIDs.Contains(si.Index))
             {
                 checkedItems.Add(index);
             }
             index++;
         }
         foreach (int idx in checkedItems)
         {
             subtitleTracks.SetItemChecked(idx, true);
         }
     }
     this.pgc.Value = pgc;
 }
Exemple #2
0
        /// <summary>
        /// reads the idx file, which is essentially a text file
        /// the first few lines contain the video properties in plain text and the
        /// last line contains index, language and timestamp from subtitles
        /// this method reads indexes and languages and store it internally, then
        /// closes the idx file again
        /// </summary>
        public static void readFileProperties(string infoFile, out List <SubtitleInfo> subtitles)
        {
            subtitles = new List <SubtitleInfo>();

            try
            {
                using (StreamReader sr = new StreamReader(infoFile))
                {
                    string line = sr.ReadLine();
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.StartsWith("id")) // Language & Index values found
                        {
                            string       lng = line.Substring(4, 2);
                            int          idx = Convert.ToInt32(line.Substring(15, 1));
                            SubtitleInfo si  = new SubtitleInfo(lng, idx);
                            subtitles.Add(si);
                        }
                    }
                }
            }
            catch (Exception i)
            {
                MessageBox.Show("The following error ocurred when parsing the idx file " + infoFile + "\r\n" + i.Message, "Error parsing idx file", MessageBoxButtons.OK);
            }
        }
        private SubtitleIndexJob generateJob()
        {
            List <int> trackIDs = new List <int>();

            foreach (object itemChecked in subtitleTracks.CheckedItems)
            {
                SubtitleInfo si = (SubtitleInfo)itemChecked;
                trackIDs.Add(si.Index);
            }
            return(new SubtitleIndexJob(input.Filename, output.Filename, keepAllTracks.Checked, trackIDs, (int)pgc.Value));
        }
Exemple #4
0
        private SubtitleIndexJob generateJob()
        {
            List <int> trackIDs = new List <int>();

            foreach (object itemChecked in subtitleTracks.CheckedItems)
            {
                SubtitleInfo si = (SubtitleInfo)itemChecked;
                trackIDs.Add(si.Index);
            }
            SubtitleIndexJob job = this.jobUtil.generateSubtitleIndexJob(input.Text, projectName.Text, keepAllTracks.Checked, trackIDs, (int)pgc.Value);

            return(job);
        }
Exemple #5
0
        /// <summary>
        /// reads the idx file, which is essentially a text file
        /// the first few lines contain the video properties in plain text and the
        /// last line contains index, language and timestamp from subtitles
        /// this method reads indexes and languages and store it internally, then
        /// closes the idx file again
        /// </summary>
        public static void readFileProperties(string infoFile, out List <SubtitleInfo> subtitles)
        {
            subtitles = new List <SubtitleInfo>();
            string       lng = "";
            int          idx = 0;
            SubtitleInfo si;
            bool         bNewSubIDFound = false;
            string       line;

            try
            {
                using (StreamReader sr = new StreamReader(infoFile))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.StartsWith("id")) // Language & Index values found
                        {
                            lng            = line.Substring(4, 2);
                            idx            = Convert.ToInt32(line.Substring(15, 1));
                            bNewSubIDFound = true;
                        }

                        if (line.StartsWith("timestamp: ") && bNewSubIDFound) // to ensure to have a sub, not just an idx/lng
                        {
                            si = new SubtitleInfo(lng, idx);
                            subtitles.Add(si);
                            bNewSubIDFound = false;
                        }
                    }
                }
            }
            catch (Exception i)
            {
                MessageBox.Show("The following error ocurred when parsing the idx file " + infoFile + "\r\n" + i.Message, "Error parsing idx file", MessageBoxButtons.OK);
            }
        }
Exemple #6
0
        /// <summary>
        /// gets information about a video source based on its DVD Decrypter generated info file
        /// </summary>
        /// <param name="infoFile">the info file to be analyzed</param>
        /// <param name="audioTracks">the audio tracks found</param>
        /// <param name="aspectRatio">the aspect ratio of the video</param>
        public void getSourceInfo(string infoFile, out List <AudioTrackInfo> audioTracks, out List <SubtitleInfo> subtitles,
                                  out Dar?aspectRatio, out int maxHorizontalResolution)
        {
            StreamReader sr = null;

            audioTracks             = new List <AudioTrackInfo>();
            subtitles               = new List <SubtitleInfo>();
            aspectRatio             = null;
            maxHorizontalResolution = 5000;
            try
            {
                sr = new StreamReader(infoFile, System.Text.Encoding.Default);
                string line = ""; int LineCount = 0;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.IndexOf("Video") != -1)
                    {
                        char[]   separator  = { '/' };
                        string[] split      = line.Split(separator, 1000);
                        string   resolution = split[1];
                        resolution = resolution.Substring(1, resolution.IndexOf('x') - 1);
                        maxHorizontalResolution = Int32.Parse(resolution);
                        string ar = split[2].Substring(1, split[2].Length - 2);

                        aspectRatio = Dar.A1x1;
                        if (split[1].Contains("PAL"))
                        {
                            if (ar.Equals("16:9"))
                            {
                                aspectRatio = Dar.ITU16x9PAL;
                            }
                            else if (ar.Equals("4:3"))
                            {
                                aspectRatio = Dar.ITU4x3PAL;
                            }
                        }
                        else if (split[1].Contains("NTSC"))
                        {
                            if (ar.Equals("16:9"))
                            {
                                aspectRatio = Dar.ITU16x9NTSC;
                            }
                            else if (ar.Equals("4:3"))
                            {
                                aspectRatio = Dar.ITU4x3NTSC;
                            }
                        }
                    }
                    else if (line.IndexOf("Audio") != -1)
                    {
                        char[]         separator = { '/' };
                        string[]       split     = line.Split(separator, 1000);
                        AudioTrackInfo ati       = new AudioTrackInfo();
                        ati.Type = split[0].Substring(split[0].LastIndexOf("-") + 1).Trim();
                        if (ati.Type.Equals("DTS"))
                        {
                            continue;                             // skip DTS tracks as BeSweet can't handle them
                        }
                        string trackID = split[0].Substring(3, 1);
                        ati.TrackID    = Int32.Parse(trackID) + 1;
                        ati.NbChannels = split[1].Trim();
                        ati.TrackInfo  = new TrackInfo(split[4].Trim(), null);
                        audioTracks.Add(ati);
                    }
                    else if (line.IndexOf("Subtitle") != -1)
                    {
                        char[]       separator = { '-' };
                        string[]     split     = line.Split(separator, 1000);
                        string       language  = split[2].Trim();
                        SubtitleInfo si        = new SubtitleInfo(language, LineCount);
                        LineCount++; // must be there coz vobsub index begins to zero...
                        subtitles.Add(si);
                    }
                }
            }
            catch (Exception i)
            {
                MessageBox.Show("The following error ocurred when parsing the info file " + infoFile + "\r\n" + i.Message, "Error parsing info file", MessageBoxButtons.OK);
                audioTracks.Clear();
            }
            finally
            {
                if (sr != null)
                {
                    try
                    {
                        sr.Close();
                    }
                    catch (IOException i)
                    {
                        Trace.WriteLine("IO Exception when closing StreamReader in VobInputWindow: " + i.Message);
                    }
                }
            }
        }