コード例 #1
0
        private bool DoMux()
        {
            try
            {
                DoPlugin(PluginType.BeforeMux);

                int videoStream    = 0;
                int audioStream    = 0;
                int chapterStream  = 0;
                int subtitleStream = 0;

                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        if (si.extraFileInfo.GetType() == typeof(VideoFileInfo))
                        {
                            if (((VideoFileInfo)si.extraFileInfo).encodedFile != "")
                            {
                                if (File.Exists(((VideoFileInfo)si.extraFileInfo).encodedFile))
                                {
                                    videoStream++;
                                }
                            }
                        }
                    }
                    else if (si.streamType == StreamType.Audio)
                    {
                        if (File.Exists(si.filename))
                        {
                            audioStream++;
                        }
                    }
                    else if (si.streamType == StreamType.Chapter)
                    {
                        chapterStream++;
                    }
                    else if (si.streamType == StreamType.Subtitle)
                    {
                        subtitleStream++;
                    }
                }
                if (!Directory.Exists(settings.targetFolder))
                {
                    logWindow.MessageDemux(Global.Res("ErrorTargetDirectory"));
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorTargetDirectory"));
                    }
                    return(false);
                }
                if (videoStream == 0)
                {
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorVideoFile"));
                    }
                    logWindow.MessageMux(Global.Res("ErrorVideoFile"));
                    return(false);
                }
                if (audioStream == 0)
                {
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorAudioFile"));
                    }
                    logWindow.MessageMux(Global.Res("ErrorAudioFile"));
                    return(false);
                }
                if (chapterStream > 0)
                {
                    bool error = false;
                    foreach (StreamInfo si in demuxedStreamList.streams)
                    {
                        if (si.streamType == StreamType.Chapter)
                        {
                            if (!File.Exists(si.filename))
                            {
                                error = true;
                            }
                        }
                    }
                    if (error)
                    {
                        if (!silent)
                        {
                            Global.ErrorMsg(Global.Res("ErrorChapterFile"));
                        }
                        logWindow.MessageMux(Global.Res("ErrorChapterFile"));
                        return(false);
                    }
                }
                if (subtitleStream > 0)
                {
                    bool error = false;
                    foreach (StreamInfo si in demuxedStreamList.streams)
                    {
                        if (si.streamType == StreamType.Subtitle)
                        {
                            if (si.extraFileInfo.GetType() == typeof(SubtitleFileInfo))
                            {
                                SubtitleFileInfo sfi = (SubtitleFileInfo)si.extraFileInfo;
                                if (sfi.forcedIdx != "")
                                {
                                    if (!File.Exists(sfi.forcedIdx))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.forcedSub != "")
                                {
                                    if (!File.Exists(sfi.forcedSub))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.forcedSup != "")
                                {
                                    if (!File.Exists(sfi.forcedSup))
                                    {
                                        error = true;
                                    }
                                }

                                if (sfi.normalIdx != "")
                                {
                                    if (!File.Exists(sfi.normalIdx))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.normalSub != "")
                                {
                                    if (!File.Exists(sfi.normalSub))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.normalSup != "")
                                {
                                    if (!File.Exists(sfi.normalSup))
                                    {
                                        error = true;
                                    }
                                }
                            }
                            else
                            {
                                error = false;
                            }
                        }
                    }
                    if (error)
                    {
                        if (!silent)
                        {
                            Global.ErrorMsg(Global.Res("ErrorSubtitleFile"));
                        }
                        logWindow.MessageMux(Global.Res("ErrorSubtitleFile"));
                        return(false);
                    }
                }

                progressBarMain.IsIndeterminate = false;
                progressBarMain.Maximum         = 100;
                progressBarMain.Minimum         = 0;
                maxProgressValue = 100;

                UpdateStatusBar(0);

                DisableControls();
                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarMux"));

                mt            = new MuxTool(settings, demuxedStreamList);
                mt.OnInfoMsg += new ExternalTool.InfoEventHandler(MuxMsg);
                mt.OnLogMsg  += new ExternalTool.LogEventHandler(MuxMsg);
                mt.Start();
                mt.WaitForExit();

                DoPlugin(PluginType.AfterMux);

                if (mt == null)
                {
                    return(false);
                }
                else
                {
                    return(mt.Successfull);
                }
            }
            catch (Exception ex)
            {
                logWindow.MessageMux(Global.Res("ErrorException") + " " + ex.Message);
                return(false);
            }
            finally
            {
                progressBarMain.IsIndeterminate = true;
                if (isWindows7)
                {
                    WPFExtensions.SetTaskbarProgressState(this, Windows7Taskbar.ThumbnailProgressState.NoProgress);
                }

                EnableControls();
                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarReady"));
            }
        }
コード例 #2
0
ファイル: Mux.cs プロジェクト: CommanderBubble/Blurip
        private bool DoMux()
        {
            try
            {
                DoPlugin(PluginType.BeforeMux);

                int videoStream = 0;
                int audioStream = 0;
                int chapterStream = 0;
                int subtitleStream = 0;

                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        if (si.extraFileInfo.GetType() == typeof(VideoFileInfo))
                        {
                            if (((VideoFileInfo)si.extraFileInfo).encodedFile != "")
                            {
                                if (File.Exists(((VideoFileInfo)si.extraFileInfo).encodedFile))
                                {
                                    videoStream++;
                                }
                            }
                            else if (File.Exists(settings.workingDir + "\\" + settings.filePrefix + "_video.mkv"))
                                {
                                    ((VideoFileInfo)si.extraFileInfo).encodedFile = settings.workingDir + "\\" + settings.filePrefix + "_video.mkv";
                                    videoStream++;
                                }
                        }
                    }
                    else if (si.streamType == StreamType.Audio)
                    {
                        if (File.Exists(si.filename))
                        {
                            audioStream++;
                        }
                    }
                    else if (si.streamType == StreamType.Chapter)
                    {
                        chapterStream++;
                    }
                    else if (si.streamType == StreamType.Subtitle)
                    {
                        subtitleStream++;
                    }
                }
                if (!Directory.Exists(settings.targetFolder))
                {
                    logWindow.MessageDemux(Global.Res("ErrorTargetDirectory"));
                    if (!silent) Global.ErrorMsg(Global.Res("ErrorTargetDirectory"));
                    return false;
                }
                if (videoStream == 0)
                {
                    if (!silent) Global.ErrorMsg(Global.Res("ErrorVideoFile"));
                    logWindow.MessageMux(Global.Res("ErrorVideoFile"));
                    return false;
                }
                if (audioStream == 0)
                {
                    if (!silent) Global.ErrorMsg(Global.Res("ErrorAudioFile"));
                    logWindow.MessageMux(Global.Res("ErrorAudioFile"));
                    return false;
                }
                if (chapterStream > 0)
                {
                    bool error = false;
                    foreach (StreamInfo si in demuxedStreamList.streams)
                    {
                        if (si.streamType == StreamType.Chapter)
                        {
                            if (!File.Exists(si.filename))
                            {
                                error = true;
                            }
                        }
                    }
                    if (error)
                    {
                        if (!silent) Global.ErrorMsg(Global.Res("ErrorChapterFile"));
                        logWindow.MessageMux(Global.Res("ErrorChapterFile"));
                        return false;
                    }
                }
                if (subtitleStream > 0)
                {
                    bool error = false;
                    foreach (StreamInfo si in demuxedStreamList.streams)
                    {
                        if (si.streamType == StreamType.Subtitle)
                        {
                            if (si.extraFileInfo.GetType() == typeof(SubtitleFileInfo))
                            {
                                SubtitleFileInfo sfi = (SubtitleFileInfo)si.extraFileInfo;
                                if (sfi.forcedIdx != "")
                                {
                                    if (!File.Exists(sfi.forcedIdx)) error = true;
                                }
                                if (sfi.forcedSub != "")
                                {
                                    if (!File.Exists(sfi.forcedSub)) error = true;
                                }
                                if (sfi.forcedSup != "")
                                {
                                    if (!File.Exists(sfi.forcedSup)) error = true;
                                }

                                if (sfi.normalIdx != "")
                                {
                                    if (!File.Exists(sfi.normalIdx)) error = true;
                                }
                                if (sfi.normalSub != "")
                                {
                                    if (!File.Exists(sfi.normalSub)) error = true;
                                }
                                if (sfi.normalSup != "")
                                {
                                    if (!File.Exists(sfi.normalSup)) error = true;
                                }
                            }
                            else
                            {
                                error = false;
                            }
                        }
                    }
                    if (error)
                    {
                        if (!silent) Global.ErrorMsg(Global.Res("ErrorSubtitleFile"));
                        logWindow.MessageMux(Global.Res("ErrorSubtitleFile"));
                        return false;
                    }
                }

                progressBarMain.IsIndeterminate = false;
                progressBarMain.Maximum = 100;
                progressBarMain.Minimum = 0;
                maxProgressValue = 100;

                UpdateStatusBar(0);

                DisableControls();
                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarMux"));

                mt = new MuxTool(settings, demuxedStreamList);
                mt.OnInfoMsg += new ExternalTool.InfoEventHandler(MuxMsg);
                mt.OnLogMsg += new ExternalTool.LogEventHandler(MuxMsg);
                mt.Start();
                mt.WaitForExit();

                DoPlugin(PluginType.AfterMux);

                if (mt == null) return false;
                else return mt.Successfull;
            }
            catch (Exception ex)
            {
                logWindow.MessageMux(Global.Res("ErrorException") + " " + ex.Message);
                return false;
            }
            finally
            {
                progressBarMain.IsIndeterminate = true;
                if (isWindows7)
                {
                    WPFExtensions.SetTaskbarProgressState(this, Windows7Taskbar.ThumbnailProgressState.NoProgress);
                }

                EnableControls();
                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarReady"));
            }
        }