Esempio n. 1
0
        /// <summary>
        /// default constructor
        /// initializes all the GUI components, initializes the internal objects and makes a default selection for all the GUI dropdowns
        /// In addition, all the jobs and profiles are being loaded from the harddisk
        /// </summary>
        public MeGUIInfo()
        {
            this.codecs               = new CodecManager();
            this.gen                  = new CommandLineGenerator();
            this.path                 = System.Windows.Forms.Application.StartupPath;
            this.jobs                 = new Dictionary <string, Job>();
            this.skipJobs             = new List <Job>();
            this.logBuilder           = new StringBuilder();
            this.jobUtil              = new JobUtil(this);
            this.settings             = new MeGUISettings();
            this.calc                 = new BitrateCalculator();
            audioStreams              = new AudioStream[2];
            audioStreams[0].path      = "";
            audioStreams[0].output    = "";
            audioStreams[0].settings  = null;
            audioStreams[1].path      = "";
            audioStreams[1].output    = "";
            audioStreams[1].settings  = null;
            this.videoEncoderProvider = new VideoEncoderProvider();
            this.audioEncoderProvider = new AudioEncoderProvider();
            this.profileManager       = new ProfileManager(this.path);
            this.profileManager.LoadProfiles(videoProfile, audioProfile);
            this.loadSettings();
            this.loadJobs();
            this.dialogManager = new DialogManager(this);
#warning refactor menus
            int index = menuItem1.MenuItems.Count;
            foreach (IMuxing muxer in PackageSystem.MuxerProviders.Values)
            {
                MenuItem newMenuItem = new MenuItem();
                newMenuItem.Text  = muxer.Name;
                newMenuItem.Tag   = muxer;
                newMenuItem.Index = index;
                index++;
                menuItem1.MenuItems.Add(newMenuItem);
                newMenuItem.Click += new System.EventHandler(this.mnuMuxer_Click);
            }
            index = mnuTools.MenuItems.Count;
            foreach (ITool tool in PackageSystem.Tools.Values)
            {
                MenuItem newMenuItem = new MenuItem();
                newMenuItem.Text  = tool.Name;
                newMenuItem.Tag   = tool;
                newMenuItem.Index = index;
                index++;
                mnuTools.MenuItems.Add(newMenuItem);
                newMenuItem.Click += new System.EventHandler(this.mnuTool_Click);
            }
            //MessageBox.Show(String.Join("|", this.GetType().Assembly.GetManifestResourceNames()));
            using (TextReader r = new StreamReader(this.GetType().Assembly.GetManifestResourceStream("MeGUI.Changelog.txt")))
            {
                mainForm.Changelog.Text = r.ReadToEnd();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// postprocesses an audio job followed by a video job
        /// this constellation happens in automated or one click encoding where we have an audio job linked
        /// to a video job
        /// first, any audio jobs previous to the audio job in question will be located
        /// then we get the size of all audio tracks
        /// from the desired final output size stored in the first video job, we calculate the video bitrate
        /// we have to use to obtain the final file size, taking container overhead into account
        /// the calculated bitrate is then applied to all video jobs
        /// </summary>
        /// <param name="firstAudio">the audio job that is linked to a video job</param>
        /// <param name="firstpass">the video job to which the audio job is linked</param>
        public static LogItem calculateBitrate(MainForm mainForm, Job ajob)
        {
            if (!(ajob is VideoJob))
            {
                return(null);
            }
            VideoJob job = (VideoJob)ajob;

            if (job.BitrateCalculationInfo == null)
            {
                return(null);
            }

            BitrateCalculationInfo b = job.BitrateCalculationInfo;
            LogItem log = new LogItem("Bitrate calculation for video");

            List <AudioBitrateCalculationStream> audioStreams = new List <AudioBitrateCalculationStream>();

            foreach (string s in b.AudioFiles)
            {
                audioStreams.Add(new AudioBitrateCalculationStream(s));
            }

            double framerate;
            ulong  framecount;

            JobUtil.getInputProperties(out framecount, out framerate, job.Input);

            int   bitrateKBits;
            ulong videoSizeKB = 0;

            try
            {
                bitrateKBits = BitrateCalculator.CalculateBitrateKBits(job.Settings.Codec, job.Settings.NbBframes > 0, b.Container,
                                                                       audioStreams.ToArray(), b.DesiredSize.Bytes, framecount, framerate, out videoSizeKB);
            }
            catch (CalculationException e)
            {
                log.LogValue("Calculation failed", e, ImageType.Error);
                return(log);
            }

            log.LogValue("Desired size after subtracting audio", videoSizeKB + "KBs");
            log.LogValue("Calculated desired bitrate", bitrateKBits + "kbit/s");

            foreach (TaggedJob t in b.VideoJobs)
            {
                ((VideoJob)t.Job).Settings.BitrateQuantizer = bitrateKBits;
            }

            return(log);
        }
Esempio n. 3
0
        /// <summary>
        /// postprocesses an audio job followed by a video job
        /// this constellation happens in automated or one click encoding where we have an audio job linked
        /// to a video job
        /// first, any audio jobs previous to the audio job in question will be located
        /// then we get the size of all audio tracks
        /// from the desired final output size stored in the first video job, we calculate the video bitrate
        /// we have to use to obtain the final file size, taking container overhead into account
        /// the calculated bitrate is then applied to all video jobs
        /// </summary>
        /// <param name="firstAudio">the audio job that is linked to a video job</param>
        /// <param name="firstpass">the video job to which the audio job is linked</param>
        public static void calculateBitrate(MainForm mainForm, Job ajob)
        {
            if (!(ajob is VideoJob))
            {
                return;
            }
            VideoJob job = (VideoJob)ajob;

            if (job.BitrateCalculationInfo == null)
            {
                return;
            }

            BitrateCalculationInfo b = job.BitrateCalculationInfo;

            mainForm.addToLog("Doing bitrate calculation...");

            List <AudioBitrateCalculationStream> audioStreams = new List <AudioBitrateCalculationStream>();

            foreach (string s in b.AudioFiles)
            {
                audioStreams.Add(new AudioBitrateCalculationStream(s));
            }

            double framerate;
            ulong  framecount;

            JobUtil.getInputProperties(out framecount, out framerate, job.Input);

            int   bitrateKBits;
            ulong videoSizeKB = 0;

            try
            {
                bitrateKBits = BitrateCalculator.CalculateBitrateKBits(job.Settings.Codec, job.Settings.NbBframes > 0, b.Container,
                                                                       audioStreams.ToArray(), b.DesiredSize.Bytes, framecount, framerate, out videoSizeKB);
            }
            catch (CalculationException e)
            {
                mainForm.addToLog("Calculation failed with message '{0}'", e);
                return;
            }

            mainForm.addToLog("Desired video size after subtracting audio size is {0}KBs. Setting the desired bitrate of the subsequent video jobs to {1} kbit/s.",
                              videoSizeKB, bitrateKBits);

            foreach (TaggedJob t in b.VideoJobs)
            {
                ((VideoJob)t.Job).Settings.BitrateQuantizer = bitrateKBits;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// default constructor
        /// initializes all the GUI components, initializes the internal objects and makes a default selection for all the GUI dropdowns
        /// In addition, all the jobs and profiles are being loaded from the harddisk
        /// </summary>
        public MeGUIInfo()
        {
            this.codecs = new CodecManager();
            this.gen = new CommandLineGenerator();
            this.path = System.Windows.Forms.Application.StartupPath;
            this.jobs = new Dictionary<string, Job>();
            this.skipJobs = new List<Job>();
            this.logBuilder = new StringBuilder();
            this.jobUtil = new JobUtil(this);
            this.settings = new MeGUISettings();
            this.calc = new BitrateCalculator();
            audioStreams = new AudioStream[2];
            audioStreams[0].path = "";
            audioStreams[0].output = "";
            audioStreams[0].settings = null;
            audioStreams[1].path = "";
            audioStreams[1].output = "";
            audioStreams[1].settings = null;
            this.videoEncoderProvider = new VideoEncoderProvider();
            this.audioEncoderProvider = new AudioEncoderProvider();
            this.profileManager = new ProfileManager(this.path);
            this.profileManager.LoadProfiles(videoProfile, audioProfile);
            this.loadSettings();
            this.loadJobs();
            this.dialogManager = new DialogManager(this);

            int index = menuItem1.MenuItems.Count;
            foreach (IMuxing muxer in PackageSystem.MuxerProviders.Values)
            {
                MenuItem newMenuItem = new MenuItem();
                newMenuItem.Text = muxer.Name;
                newMenuItem.Tag = muxer;
                newMenuItem.Index = index;
                index++;
                menuItem1.MenuItems.Add(newMenuItem);
                newMenuItem.Click += new System.EventHandler(this.mnuMuxer_Click);
            }
            index = mnuTools.MenuItems.Count;
            foreach (ITool tool in PackageSystem.Tools.Values)
            {
                MenuItem newMenuItem = new MenuItem();
                newMenuItem.Text = tool.Name;
                newMenuItem.Tag = tool;
                newMenuItem.Index = index;
                index++;
                mnuTools.MenuItems.Add(newMenuItem);
                newMenuItem.Click += new System.EventHandler(this.mnuTool_Click);
            }
            //MessageBox.Show(String.Join("|", this.GetType().Assembly.GetManifestResourceNames()));
            using (TextReader r = new StreamReader(this.GetType().Assembly.GetManifestResourceStream("MeGUI.Changelog.txt")))
            {
                mainForm.Changelog.Text = r.ReadToEnd();
            }
        }