コード例 #1
0
        /// <summary>
        ///  Handles assessment of whether the encoding options vary between two xvidSettings instances
        /// The following are excluded from the comparison:
        /// BitrateQuantizer
        /// CreditsQuantizer
        /// Logfile
        /// PAR
        /// PARs
        /// SARX
        /// SARY
        /// Zones
        /// </summary>
        /// <param name="otherSettings"></param>
        /// <returns>true if the settings differ</returns>
        public bool IsAltered(VideoCodecSettings settings)
        {
            if (!(settings is xvidSettings))
            {
                return(true);
            }
            xvidSettings otherSettings = (xvidSettings)settings;

            if (
                this.AveragingPeriod != otherSettings.AveragingPeriod ||
                this.BframeThreshold != otherSettings.BframeThreshold ||
                this.BQuantOffset != otherSettings.BQuantOffset ||
                this.BQuantRatio != otherSettings.BQuantRatio ||
                this.ChromaMotion != otherSettings.ChromaMotion ||
                this.ClosedGOP != otherSettings.ClosedGOP ||
                this.CustomEncoderOptions != otherSettings.CustomEncoderOptions ||
                this.EncodingMode != otherSettings.EncodingMode ||
                this.FrameDropRatio != otherSettings.FrameDropRatio ||
                this.GMC != otherSettings.GMC ||
                this.HighBitrateDegradation != otherSettings.HighBitrateDegradation ||
                this.Interlaced != otherSettings.Interlaced ||
                this.KeyFrameBoost != otherSettings.KeyFrameBoost ||
                this.KeyframeInterval != otherSettings.KeyframeInterval ||
                this.KeyframeReduction != otherSettings.KeyframeReduction ||
                this.KeyframeThreshold != otherSettings.KeyframeThreshold ||
                this.LowBitrateImprovement != otherSettings.LowBitrateImprovement ||
                this.MaxBQuant != otherSettings.MaxBQuant ||
                this.MaxOverflowDegradation != otherSettings.MaxOverflowDegradation ||
                this.MaxOverflowImprovement != otherSettings.MaxOverflowImprovement ||
                this.MaxPQuant != otherSettings.MaxPQuant ||
                this.MaxQuantizer != otherSettings.MaxQuantizer ||
                this.MinBQuant != otherSettings.MinBQuant ||
                this.MinPQuant != otherSettings.MinPQuant ||
                this.MinQuantizer != otherSettings.MinQuantizer ||
                this.MotionSearchPrecision != otherSettings.MotionSearchPrecision ||
                this.NbBframes != otherSettings.NbBframes ||
                this.OverflowControlStrength != otherSettings.OverflowControlStrength ||
                this.PackedBitstream != otherSettings.PackedBitstream ||
                this.QPel != otherSettings.QPel ||
                this.RateControlBuffer != otherSettings.RateControlBuffer ||
                this.ReactionDelayFactor != otherSettings.ReactionDelayFactor ||
                this.Trellis != otherSettings.Trellis ||
                this.Turbo != otherSettings.Turbo ||
                this.V4MV != otherSettings.V4MV ||
                this.VHQForBframes != otherSettings.VHQForBframes ||
                this.XvidProfile != otherSettings.XvidProfile ||
                this.VbvBuffer != otherSettings.VbvBuffer ||
                this.VbvMaxRate != otherSettings.VbvMaxRate ||
                this.VbvPeakRate != otherSettings.VbvPeakRate ||
                this.VHQMode != otherSettings.VHQMode ||
                this.HVSMasking != otherSettings.HVSMasking
                )
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: ProfileManager.cs プロジェクト: paulyc/megui
 public static void FixFileNames(Profile profile, Dictionary <string, string> substitutionTable)
 {
     if (profile is GenericProfile <VideoCodecSettings> )
     {
         GenericProfile <VideoCodecSettings> vProf = profile as GenericProfile <VideoCodecSettings>;
         if (vProf.Settings is x264Settings)
         {
             x264Settings xSettings = vProf.Settings as x264Settings;
             if (xSettings.QuantizerMatrixType == 2) // CQM
             {
                 if (substitutionTable.ContainsKey(xSettings.QuantizerMatrix))
                 {
                     xSettings.QuantizerMatrix = substitutionTable[xSettings.QuantizerMatrix];
                 }
             }
         }
         if (vProf.Settings is xvidSettings)
         {
             xvidSettings xSettings = vProf.Settings as xvidSettings;
             if (xSettings.QuantType == 2) // CQM
             {
                 if (substitutionTable.ContainsKey(xSettings.CustomQuantizerMatrix))
                 {
                     xSettings.CustomQuantizerMatrix = substitutionTable[xSettings.CustomQuantizerMatrix];
                 }
             }
         }
     }
 }
コード例 #3
0
        public static string genCommandline(string input, string output, Dar?d, xvidSettings xs, int hres, int vres)
        {
            StringBuilder sb = new StringBuilder();
            CultureInfo   ci = new CultureInfo("en-us");

            sb.Append("-i \"" + input + "\" ");
            switch (xs.EncodingMode)
            {
            case 0:                                                         // CBR
                sb.Append("-single -bitrate " + xs.BitrateQuantizer + " "); // add bitrate
                break;

            case 1:                                             // CQ
                sb.Append("-single -cq " + xs.Quantizer + " "); // add quantizer
                break;

            case 2:                                                                                    // 2 pass first pass
                sb.Append("-pass1 " + "\"" + xs.Logfile + "\" -bitrate " + xs.BitrateQuantizer + " "); // add logfile
                break;

            case 3:                                                                                    // 2 pass second pass
            case 4:                                                                                    // automated twopass
                sb.Append("-pass2 " + "\"" + xs.Logfile + "\" -bitrate " + xs.BitrateQuantizer + " "); // add logfile
                break;
            }
            if (xs.EncodingMode <= 1) // 1 pass modes
            {
                if (xs.ReactionDelayFactor != 16)
                {
                    sb.Append("-reaction " + xs.ReactionDelayFactor + " ");
                }
                if (xs.AveragingPeriod != 100)
                {
                    sb.Append("-averaging " + xs.AveragingPeriod + " ");
                }
                if (xs.RateControlBuffer != 100)
                {
                    sb.Append("-smoother " + xs.RateControlBuffer + " ");
                }
            }
            else // two pass modes
            {
                if (xs.KeyFrameBoost != 10)
                {
                    sb.Append("-kboost " + xs.KeyFrameBoost + " ");
                }
                if (xs.KeyframeThreshold != 1)
                {
                    sb.Append("-kthresh " + xs.KeyframeThreshold + " ");
                }
                if (xs.KeyframeReduction != 20)
                {
                    sb.Append("-kreduction " + xs.KeyframeReduction + " ");
                }
                if (xs.OverflowControlStrength != 5)
                {
                    sb.Append("-ostrength " + xs.OverflowControlStrength + " ");
                }
                if (xs.MaxOverflowImprovement != 5)
                {
                    sb.Append("-oimprove " + xs.MaxOverflowImprovement + " ");
                }
                if (xs.MaxOverflowDegradation != 5)
                {
                    sb.Append("-odegrade " + xs.MaxOverflowDegradation + " ");
                }
                if (xs.HighBitrateDegradation != 0)
                {
                    sb.Append("-chigh " + xs.HighBitrateDegradation + " ");
                }
                if (xs.LowBitrateImprovement != 0)
                {
                    sb.Append("-clow " + xs.LowBitrateImprovement + " ");
                }
                sb.Append("-overhead 0 ");
                if (xs.VbvBuffer != 0)
                {
                    sb.Append("-vbvsize " + xs.VbvBuffer + " ");
                }
                if (xs.VbvMaxRate != 0)
                {
                    sb.Append("-vbvmax " + xs.VbvMaxRate + " ");
                }
                if (xs.VbvPeakRate != 0)
                {
                    sb.Append("-vbvpeak " + xs.VbvPeakRate + " ");
                }
            }
            if (xs.Turbo)
            {
                sb.Append("-turbo ");
            }
            if (xs.KeyframeInterval != 300)
            {
                sb.Append("-max_key_interval " + xs.KeyframeInterval + " ");
            }
            if (!xs.PackedBitstream) // default is on in encraw
            {
                sb.Append("-nopacked ");
            }
            if (xs.MotionSearchPrecision != 6)
            {
                sb.Append("-quality " + xs.MotionSearchPrecision + " ");
            }
            if (xs.VHQMode != 1)
            {
                sb.Append("-vhqmode " + xs.VHQMode + " ");
            }
            if (xs.QPel)
            {
                sb.Append("-qpel ");
            }
            if (xs.GMC)
            {
                sb.Append("-gmc ");
            }
            if (xs.QuantizerMatrix == xvidSettings.MPEGMatrix)
            {
                sb.Append("-qtype 1 ");
            }
            else if (xs.QuantizerMatrix != xvidSettings.H263Matrix && !string.IsNullOrEmpty(xs.QuantizerMatrix))
            {
                sb.Append("-qmatrix \"" + xs.QuantizerMatrix + "\" ");
            }
            if (xs.ClosedGOP)
            {
                sb.Append("-closed_gop ");
            }
            if (xs.AdaptiveQuant)
            {
                sb.Append("-lumimasking ");
            }
            if (xs.Interlaced)
            {
                sb.Append("-interlaced ");
                if (xs.BottomFieldFirst)
                {
                    sb.Append("1 ");
                }
                else
                {
                    sb.Append("2 ");
                }
            }
            if (xs.Greyscale)
            {
                sb.Append("-grey ");
            }
            if (xs.LumiMasking)
            {
                sb.Append("-lumimasking ");
            }
            if (!xs.Trellis)
            {
                sb.Append("-notrellis ");
            }
            if (!xs.ChromaMotion)
            {
                sb.Append("-nochromame ");
            }
            if (xs.MinQuantizer != 2)
            {
                sb.Append("-imin " + xs.MinQuantizer + " ");
            }
            if (xs.MaxQuantizer != 31)
            {
                sb.Append("-imax " + xs.MaxQuantizer + " ");
            }
            if (xs.MinPQuant != 2)
            {
                sb.Append("-pmin " + xs.MinPQuant + " ");
            }
            if (xs.MaxPQuant != 31)
            {
                sb.Append("-pmax " + xs.MaxPQuant + " ");
            }
            if (!xs.ClosedGOP)
            {
                sb.Append("-noclosed_gop ");
            }
            if (xs.FrameDropRatio != 0)
            {
                sb.Append("-drop " + xs.FrameDropRatio + " ");
            }

            if (xs.NbBframes != 2)
            {
                sb.Append("-max_bframes " + xs.NbBframes + " ");
            }
            if (xs.NbBframes > 0)
            {
                if (xs.VHQForBframes)
                {
                    sb.Append("-bvhq ");
                }
                if (xs.BQuantRatio != 150)
                {
                    sb.Append("-bquant_ratio " + xs.BQuantRatio + " ");
                }
                if (xs.BQuantOffset != 100)
                {
                    sb.Append("-bquant_offset " + xs.BQuantOffset + " ");
                }
                if (xs.MinBQuant != 2)
                {
                    sb.Append("-bmin " + xs.MinBQuant + " ");
                }
                if (xs.MaxBQuant != 31)
                {
                    sb.Append("-bmax " + xs.MaxBQuant + " ");
                }
            }
            if (d.HasValue) // custom PAR mode
            {
                Sar s = d.Value.ToSar(hres, vres);
                sb.Append("-par " + s.X + ":" + s.Y + " ");
            }
            sb.Append("-threads " + xs.NbThreads + " ");
            if (xs.Zones != null && xs.Zones.Length > 0 && xs.CreditsQuantizer >= new decimal(1) &&
                xs.EncodingMode != 1)    // only for non CQ mode at the moment
            {
                foreach (Zone zone in xs.Zones)
                {
                    if (zone.mode == ZONEMODE.QUANTIZER)
                    {
                        sb.Append("-zq " + zone.startFrame + " " + zone.modifier + " ");
                    }
                    if (zone.mode == ZONEMODE.WEIGHT)
                    {
                        sb.Append("-zw " + zone.startFrame + " ");
                        double mod = (double)zone.modifier / 100.0;
                        sb.Append(mod.ToString(ci) + " ");
                    }
                }
            }
            if (xs.EncodingMode != 2) // not 2 pass vbr first pass, add output filename and output type
            {
                string extension = Path.GetExtension(output).ToLower();
                if (extension.Equals(".mkv"))
                {
                    sb.Append(" -mkv \"" + output + "\"");
                }
                else if (extension.Equals(".avi"))
                {
                    sb.Append(" -avi \"" + output + "\"");
                }
                else
                {
                    sb.Append(" -o \"" + output + "\"");
                }
            }
            if (!xs.CustomEncoderOptions.Equals("")) // add custom encoder options
            {
                sb.Append(" " + xs.CustomEncoderOptions);
            }
            return(sb.ToString());
        }
コード例 #4
0
        public static string genCommandline(string input, string output, Dar?d, xvidSettings xs, int hres, int vres, int fps_n, int fps_d, Zone[] zones, LogItem log)
        {
            StringBuilder sb = new StringBuilder();
            CultureInfo   ci = new CultureInfo("en-us");

            // log
            if (log != null)
            {
                if (!String.IsNullOrEmpty(xs.CustomEncoderOptions))
                {
                    log.LogEvent("custom command line: " + xs.CustomEncoderOptions);
                }
            }

            #region input options
            if (log != null)
            {
                sb.Append("-i \"" + input + "\" ");
            }
            #endregion

            #region output options
            if (log != null)
            {
                if (xs.VideoEncodingType != VideoCodecSettings.VideoEncodingMode.twopass1) // not 2 pass vbr first pass, add output filename and output type
                {
                    sb.Append("-o \"" + output + "\" ");
                }
            }
            #endregion

            #region rate control options
            switch (xs.VideoEncodingType)
            {
            case VideoCodecSettings.VideoEncodingMode.twopass1:     // 2 pass first pass
                sb.Append("-pass1 " + "\"" + xs.Logfile + "\" ");   // add logfile
                break;

            case VideoCodecSettings.VideoEncodingMode.twopass2:         // 2 pass second pass
            case VideoCodecSettings.VideoEncodingMode.twopassAutomated: // automated twopass
                sb.Append("-pass2 " + "\"" + xs.Logfile + "\" ");       // add logfile
                break;
            }
            if (!xs.CustomEncoderOptions.Contains("-bitrate ") && !xs.CustomEncoderOptions.Contains("-cq "))
            {
                if (xs.VideoEncodingType == VideoCodecSettings.VideoEncodingMode.CQ)
                {
                    sb.Append("-cq " + xs.Quantizer.ToString(ci) + " "); // add quantizer
                }
                else if (xs.BitrateQuantizer != 700)
                {
                    sb.Append("-bitrate " + xs.BitrateQuantizer + " "); // add bitrate
                }
            }
            if (!xs.CustomEncoderOptions.Contains("-max_key_interval ") && xs.KeyframeInterval != 300)
            {
                sb.Append("-max_key_interval " + xs.KeyframeInterval + " ");
            }
            if (zones != null && zones.Length > 0 && xs.CreditsQuantizer >= new decimal(1))
            {
                foreach (Zone zone in zones)
                {
                    if (zone.mode == ZONEMODE.Quantizer)
                    {
                        sb.Append("-zq " + zone.startFrame + " " + zone.modifier + " ");
                    }
                    if (zone.mode == ZONEMODE.Weight)
                    {
                        sb.Append("-zw " + zone.startFrame + " ");
                        double mod = (double)zone.modifier / 100.0;
                        sb.Append(mod.ToString(ci) + " ");
                    }
                }
            }
            #endregion

            #region single pass options
            if (xs.VideoEncodingType == VideoCodecSettings.VideoEncodingMode.CQ || xs.VideoEncodingType == VideoCodecSettings.VideoEncodingMode.CBR)
            {
                if (!xs.CustomEncoderOptions.Contains("-reaction ") && xs.ReactionDelayFactor != 16)
                {
                    sb.Append("-reaction " + xs.ReactionDelayFactor + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-averaging ") && xs.AveragingPeriod != 100)
                {
                    sb.Append("-averaging " + xs.AveragingPeriod + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-smoother ") && xs.RateControlBuffer != 100)
                {
                    sb.Append("-smoother " + xs.RateControlBuffer + " ");
                }
            }
            #endregion

            #region second pass options
            if (xs.VideoEncodingType != VideoCodecSettings.VideoEncodingMode.CQ && xs.VideoEncodingType != VideoCodecSettings.VideoEncodingMode.CBR)
            {
                if (!xs.CustomEncoderOptions.Contains("-kboost ") && xs.KeyFrameBoost != 10)
                {
                    sb.Append("-kboost " + xs.KeyFrameBoost + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-kthresh ") && xs.KeyframeThreshold != 1)
                {
                    sb.Append("-kthresh " + xs.KeyframeThreshold + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-kreduction ") && xs.KeyframeReduction != 20)
                {
                    sb.Append("-kreduction " + xs.KeyframeReduction + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-ostrength ") && xs.OverflowControlStrength != 5)
                {
                    sb.Append("-ostrength " + xs.OverflowControlStrength + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-oimprove ") && xs.MaxOverflowImprovement != 5)
                {
                    sb.Append("-oimprove " + xs.MaxOverflowImprovement + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-odegrade ") && xs.MaxOverflowDegradation != 5)
                {
                    sb.Append("-odegrade " + xs.MaxOverflowDegradation + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-chigh ") && xs.HighBitrateDegradation != 0)
                {
                    sb.Append("-chigh " + xs.HighBitrateDegradation + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-clow ") && xs.LowBitrateImprovement != 0)
                {
                    sb.Append("-clow " + xs.LowBitrateImprovement + " ");
                }
                // -overhead missing
                if (xs.XvidProfile != 0)
                {
                    int ivbvmax = 0, ivbvsize = 0, ivbvpeak = 0;
                    switch (xs.XvidProfile)
                    {
                    case 1:
                        ivbvmax  = 4854000;
                        ivbvsize = 3145728;
                        ivbvpeak = 2359296;
                        break;

                    case 2:
                        ivbvmax  = 9708400;
                        ivbvsize = 6291456;
                        ivbvpeak = 4718592;
                        break;

                    case 3:
                        ivbvmax  = 20000000;
                        ivbvsize = 16000000;
                        ivbvpeak = 12000000;
                        break;

                    case 4:
                        ivbvmax  = 200000;
                        ivbvsize = 262144;
                        ivbvpeak = 196608;
                        break;

                    case 5:
                        ivbvmax  = 600000;
                        ivbvsize = 655360;
                        ivbvpeak = 491520;
                        break;

                    case 6:
                        ivbvmax  = xs.VbvMaxRate;
                        ivbvsize = xs.VbvBuffer;
                        ivbvpeak = xs.VbvPeakRate;
                        break;
                    }
                    if (!xs.CustomEncoderOptions.Contains("-vbvsize ") && ivbvsize != 0)
                    {
                        sb.Append("-vbvsize " + ivbvsize + " ");
                    }
                    if (!xs.CustomEncoderOptions.Contains("-vbvmax ") && ivbvmax != 0)
                    {
                        sb.Append("-vbvmax " + ivbvmax + " ");
                    }
                    if (!xs.CustomEncoderOptions.Contains("-vbvpeak ") && ivbvpeak != 0)
                    {
                        sb.Append("-vbvpeak " + ivbvpeak + " ");
                    }
                }
            }
            #endregion

            #region bframes options
            if (!xs.CustomEncoderOptions.Contains("-max_bframes ") && xs.NbBframes != 2)
            {
                sb.Append("-max_bframes " + xs.NbBframes + " ");
            }
            if (xs.NbBframes > 0)
            {
                if (!xs.CustomEncoderOptions.Contains("-bquant_ratio ") && xs.BQuantRatio != 150)
                {
                    sb.Append("-bquant_ratio " + xs.BQuantRatio + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-bquant_offset ") && xs.BQuantOffset != 100)
                {
                    sb.Append("-bquant_offset " + xs.BQuantOffset + " ");
                }
            }
            #endregion

            #region other options
            // -noasm missing
            if (!xs.CustomEncoderOptions.Contains("-turbo") && xs.Turbo)
            {
                sb.Append("-turbo ");
            }
            if (!xs.CustomEncoderOptions.Contains("-quality ") && xs.MotionSearchPrecision != 6)
            {
                sb.Append("-quality " + xs.MotionSearchPrecision + " ");
            }
            if (!xs.CustomEncoderOptions.Contains("-vhqmode ") && xs.VHQMode != 1)
            {
                sb.Append("-vhqmode " + xs.VHQMode + " ");
            }
            if (xs.NbBframes > 0 && !xs.CustomEncoderOptions.Contains("-bvhq ") && xs.VHQForBframes)
            {
                sb.Append("-bvhq ");
            }
            // -metric missing
            if (!xs.CustomEncoderOptions.Contains("-qpel ") && xs.QPel)
            {
                sb.Append("-qpel ");
            }
            if (!xs.CustomEncoderOptions.Contains("-gmc ") && xs.GMC)
            {
                sb.Append("-gmc ");
            }
            if (!xs.CustomEncoderOptions.Contains("-qtype ") && xs.QuantizerMatrix == xvidSettings.MPEGMatrix)
            {
                sb.Append("-qtype 1 ");
            }
            else if (!xs.CustomEncoderOptions.Contains("-qmatrix ") && xs.QuantizerMatrix != xvidSettings.H263Matrix && !string.IsNullOrEmpty(xs.QuantizerMatrix))
            {
                sb.Append("-qmatrix \"" + xs.QuantizerMatrix + "\" ");
            }
            if (!xs.CustomEncoderOptions.Contains("-interlaced ") && xs.Interlaced)
            {
                sb.Append("-interlaced ");
                if (xs.BottomFieldFirst)
                {
                    sb.Append("1 ");
                }
                else
                {
                    sb.Append("2 ");
                }
            }
            if (!xs.CustomEncoderOptions.Contains("-nopacked") && !xs.PackedBitstream)
            {
                sb.Append("-nopacked ");
            }
            if (!xs.CustomEncoderOptions.Contains("-noclosed_gop") && !xs.ClosedGOP)
            {
                sb.Append("-noclosed_gop ");
            }
            if (!xs.CustomEncoderOptions.Contains("-masking ") && xs.HVSMasking != 0)
            {
                sb.Append("-masking " + xs.HVSMasking + " ");
            }
            // -stats missing
            // -ssim missing
            // -ssim_file missing
            // -debug missing
            // -vop_debug missing
            if (!xs.CustomEncoderOptions.Contains("-nochromame") && !xs.ChromaMotion)
            {
                sb.Append("-nochromame ");
            }
            if (!xs.CustomEncoderOptions.Contains("-notrellis") && !xs.Trellis)
            {
                sb.Append("-notrellis ");
            }
            if (!xs.CustomEncoderOptions.Contains("-imin ") && xs.MinQuantizer != 2)
            {
                sb.Append("-imin " + xs.MinQuantizer + " ");
            }
            if (!xs.CustomEncoderOptions.Contains("-imax ") && xs.MaxQuantizer != 31)
            {
                sb.Append("-imax " + xs.MaxQuantizer + " ");
            }
            if (xs.NbBframes > 0)
            {
                if (!xs.CustomEncoderOptions.Contains("-bmin ") && xs.MinBQuant != 2)
                {
                    sb.Append("-bmin " + xs.MinBQuant + " ");
                }
                if (!xs.CustomEncoderOptions.Contains("-bmax ") && xs.MaxBQuant != 31)
                {
                    sb.Append("-bmax " + xs.MaxBQuant + " ");
                }
            }
            if (!xs.CustomEncoderOptions.Contains("-pmin ") && xs.MinPQuant != 2)
            {
                sb.Append("-pmin " + xs.MinPQuant + " ");
            }
            if (!xs.CustomEncoderOptions.Contains("-pmax ") && xs.MaxPQuant != 31)
            {
                sb.Append("-pmax " + xs.MaxPQuant + " ");
            }
            if (!xs.CustomEncoderOptions.Contains("-drop ") && xs.FrameDropRatio != 0)
            {
                sb.Append("-drop " + xs.FrameDropRatio + " ");
            }
            // -start missing
            if (!xs.CustomEncoderOptions.Contains("-threads ") && xs.NbThreads > 0)
            {
                sb.Append("-threads " + xs.NbThreads + " ");
            }
            // -slices missing
            // -progress missing
            if (!xs.CustomEncoderOptions.Contains("-par ") && d.HasValue) // custom PAR mode
            {
                Sar s = d.Value.ToSar(hres, vres);
                if (s.X == 1 && s.Y == 1)
                {
                    sb.Append("-par 1 ");
                }
                else if (s.X == 12 && s.Y == 11)
                {
                    sb.Append("-par 2 ");
                }
                else if (s.X == 10 && s.Y == 11)
                {
                    sb.Append("-par 3 ");
                }
                else if (s.X == 16 && s.Y == 11)
                {
                    sb.Append("-par 4 ");
                }
                else if (s.X == 40 && s.Y == 33)
                {
                    sb.Append("-par 5 ");
                }
                else
                {
                    sb.Append("-par " + s.X + ":" + s.Y + " ");
                }
            }
            #endregion

            if (!String.IsNullOrEmpty(xs.CustomEncoderOptions.Trim())) // add custom encoder options
            {
                sb.Append(xs.CustomEncoderOptions.Trim());
            }

            return(sb.ToString());
        }
コード例 #5
0
ファイル: XviDEncoder.cs プロジェクト: RoDaniel/featurehouse
        public static string genCommandline(string input, string output, Dar? d, xvidSettings xs, int hres, int vres, Zone[] zones)
        {
            StringBuilder sb = new StringBuilder();
            CultureInfo ci = new CultureInfo("en-us");
            sb.Append("-i \"" + input + "\" ");
            switch (xs.EncodingMode)
            {
                case 0: // CBR
                    sb.Append("-single -bitrate " + xs.BitrateQuantizer + " "); // add bitrate
                    break;
                case 1: // CQ
                    sb.Append("-single -cq " + xs.Quantizer.ToString(ci) + " "); // add quantizer
                    break;
                case 2: // 2 pass first pass
                    sb.Append("-pass1 " + "\"" + xs.Logfile + "\" -bitrate " + xs.BitrateQuantizer + " "); // add logfile
                    break;
                case 3: // 2 pass second pass
                case 4: // automated twopass
                    sb.Append("-pass2 " + "\"" + xs.Logfile + "\" -bitrate " + xs.BitrateQuantizer + " "); // add logfile
                    break;
            }
            if (xs.EncodingMode <= 1) // 1 pass modes
            {
                if (xs.ReactionDelayFactor != 16)
                    sb.Append("-reaction " + xs.ReactionDelayFactor + " ");
                if (xs.AveragingPeriod != 100)
                    sb.Append("-averaging " + xs.AveragingPeriod + " ");
                if (xs.RateControlBuffer != 100)
                    sb.Append("-smoother " + xs.RateControlBuffer + " ");
            }
            else // two pass modes
            {
                if (xs.KeyFrameBoost != 10)
                    sb.Append("-kboost " + xs.KeyFrameBoost + " ");
                if (xs.KeyframeThreshold != 1)
                    sb.Append("-kthresh " + xs.KeyframeThreshold + " ");
                if (xs.KeyframeReduction != 20)
                    sb.Append("-kreduction " + xs.KeyframeReduction + " ");
                if (xs.OverflowControlStrength != 5)
                    sb.Append("-ostrength " + xs.OverflowControlStrength + " ");
                if (xs.MaxOverflowImprovement != 5)
                    sb.Append("-oimprove " + xs.MaxOverflowImprovement + " ");
                if (xs.MaxOverflowDegradation != 5)
                    sb.Append("-odegrade " + xs.MaxOverflowDegradation + " ");
                if (xs.HighBitrateDegradation != 0)
                    sb.Append("-chigh " + xs.HighBitrateDegradation + " ");
                if (xs.LowBitrateImprovement != 0)
                    sb.Append("-clow " + xs.LowBitrateImprovement + " ");
                sb.Append("-overhead 0 ");
                if (xs.XvidProfile != 0)
                {
                    switch (xs.XvidProfile)
                    {
                        case 0:
                            break;
                        case 1:
                            sb.Append("-vbvmax 4854000 -vbvsize 3145728 -vbvpeak 2359296 ");
                            break;
                        case 2:
                            sb.Append("-vbvmax 9708400 -vbvsize 6291456 -vbvpeak 4718592 ");
                            break;
                        case 3:
                            sb.Append("-vbvmax 20000000 -vbvsize 16000000 -vbvpeak 12000000 ");
                            break;
                        case 4:
                            sb.Append("-vbvmax 200000 -vbvsize 262144 -vbvpeak 196608 ");
                            break;
                        case 5:
                            sb.Append("-vbvmax 600000 -vbvsize 655360 -vbvpeak 491520 ");
                            break;
                        case 6:
                            if (xs.VbvBuffer != 0)
                                sb.Append("-vbvsize " + xs.VbvBuffer + " ");
                            if (xs.VbvMaxRate != 0)
                                sb.Append("-vbvmax " + xs.VbvMaxRate + " ");
                            if (xs.VbvPeakRate != 0)
                                sb.Append("-vbvpeak " + xs.VbvPeakRate + " ");
                            break;
                    }
                }
            }
            if (xs.Turbo)
                sb.Append("-turbo ");
            if (xs.KeyframeInterval != 300)
                sb.Append("-max_key_interval " + xs.KeyframeInterval + " ");
            if (!xs.PackedBitstream) // default is on in encraw
                sb.Append("-nopacked ");
            if (xs.MotionSearchPrecision != 6)
                sb.Append("-quality " + xs.MotionSearchPrecision + " ");
            if (xs.VHQMode != 1)
                sb.Append("-vhqmode " + xs.VHQMode + " ");
            if (xs.QPel)
                sb.Append("-qpel ");
            if (xs.GMC)
                sb.Append("-gmc ");
            if (xs.QuantizerMatrix == xvidSettings.MPEGMatrix)
                sb.Append("-qtype 1 ");
            else if (xs.QuantizerMatrix != xvidSettings.H263Matrix && !string.IsNullOrEmpty(xs.QuantizerMatrix))
                sb.Append("-qmatrix \"" + xs.QuantizerMatrix + "\" ");
            if (xs.Interlaced)
            {
                sb.Append("-interlaced ");
                if (xs.BottomFieldFirst)
                    sb.Append("1 ");
                else
                    sb.Append("2 ");
            }
            if (xs.HVSMasking != 0)
                sb.Append("-masking " + xs.HVSMasking + " ");
            if (!xs.Trellis)
                sb.Append("-notrellis ");
            if (!xs.ChromaMotion)
                sb.Append("-nochromame ");
            if (xs.MinQuantizer != 2)
                sb.Append("-imin " + xs.MinQuantizer + " ");
            if (xs.MaxQuantizer != 31)
                sb.Append("-imax " + xs.MaxQuantizer + " ");
            if (xs.MinPQuant != 2)
                sb.Append("-pmin " + xs.MinPQuant + " ");
            if (xs.MaxPQuant != 31)
                sb.Append("-pmax " + xs.MaxPQuant + " ");
            if (!xs.ClosedGOP)
                sb.Append("-noclosed_gop ");
            if (xs.FrameDropRatio != 0)
                sb.Append("-drop " + xs.FrameDropRatio + " ");

            if (xs.NbBframes != 2) sb.Append("-max_bframes " + xs.NbBframes + " ");
            if (xs.NbBframes > 0)
            {
                if (xs.VHQForBframes)
                    sb.Append("-bvhq ");
                if (xs.BQuantRatio != 150)
                    sb.Append("-bquant_ratio " + xs.BQuantRatio + " ");
                if (xs.BQuantOffset != 100)
                    sb.Append("-bquant_offset " + xs.BQuantOffset + " ");
                if (xs.MinBQuant != 2)
                    sb.Append("-bmin " + xs.MinBQuant + " ");
                if (xs.MaxBQuant != 31)
                    sb.Append("-bmax " + xs.MaxBQuant + " ");
            }
            if (d.HasValue) // custom PAR mode
            {
                Sar s = d.Value.ToSar(hres, vres);
                sb.Append("-par " + s.X + ":" + s.Y + " ");
            }
            sb.Append("-threads " + xs.NbThreads + " ");
            if (zones != null && zones.Length > 0 && xs.CreditsQuantizer >= new decimal(1)
                && xs.EncodingMode != 1) // only for non CQ mode at the moment
            {
                foreach (Zone zone in zones)
                {
                    if (zone.mode == ZONEMODE.Quantizer)
                        sb.Append("-zq " + zone.startFrame + " " + zone.modifier + " ");
                    if (zone.mode == ZONEMODE.Weight)
                    {
                        sb.Append("-zw " + zone.startFrame + " ");
                        double mod = (double)zone.modifier / 100.0;
                        sb.Append(mod.ToString(ci) + " ");
                    }
                }
            }
            if (xs.EncodingMode != 2) // not 2 pass vbr first pass, add output filename and output type
            {
                string extension = Path.GetExtension(output).ToLower();
                if (extension.Equals(".mkv"))
                    sb.Append(" -mkv \"" + output + "\"");
                else if (extension.Equals(".avi"))
                    sb.Append(" -avi \"" + output + "\"");
                else
                    sb.Append(" -o \"" + output + "\"");
            }
            if (!xs.CustomEncoderOptions.Equals("")) // add custom encoder options
                sb.Append(" " + xs.CustomEncoderOptions);
            return sb.ToString();
        }