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

            if (
                this.AvoidHighMoBframes != otherSettings.AvoidHighMoBframes ||
                this.BorderMask != otherSettings.BorderMask ||
                this.BQuantFactor != otherSettings.BQuantFactor ||
                this.BufferSize != otherSettings.BufferSize ||
                this.CustomEncoderOptions != otherSettings.CustomEncoderOptions ||
                this.DarkMask != otherSettings.DarkMask ||
                this.EncodingMode != otherSettings.EncodingMode ||
                this.FieldOrder != otherSettings.FieldOrder ||
                this.FilesizeTolerance != otherSettings.FilesizeTolerance ||
                this.FourCC != otherSettings.FourCC ||
                // this.FourCCs != otherSettings.FourCCs ||
                this.GreyScale != otherSettings.GreyScale ||
                this.InitialBufferOccupancy != otherSettings.InitialBufferOccupancy ||
                this.Interlaced != otherSettings.Interlaced ||
                this.InterMatrix != otherSettings.InterMatrix ||
                this.IntraMatrix != otherSettings.IntraMatrix ||
                this.IPFactor != otherSettings.IPFactor ||
                this.KeyframeInterval != otherSettings.KeyframeInterval ||
                this.LumiMasking != otherSettings.LumiMasking ||
                this.MaxBitrate != otherSettings.MaxBitrate ||
                this.MaxQuantDelta != otherSettings.MaxQuantDelta ||
                this.MaxQuantizer != otherSettings.MaxQuantizer ||
                this.MbDecisionAlgo != otherSettings.MbDecisionAlgo ||
                this.MERange != otherSettings.MERange ||
                this.MinBitrate != otherSettings.MinBitrate ||
                this.MinQuantizer != otherSettings.MinQuantizer ||
                this.NbBframes != otherSettings.NbBframes ||
                this.NbMotionPredictors != otherSettings.NbMotionPredictors ||
                this.PBFactor != otherSettings.PBFactor ||
                this.QPel != otherSettings.QPel ||
                this.QuantizerBlur != otherSettings.QuantizerBlur ||
                this.QuantizerCompression != otherSettings.QuantizerCompression ||
                this.SCD != otherSettings.SCD ||
                this.SpatialMask != otherSettings.SpatialMask ||
                this.SubpelRefinement != otherSettings.SubpelRefinement ||
                this.TemporalMask != otherSettings.TemporalMask ||
                this.Trellis != otherSettings.Trellis ||
                this.Turbo != otherSettings.Turbo ||
                this.V4MV != otherSettings.V4MV
                )
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public static string genLavcCommandline(string input, string output, Dar?d, lavcSettings ls)
        {
            CultureInfo   ci = new CultureInfo("en-us");
            StringBuilder sb = new StringBuilder();

            sb.Append("\"" + input + "\" -ovc lavc -nosound ");
            if (ls.EncodingMode == 4 || ls.EncodingMode == 7)
            {
                ls.Turbo = false;
            }
            switch (ls.EncodingMode)
            {
            case 0:                                                           // CBR
                sb.Append("-lavcopts vbitrate=" + ls.BitrateQuantizer + ":"); // add bitrate
                break;

            case 1:                                                          // CQ
                sb.Append("-lavcopts vqscale=" + ls.BitrateQuantizer + ":"); // add quantizer
                break;

            case 2:                                                                   // 2 pass first pass
                sb.Append("-o NUL: -passlogfile " + "\"" + ls.Logfile + "\" ");       // add logfile
                sb.Append("-lavcopts vpass=1:vbitrate=" + ls.BitrateQuantizer + ":"); // add pass & quantizer
                if (ls.Turbo)
                {
                    sb.Append("turbo:");
                }
                break;

            case 3:                                                                   // 2 pass second pass
            case 4:                                                                   // 2 pass automated encoding
                sb.Append(" -passlogfile " + "\"" + ls.Logfile + "\" ");              // add logfile
                sb.Append("-lavcopts vpass=2:vbitrate=" + ls.BitrateQuantizer + ":"); // add pass & bitrate
                break;

            case 5:                                                                   // 3 pass first pass
                sb.Append("-o NUL: -passlogfile " + "\"" + ls.Logfile + "\" ");       // add logfile
                sb.Append("-lavcopts vpass=1:vbitrate=" + ls.BitrateQuantizer + ":"); // add pass & quantizer
                break;

            case 6:                                                                   // 3 pass 2nd pass
                sb.Append(" -passlogfile " + "\"" + ls.Logfile + "\" ");              // add logfile
                sb.Append("-lavcopts vpass=3:vbitrate=" + ls.BitrateQuantizer + ":"); // add pass & bitrate
                break;

            case 7:
                sb.Append(" -passlogfile " + "\"" + ls.Logfile + "\" ");              // add logfile
                sb.Append("-lavcopts vpass=3:vbitrate=" + ls.BitrateQuantizer + ":"); // add pass & bitrate
                break;
            } // now add the rest of the lavc encoder options
            if (ls.KeyframeInterval != 250) // gop size of 250 is default
            {
                sb.Append("keyint=" + ls.KeyframeInterval + ":");
            }
            if (ls.NbBframes != 0) // 0 is default value
            {
                sb.Append("vmax_b_frames=" + ls.NbBframes + ":");
            }
            if (ls.AvoidHighMoBframes && (ls.EncodingMode == 2 || ls.EncodingMode == 5)) // is only available in first pass
            {
                sb.Append("vb_strategy=1:");
            }
            if (ls.MbDecisionAlgo > 0) // default is 0
            {
                sb.Append("mbd=" + ls.MbDecisionAlgo + ":");
            }
            if (ls.V4MV)
            {
                sb.Append("v4mv:");
            }
            if (ls.SCD != 0)
            {
                sb.Append("sc_treshold=" + ls.SCD + ":");
            }
            if (ls.QPel)
            {
                sb.Append("qpel:");
            }
            if (ls.LumiMasking != new decimal(0.0))
            {
                sb.Append("lumi_mask=" + ls.LumiMasking.ToString(ci) + ":");
            }
            if (ls.DarkMask != new decimal(0.0))
            {
                sb.Append("dark_mask=" + ls.DarkMask.ToString(ci) + ":");
            }
            if (ls.SubpelRefinement != 8)
            {
                sb.Append("subq=" + ls.SubpelRefinement + ":");
            }
            if (ls.GreyScale)
            {
                sb.Append("gray:");
            }
            if (ls.Interlaced)
            {
                sb.Append("ildct:ilme");
                if (ls.FieldOrder != -1)
                {
                    sb.Append("top=" + ls.FieldOrder + ":");
                }
            }
            if (ls.MERange != (decimal)0)
            {
                sb.Append("me_range=" + ls.MERange.ToString(ci) + ":");
            }
            if (ls.InitialBufferOccupancy != (decimal)0.9)
            {
                sb.Append("vrc_init_occupancy=" + ls.InitialBufferOccupancy.ToString(ci) + ":");
            }
            if (ls.BorderMask != (decimal)0.0)
            {
                sb.Append("border_mask=" + ls.BorderMask.ToString(ci) + ":");
            }
            if (ls.TemporalMask != (decimal)0.0)
            {
                sb.Append("tcplx_mask=" + ls.TemporalMask.ToString(ci) + ":");
            }
            if (ls.SpatialMask != (decimal)0.0)
            {
                sb.Append("scplx_mask=" + ls.SpatialMask.ToString(ci) + ":");
            }
            if (ls.NbThreads > 1)
            {
                sb.Append("threads=" + ls.NbThreads + ":");
            }
            if (ls.MinQuantizer != 2)
            {
                sb.Append("vqmin=" + ls.MinQuantizer + ":");
            }
            if (ls.MaxQuantizer != 31)
            {
                sb.Append("vqmax=" + ls.MaxQuantizer + ":");
            }
            if (ls.MaxQuantDelta != 3)
            {
                sb.Append("vqdiff=" + ls.MaxQuantDelta + ":");
            }
            if (ls.EncodingMode == 0 || ls.EncodingMode == 1)
            {
                if (ls.IPFactor != (decimal)0.8)
                {
                    sb.Append("vi_qfactor=" + ls.IPFactor.ToString(ci) + ":");
                }
                if (ls.PBFactor != (decimal)1.25)
                {
                    sb.Append("vb_qfactor=" + ls.PBFactor.ToString(ci) + ":");
                }
                if (ls.BQuantFactor != (decimal)1.25)
                {
                    sb.Append("vb_qoffset=" + ls.BQuantFactor.ToString(ci) + ":");
                }
            }
            if (ls.QuantizerBlur != new decimal(0.5))
            {
                sb.Append("vqblur=" + ls.QuantizerBlur.ToString(ci) + ":");
            }
            if (ls.QuantizerCompression != new decimal(0.5))
            {
                sb.Append("vqcomp=" + ls.QuantizerCompression.ToString(ci) + ":");
            }
            if (ls.Trellis)
            {
                sb.Append("trell:");
            }
            if (ls.MinBitrate != 0) // 0 = unlimited is default
            {
                sb.Append("vrc_minrate=" + ls.MinBitrate + ":");
            }
            if (ls.MaxBitrate != 0) // 0 = unlimited is default
            {
                sb.Append("vrc_maxrate=" + ls.MaxBitrate + ":");
            }
            if (ls.BufferSize != 0) // default = empty
            {
                sb.Append("vrc_buf_size=" + ls.BufferSize + ":");
            }
            if (ls.FilesizeTolerance != 8000) // default is 8000 kbits
            {
                sb.Append("vratetol=" + ls.FilesizeTolerance + ":");
            }
            if (ls.Zones != null && ls.Zones.Length > 0 && ls.CreditsQuantizer >= new decimal(1))
            {
                sb.Append("vrc_override=");
                foreach (Zone zone in ls.Zones)
                {
                    if (zone.mode == ZONEMODE.QUANTIZER)
                    {
                        sb.Append(zone.startFrame + "," + zone.endFrame + "," + zone.modifier + "/");
                    }
                    else
                    {
                        sb.Append(zone.startFrame + "," + zone.endFrame + ",-" + zone.modifier + "/");
                    }
                }
                sb.Remove(sb.Length - 1, 1); // remove trailing slash
                sb.Append(":");
            }
            if (!ls.IntraMatrix.Equals(""))
            {
                sb.Append("intra_matrix=" + ls.IntraMatrix + ":");
            }
            if (!ls.InterMatrix.Equals(""))
            {
                sb.Append("inter_matrix=" + ls.InterMatrix + ":");
            }
            if (d.HasValue)
            {
                sb.Append("aspect=" + d.Value.X + "/" + d.Value.Y + ":");
            }
            if (ls.NbMotionPredictors != (decimal)0)
            {
                sb.Append("last_pred=" + ls.NbMotionPredictors.ToString(ci) + ":");
            }

            if (sb.ToString().EndsWith(":")) // remove the last :
            {
                sb.Remove(sb.Length - 1, 1);
            }
            //add the rest of the mencoder commandline regarding the output
            if (ls.EncodingMode != 2 && ls.EncodingMode != 5) // not 2 pass vbr first pass and 3 pass first pass, add output filename and output type
            {
                sb.Append(" -o \"" + output + "\" -of ");     // rest of mencoder options
                int outputType = getVideoOutputType(output);
                if (outputType == 0)                          // AVI
                {
                    sb.Append("avi -ffourcc " + ls.FourCCs[ls.FourCC] + " ");
                }
                if (outputType >= 1) // RAW
                {
                    sb.Append("rawvideo ");
                }
            }
            return(sb.ToString());
        }