Exemplo n.º 1
0
        public EditStreamInfoWindow(StreamInfo si)
        {
            try
            {
                InitializeComponent();
                this.si = new StreamInfo(si);
                comboBoxStreamType.Items.Clear();
                foreach (StreamType s in Enum.GetValues(typeof(StreamType))) comboBoxStreamType.Items.Add(s);
                comboBoxStreamType.SelectedItem = si.streamType;

                textBoxDescription.Text = si.desc;
                textBoxFilename.Text = si.filename;
                textBoxLanguage.Text = si.language;
                textBoxNumber.Text = si.number.ToString();
                textBoxTypeDesc.Text = si.typeDesc;
                textBoxAddInfo.Text = si.addInfo;

                checkBoxSelected.IsChecked = si.selected;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
        private bool DoSubtitle()
        {
            try
            {
                DoPlugin(PluginType.BeforeSubtitle);

                if (!Directory.Exists(settings.workingDir))
                {
                    logWindow.MessageDemux(Global.Res("ErrorWorkingDirectory"));
                    if (!silent) Global.ErrorMsg(Global.Res("ErrorWorkingDirectory"));
                    return false;
                }

                if (demuxedStreamList.streams.Count == 0)
                {
                    logWindow.MessageSubtitle(Global.Res("ErrorNoDemuxedStreams"));
                    if (!silent) Global.ErrorMsg(Global.Res("ErrorNoDemuxedStreams"));
                    return false;
                }

                string fps = "";
                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        if (si.extraFileInfo.GetType() == typeof(VideoFileInfo))
                        {
                            fps = ((VideoFileInfo)si.extraFileInfo).fps;
                            break;
                        }
                    }
                }
                if (fps == "")
                {
                    logWindow.MessageSubtitle(Global.Res("ErrorSetFramerate"));
                    if (!silent) Global.ErrorMsg(Global.Res("ErrorSetFramerate"));
                    return false;
                }

                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarSubtitle"));
                                
                int subtitleCount = 0;
                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Subtitle)
                    {
                        subtitleCount++;
                        if (si.extraFileInfo == null || si.extraFileInfo.GetType() != typeof(SubtitleFileInfo)) si.extraFileInfo = new SubtitleFileInfo();                        
                    }
                }

                if (subtitleCount == 0)
                {
                    logWindow.MessageSubtitle(Global.Res("InfoNoSubtitles"));
                    return true;
                }

                bool suptitle = false;

                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Subtitle)
                    {
                        if (si.advancedOptions != null && si.advancedOptions.GetType() == typeof(AdvancedSubtitleOptions))
                        {
                            if (((AdvancedSubtitleOptions)si.advancedOptions).supTitle)
                            {
                                if (!suptitle)
                                {
                                    suptitle = true;
                                }
                            }
                        }
                    }
                }

                int muxSubs = settings.muxSubs;
                if (suptitle) muxSubs = 0;

                // do not mux and copy subs
                if (muxSubs == 0 && settings.copySubs == 0)
                {
                    logWindow.MessageSubtitle(Global.Res("InfoNoSubtitlesProcessing"));
                    return true;
                }
                // only untouched subs
                else if (settings.muxUntouchedSubs && settings.copyUntouchedSubs)
                {
                    logWindow.MessageSubtitle(Global.Res("InfoNoSubtitlesProcessing"));
                    return true;
                }
                else if (settings.muxUntouchedSubs && settings.copySubs == 0)
                {
                    logWindow.MessageSubtitle(Global.Res("InfoNoSubtitlesProcessing"));
                    return true;
                }
                else if (muxSubs == 0 && settings.copyUntouchedSubs)
                {
                    logWindow.MessageSubtitle(Global.Res("InfoNoSubtitlesProcessing"));
                    return true;
                }

                DisableControls();

                bool sub = false;
                bool sup = false;

                if (settings.muxSubs > 0 && settings.muxSubs < 4)
                {
                    sub = true;
                }
                else if (settings.muxSubs >= 4)
                {
                    sup = true;
                }

                if (settings.copySubs > 0 && settings.copySubs < 4)
                {
                    sub = true;
                }
                else if (settings.copySubs >= 4)
                {
                    sup = true;
                }
                
                bool error = false;
                int subtitle = 0;
                for (int i = 0; i < demuxedStreamList.streams.Count; i++)
                {
                    if (demuxedStreamList.streams[i].streamType == StreamType.Subtitle)
                    {
                        if (demuxedStreamList.streams[i].extraFileInfo != null && demuxedStreamList.streams[i].extraFileInfo.GetType() == typeof(SubtitleFileInfo) &&
                            ((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).isSecond) continue;

                        subtitle++;
                        StreamInfo si = demuxedStreamList.streams[i];
                        if (sub)
                        {
                            UpdateStatus(Global.Res("StatusBar") + " " + String.Format(Global.Res("StatusBarSubtitleNormal"), subtitle, subtitleCount));                            
                            st = new SubtitleTool(settings, fps, ref si, false, false, false);
                            st.OnInfoMsg += new ExternalTool.InfoEventHandler(SubtitleMsg);
                            st.OnLogMsg += new ExternalTool.LogEventHandler(SubtitleMsg);
                            st.Start();
                            st.WaitForExit();
                            if (st == null || !st.Successfull) error = true;
                            
                            if (((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).containsForced)
                            {
                                UpdateStatus(Global.Res("StatusBar") + " " + String.Format(Global.Res("StatusBarSubtitleForced"), subtitle, subtitleCount));
                                st = new SubtitleTool(settings, fps, ref si, true, false, false);
                                st.OnInfoMsg += new ExternalTool.InfoEventHandler(SubtitleMsg);
                                st.OnLogMsg += new ExternalTool.LogEventHandler(SubtitleMsg);
                                st.Start();
                                st.WaitForExit();
                                if (st == null || !st.Successfull) error = true;
                            }
                        }
                        if (sup)
                        {
                            UpdateStatus(Global.Res("StatusBar") + " " + String.Format(Global.Res("StatusBarSubtitleNormalPgs"), subtitle, subtitleCount));
                            st = new SubtitleTool(settings, fps, ref si, false, false, true);
                            st.OnInfoMsg += new ExternalTool.InfoEventHandler(SubtitleMsg);
                            st.OnLogMsg += new ExternalTool.LogEventHandler(SubtitleMsg);
                            st.Start();
                            st.WaitForExit();
                            if (st == null || !st.Successfull) error = true;

                            if (((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).containsForced)
                            {
                                UpdateStatus(Global.Res("StatusBar") + " " + String.Format(Global.Res("StatusBarSubtitleForcedPgs"), subtitle, subtitleCount));
                                st = new SubtitleTool(settings, fps, ref si, true, false, true);
                                st.OnInfoMsg += new ExternalTool.InfoEventHandler(SubtitleMsg);
                                st.OnLogMsg += new ExternalTool.LogEventHandler(SubtitleMsg);
                                st.Start();
                                st.WaitForExit();
                                if (st == null || !st.Successfull) error = true;
                            }
                        }

                        if (settings.muxLowResSubs && (settings.muxSubs > 0 && settings.muxSubs <4))
                        {
                            UpdateStatus(Global.Res("StatusBar") + " " + String.Format(Global.Res("StatusBarSubtitleLowresNormal"), subtitle, subtitleCount));
                            si = demuxedStreamList.streams[i];
                            st = new SubtitleTool(settings, fps, ref si, false, true, false);
                            st.OnInfoMsg += new ExternalTool.InfoEventHandler(SubtitleMsg);
                            st.OnLogMsg += new ExternalTool.LogEventHandler(SubtitleMsg);
                            st.Start();
                            st.WaitForExit();
                            if (st == null || !st.Successfull) error = true;

                            if (((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).containsForced)
                            {
                                UpdateStatus(Global.Res("StatusBar") + " " + String.Format(Global.Res("StatusBarSubtitleLowresForced"), subtitle, subtitleCount));
                                st = new SubtitleTool(settings, fps, ref si, true, true, false);
                                st.OnInfoMsg += new ExternalTool.InfoEventHandler(SubtitleMsg);
                                st.OnLogMsg += new ExternalTool.LogEventHandler(SubtitleMsg);
                                st.Start();
                                st.WaitForExit();
                                if (st == null || !st.Successfull) error = true;
                            }
                        }

                        if (!error)
                        {
                            if (si.extraFileInfo != null && si.extraFileInfo.GetType() == typeof(SubtitleFileInfo))
                            {
                                SubtitleFileInfo sfi = (SubtitleFileInfo)si.extraFileInfo;
                                if ((sfi.forcedIdx != "" && sfi.normalIdx != "") || (sfi.forcedSup != "" && sfi.normalSup != ""))
                                {
                                    StreamInfo si2 = new StreamInfo(demuxedStreamList.streams[i]);
                                    if (demuxedStreamList.streams[i].extraFileInfo != null && demuxedStreamList.streams[i].extraFileInfo.GetType() == typeof(SubtitleFileInfo))
                                    {
                                        ((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).forcedIdx = "";
                                        ((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).forcedSub = "";
                                        ((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).forcedSup = "";
                                        ((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).forcedIdxLowRes = "";
                                        ((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).forcedSubLowRes = "";
                                        ((SubtitleFileInfo)demuxedStreamList.streams[i].extraFileInfo).isSecond = false;
                                    }
                                    si2.desc += " (only forced)"; ;
                                    if (si2.extraFileInfo != null && si2.extraFileInfo.GetType() == typeof(SubtitleFileInfo))
                                    {
                                        ((SubtitleFileInfo)si2.extraFileInfo).normalIdx = "";
                                        ((SubtitleFileInfo)si2.extraFileInfo).normalSub = "";
                                        ((SubtitleFileInfo)si2.extraFileInfo).normalSup = "";
                                        ((SubtitleFileInfo)si2.extraFileInfo).normalIdxLowRes = "";
                                        ((SubtitleFileInfo)si2.extraFileInfo).normalSubLowRes = "";
                                        ((SubtitleFileInfo)si2.extraFileInfo).isSecond = true;
                                    }
                                    bool add = true;
                                    if (demuxedStreamList.streams.Count > i + 1)
                                    {
                                        if (demuxedStreamList.streams[i + 1].extraFileInfo != null && demuxedStreamList.streams[i + 1].extraFileInfo.GetType() == typeof(SubtitleFileInfo))
                                        {
                                            SubtitleFileInfo stfi = (SubtitleFileInfo)demuxedStreamList.streams[i + 1].extraFileInfo;
                                            if (stfi.normalIdx == ((SubtitleFileInfo)si2.extraFileInfo).normalIdx &&
                                                stfi.normalSub == ((SubtitleFileInfo)si2.extraFileInfo).normalSub &&
                                                stfi.normalSup == ((SubtitleFileInfo)si2.extraFileInfo).normalSup &&
                                                stfi.normalIdxLowRes == ((SubtitleFileInfo)si2.extraFileInfo).normalIdxLowRes &&
                                                stfi.normalSubLowRes == ((SubtitleFileInfo)si2.extraFileInfo).normalSubLowRes &&
                                                stfi.forcedIdx == ((SubtitleFileInfo)si2.extraFileInfo).forcedIdx &&
                                                stfi.forcedSub == ((SubtitleFileInfo)si2.extraFileInfo).forcedSub &&
                                                stfi.forcedSup == ((SubtitleFileInfo)si2.extraFileInfo).forcedSup &&
                                                stfi.forcedIdxLowRes == ((SubtitleFileInfo)si2.extraFileInfo).forcedIdxLowRes &&
                                                stfi.forcedSubLowRes == ((SubtitleFileInfo)si2.extraFileInfo).forcedSubLowRes &&
                                                demuxedStreamList.streams[i + 1].filename == si2.filename)
                                            {
                                                add = false;
                                            }
                                        }
                                    }
                                    if (add)
                                    {
                                        demuxedStreamList.streams.Insert(i + 1, si2);
                                        i++;
                                    }
                                }
                                // treat track as forced track even if it doesn't contain forced subs
                                else if (sfi.normalIdx != "" || sfi.normalSup != "")
                                {
                                    if (si.advancedOptions != null && si.advancedOptions.GetType() == typeof(AdvancedSubtitleOptions))
                                    {
                                        if (((AdvancedSubtitleOptions)si.advancedOptions).isForced)
                                        {
                                            sfi.forcedIdx = sfi.normalIdx;
                                            sfi.forcedSub = sfi.normalSub;
                                            sfi.forcedSup = sfi.normalSup;

                                            sfi.forcedIdxLowRes = sfi.normalIdxLowRes;
                                            sfi.forcedSubLowRes = sfi.normalSubLowRes;

                                            sfi.normalIdx = "";
                                            sfi.normalSub = "";
                                            sfi.normalSup = "";

                                            sfi.normalIdxLowRes = "";
                                            sfi.normalSubLowRes = "";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    demuxedStreamsWindow.UpdateDemuxedStreams();
                }

                if (error)
                {
                    logWindow.MessageSubtitle(Global.Res("ErrorSubtitle"));
                    return false;
                }

                DoPlugin(PluginType.AfterSubtitle);

                TitleInfo.SaveStreamInfoFile(demuxedStreamList, settings.workingDir + "\\" + settings.filePrefix + "_streamInfo.xml");
                demuxedStreamsWindow.UpdateDemuxedStreams();

                return true;
            }
            catch (Exception ex)
            {
                logWindow.MessageSubtitle(Global.Res("ErrorException") + " " + ex.Message);
                return false;
            }
            finally
            {
                EnableControls();
                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarReady"));
            }
        }
Exemplo n.º 3
0
 public StreamInfo(StreamInfo orig)
 {
     try
     {
         this.addInfo = orig.addInfo;
         this.desc = orig.desc;
         this.filename = orig.filename;
         this.language = orig.language;
         this.number = orig.number;
         this.selected = orig.selected;
         this.streamType = orig.streamType;
         this.typeDesc = orig.typeDesc;
         Type extraFileInfoType = orig.extraFileInfo.GetType();
         Type advancedOptionsType = orig.advancedOptions.GetType();
         this.extraFileInfo = (ExtraFileInfo)Activator.CreateInstance(extraFileInfoType, orig.extraFileInfo);
         this.advancedOptions = (AdvancedOptions)Activator.CreateInstance(advancedOptionsType, orig.advancedOptions);
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 4
0
        protected override void Process()
        {
            try
            {
                string res = Output;
                res = res.Replace("\b", "");
                res = res.Replace("\r", "");

                string[] tmp = res.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < tmp.Length; i++)
                {
                    tmp[i] = tmp[i].Trim();
                }

                if (res.Trim() == "")
                {
                    Info("Failed to get stream infos");
                    return;
                }

                TitleInfo ti = new TitleInfo();
                if (files != null)
                {
                    ti.files.Clear();
                    foreach (string s in files) ti.files.Add(s);
                }

                if (tmp[0][0] == '-')
                {
                    int length = 0;
                    for (int i = 0; i < tmp[0].Length; i++)
                    {
                        if (tmp[0][i] == '-')
                        {
                            length++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    tmp[0] = tmp[0].Substring(length, tmp[0].Length - length);
                    tmp[0] = tmp[0].Trim();
                    ti.desc = tmp[0];
                    ti.streamNumber = streamNumber;
                }

                for (int i = 0; i < tmp.Length; i++)
                {
                    if (Regex.IsMatch(tmp[i], "^[0-9.*].*:"))
                    {
                        StreamInfo sr = new StreamInfo();
                        sr.desc = tmp[i];
                        if (i < tmp.Length - 1)
                        {
                            if (!Regex.IsMatch(tmp[i + 1], "^[0-9.*].*:"))
                            {
                                sr.addInfo = tmp[i + 1];

                            }
                        }

                        int pos = tmp[i].IndexOf(':');
                        string substr = tmp[i].Substring(0, pos);
                        sr.number = Convert.ToInt32(substr);

                        substr = tmp[i].Substring(pos + 1).Trim();
                        string[] tmpInfo = substr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        if (tmpInfo.Length > 0)
                        {
                            sr.typeDesc = tmpInfo[0];
                            if (tmpInfo[0] == "Chapters")
                            {
                                sr.streamType = StreamType.Chapter;
                            }
                            else if (videoTypes.Contains(tmpInfo[0]))
                            {
                                sr.streamType = StreamType.Video;
                            }
                            else if (ac3AudioTypes.Contains(tmpInfo[0]))
                            {
                                sr.streamType = StreamType.Audio;
                                if (tmpInfo.Length > 1)
                                {
                                    sr.language = tmpInfo[1].Trim();
                                }
                                else
                                {
                                    sr.language = "undef";
                                }
                            }
                            else if (dtsAudioTypes.Contains(tmpInfo[0]))
                            {
                                sr.streamType = StreamType.Audio;
                                if (tmpInfo.Length > 1)
                                {
                                    sr.language = tmpInfo[1].Trim();
                                }
                                else
                                {
                                    sr.language = "undef";
                                }
                            }
                            else if (tmpInfo[0] == "Subtitle (PGS)")
                            {
                                sr.streamType = StreamType.Subtitle;
                                if (tmpInfo.Length > 1)
                                {
                                    sr.language = tmpInfo[1].Trim();
                                }
                                else
                                {
                                    sr.language = "undef";
                                }
                            }
                            else
                            {
                                sr.streamType = StreamType.Unknown;
                            }
                        }
                        else
                        {
                            sr.typeDesc = "Unknown";
                            sr.streamType = StreamType.Unknown;
                        }

                        ti.streams.Add(sr);
                    }
                }

                result.Add(ti);
                successfull = true;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 5
0
        public SubtitleTool(UserSettings settings, string fps, ref StreamInfo si, bool onlyForced, bool lowRes, bool pgs)
            : base()
        {
            try
            {
                this.settings = settings;
                this.fps = fps;
                this.Path = settings.javaPath;
                this.si = new StreamInfo();
                this.si = si;
                this.onlyForced = onlyForced;
                this.lowRes = lowRes;
                this.pgs = pgs;
                                
                if (this.fps == "24.000") this.fps = "24";
                if (this.fps == "25.000") this.fps = "25";
                if (this.fps == "50.000") this.fps = "50";

                string format = ".sub";
                if (pgs)
                {
                    format = ".sup";
                }

                if (!lowRes)
                {
                    if (!onlyForced)
                    {
                        output = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                                "_complete" + format;

                        outputIdx = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                            "_complete.idx";
                    }
                    else
                    {
                        output = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                                "_onlyforced" + format;

                        outputIdx = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                            "_onlyforced.idx";
                    }
                }
                else
                {
                    if (!onlyForced)
                    {
                        output = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                                "_complete_lowres.sub";

                        outputIdx = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                            "_complete_lowres.idx";
                    }
                    else
                    {
                        output = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                                "_onlyforced_lowres.sub";

                        outputIdx = settings.workingDir + "\\" + System.IO.Path.GetFileNameWithoutExtension(si.filename) +
                            "_onlyforced_lowres.idx";
                    }
                }

                this.Parameter = "-jar \"" + settings.sup2subPath + "\" \"" +
                            si.filename + "\" \"" + output + "\" /fps:" + this.fps;

                if (!onlyForced)
                {
                }
                else
                {
                    this.Parameter += " /forced";
                }

                if (!lowRes)
                {
                    if (!settings.resize720p)
                    {
                        this.Parameter += " /res:1080";
                    }
                    else
                    {
                        this.Parameter += " /res:720";
                    }
                }
                else
                {
                    this.Parameter += " /res:576";
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 6
0
 private void buttonAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         StreamInfo si = new StreamInfo();
         EditStreamInfoWindow esiw = new EditStreamInfoWindow(si);
         esiw.ShowDialog();
         if (esiw.DialogResult == true)
         {
             mainWindow.DemuxedStreams.streams.Add(esiw.streamInfo);
             UpdateDemuxedStreams();
         }
     }
     catch (Exception)
     {
     }
 }