Esempio n. 1
0
 public OneClickStream(AudioTrackInfo oInfo)
 {
     this._trackInfo    = oInfo;
     this._encodingMode = AudioEncodingMode.IfCodecDoesNotMatch;
 }
Esempio n. 2
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);
                    }
                }
            }
        }
Esempio n. 3
0
        private void updatePossibleContainers()
        {
            // Since everything calls everything else, this is just a safeguard to make sure we don't infinitely recurse
            if (beingCalled)
            {
                return;
            }
            beingCalled = true;

            List <AudioEncoderType> audioCodecs         = new List <AudioEncoderType>();
            List <MuxableType>      dictatedOutputTypes = new List <MuxableType>();

            for (int i = 0; i < audioConfigControl.Count; ++i)
            {
                if (audioTrack[i].SelectedIndex == 0) // "None"
                {
                    continue;
                }

                if (audioConfigControl[i].Settings != null && !audioConfigControl[i].DontEncode)
                {
                    audioCodecs.Add(audioConfigControl[i].Settings.EncoderType);
                }

                else if (audioConfigControl[i].DontEncode)
                {
                    string typeString;

                    if (audioTrack[i].SelectedSCItem.IsStandard)
                    {
                        AudioTrackInfo ati = (AudioTrackInfo)audioTrack[i].SelectedObject;
                        typeString = "file." + ati.Type;
                    }
                    else
                    {
                        typeString = audioTrack[i].SelectedText;
                    }

                    if (VideoUtil.guessAudioType(typeString) != null)
                    {
                        dictatedOutputTypes.Add(VideoUtil.guessAudioMuxableType(typeString, false));
                    }
                }
            }

            List <ContainerType> tempSupportedOutputTypes = this.muxProvider.GetSupportedContainers(
                VideoSettings.EncoderType, audioCodecs.ToArray(), dictatedOutputTypes.ToArray());

            List <ContainerType> supportedOutputTypes = new List <ContainerType>();

            foreach (ContainerType c in acceptableContainerTypes)
            {
                if (tempSupportedOutputTypes.Contains(c))
                {
                    supportedOutputTypes.Add(c);
                }
            }

            if (supportedOutputTypes.Count == 0)
            {
                if (tempSupportedOutputTypes.Count > 0 && !ignoreRestrictions)
                {
                    string message = string.Format(
                        "No container type could be found that matches the list of acceptable types" +
                        "in your chosen one click profile. {0}" +
                        "Your restrictions are now being ignored.", Environment.NewLine);
                    MessageBox.Show(message, "Filetype restrictions too restrictive", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ignoreRestrictions = true;
                }
                if (ignoreRestrictions)
                {
                    supportedOutputTypes = tempSupportedOutputTypes;
                }
                if (tempSupportedOutputTypes.Count == 0)
                {
                    MessageBox.Show("No container type could be found for your current settings. Please modify the codecs you use", "No container found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (supportedOutputTypes.Count > 0)
            {
                this.containerFormat.Items.Clear();
                this.containerFormat.Items.AddRange(supportedOutputTypes.ToArray());
                this.containerFormat.SelectedIndex = 0;
                this.output.Filename = Path.ChangeExtension(output.Filename, (this.containerFormat.SelectedItem as ContainerType).Extension);
            }
            beingCalled = false;
        }