Beispiel #1
0
 /// <summary>
 /// sets the size of the output given the desired bitrate
 /// </summary>
 private void setTargetSize()
 {
     try
     {
         CalcData data = GetCalcData();
         data.VideoBitrate = Int32.Parse(this.projectedBitrateKBits.Text);
         data.CalcByVideoSize();
         this.videoSize.Text   = data.VideoSize.ToString();
         this.targetSize.Value = new FileSize(Unit.MB, data.TotalSize.MBExact);
     }
     catch (Exception)
     {
         videoSize.Text   = "";
         targetSize.Value = null;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Calculates by the selected method
        /// </summary>
        protected void Calculate()
        {
            if (calculating)
            {
                return;
            }
            calculating = true;
            try
            {
                CalcData data = new CalcData((long)nbFrames.Value, fpsChooser.Value ?? 0);
                data.FrameSize        = new Size((int)width.Value, (int)height.Value);
                data.ExtraSize        = GetTotalExtraSize();
                data.AudioStreams     = GetAudioStreams().ToArray();
                data.ContainerType    = containerFormat.SelectedItem as ContainerType;
                data.HasBFrames       = bframes.Checked;
                data.VideoCodec       = SelectedVCodec.VCodec;
                data.QualityCoeffient = (float)complexity.Value / 100F;

                if (fileSizeRadio.Checked) // get video, bpp, qest
                {
                    data.TotalSize = new FileSize(targetSize.Value.Value.Bytes);
                    data.CalcByTotalSize();
                }
                else if (this.bppRadio.Checked) // get video, quest, total
                {
                    data.BitsPerPixel = (float)bpp.Value;
                    data.CalcByBitsPerPixel();
                }
                else if (this.qEstRadio.Checked) // get video, bpp, total
                {
                    data.QualityEstimate = (float)qest.Value;
                    data.CalcByQualityEstimate();
                }
                else // given video size, get total, bpp, quest
                {
                    data.VideoBitrate = projectedBitrate.Value;
                    data.CalcByVideoSize();
                }

                targetSize.Value       = new FileSize(Unit.KB, data.TotalSize.KB);
                projectedBitrate.Value = data.VideoBitrate;
                videoSize.Text         = new FileSize(Unit.KB, data.VideoSize.KB).ToString();
                bpp.Value           = (decimal)data.BitsPerPixel;
                qest.Value          = (decimal)data.QualityEstimate;
                applyButton.Enabled = true;
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                applyButton.Enabled = false;
                videoSize.Text      = "";
                if (fileSizeRadio.Checked)
                {
                    bpp.Value              = 0;
                    qest.Value             = 0;
                    projectedBitrate.Value = 0;
                }
                else if (this.bppRadio.Checked)
                {
                    qest.Value             = 0;
                    projectedBitrate.Value = 0;
                    targetSize.Value       = null;
                }
                else if (this.qEstRadio.Checked)
                {
                    bpp.Value = 0;
                    projectedBitrate.Value = 0;
                    targetSize.Value       = null;
                }
                else
                {
                    bpp.Value        = 0;
                    qest.Value       = 0;
                    targetSize.Value = null;
                }
            }
            calculating = false;
        }