protected void ComposeFFMpegOutputArgs(StringBuilder outputArgs, string outputFormat, OutputSettings settings)
 {
     if (settings != null)
     {
         if (settings.MaxDuration.HasValue)
         {
             outputArgs.AppendFormat(CultureInfo.InvariantCulture, " -t {0}", new object[] { settings.MaxDuration });
         }
         if (outputFormat != null)
         {
             outputArgs.AppendFormat(" -f {0} ", outputFormat);
         }
         if (settings.AudioSampleRate.HasValue)
         {
             outputArgs.AppendFormat(" -ar {0}", settings.AudioSampleRate);
         }
         if (settings.AudioCodec != null)
         {
             outputArgs.AppendFormat(" -acodec {0}", settings.AudioCodec);
         }
         if (settings.VideoFrameCount.HasValue)
         {
             outputArgs.AppendFormat(" -vframes {0}", settings.VideoFrameCount);
         }
         if (settings.VideoFrameRate.HasValue)
         {
             outputArgs.AppendFormat(" -r {0}", settings.VideoFrameRate);
         }
         if (settings.VideoCodec != null)
         {
             outputArgs.AppendFormat(" -vcodec {0}", settings.VideoCodec);
         }
         if (settings.VideoFrameSize != null)
         {
             outputArgs.AppendFormat(" -s {0}", settings.VideoFrameSize);
         }
         if (settings.CustomOutputArgs != null)
         {
             outputArgs.AppendFormat(" {0} ", settings.CustomOutputArgs);
         }
     }
 }
        public void ConvertMedia(FFMpegInput[] inputs, string output, string outputFormat, OutputSettings settings)
        {
            if ((inputs == null) || (inputs.Length == 0))
            {
                throw new ArgumentException("At least one ffmpeg input should be specified");
            }
            FFMpegInput   input   = inputs[inputs.Length - 1];
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < (inputs.Length - 1); i++)
            {
                FFMpegInput input2 = inputs[i];
                if (input2.Format != null)
                {
                    builder.Append(" -f " + input2.Format);
                }
                if (input2.CustomInputArgs != null)
                {
                    builder.AppendFormat(" {0} ", input2.CustomInputArgs);
                }
                builder.AppendFormat(" -i {0} ", this.CommandArgParameter(input2.Input));
            }
            ConvertSettings outputSettings = new ConvertSettings();

            settings.CopyTo(outputSettings);
            outputSettings.CustomInputArgs = builder.ToString() + input.CustomInputArgs;
            this.ConvertMedia(input.Input, input.Format, output, outputFormat, outputSettings);
        }