public static string GetEncodeVideoFFMpegArgs(string sSourceFile, MP4Info objMp4Info, double nMbps, int iWidth, int iHeight, bool bIncludeAudio, string sOutputFile)
    {
        //Ensure file contains a video stream, otherwise this command will fail
        if (objMp4Info != null && objMp4Info.VideoStreamCount == 0)
        {
            throw new Exception("FFMpegArgUtils::GetEncodeVideoFFMpegArgs - mp4 does not contain a video stream");
        }

        int iBitRateInKbps = (int)(nMbps * 1000);


        StringBuilder sbArgs = new StringBuilder();

        sbArgs.Append(" -y -threads 2 -i \"" + sSourceFile + "\" -strict -2 ");         // 0 tells it to choose how many threads to use

        if (bIncludeAudio == true)
        {
            //sbArgs.Append(" -acodec libmp3lame -ab 96k");
            sbArgs.Append(" -acodec aac -ar 44100 -ab 96k");
        }
        else
        {
            sbArgs.Append(" -an");
        }


        sbArgs.Append(" -vcodec libx264 -level 41 -r 15 -crf 25 -g 15  -keyint_min 45 -bf 0");

        //sbArgs.Append(" -vf pad=" + iWidth + ":" + iHeight + ":" + iVideoOffsetX + ":" + iVideoOffsetY);
        sbArgs.Append(String.Format(" -vf \"scale=iw*min({0}/iw\\,{1}/ih):ih*min({0}/iw\\,{1}/ih),pad={0}:{1}:({0}-iw)/2:({1}-ih)/2\"", iWidth, iHeight));

        //Output File
        sbArgs.Append(" \"" + sOutputFile + "\"");
        return(sbArgs.ToString());
    }
 /// <summary>
 /// Encodes an MP4 to the specs provided, quality is a value from 0 to 1
 /// </summary>
 /// <param name="nQuality">A value from 0 to 1</param>
 ///
 public CreateEncodedVideoCommand(string sSourceFile, string sOutputFolder, string sFFMpegPath, double nMaxBitrateInMbps, MP4Info objSourceInfo, int iOutputWidth, int iOutputHeight, string sOutputExt)
 {
     _sSourceFile   = sSourceFile;
     _sOutputFolder = sOutputFolder;
     _nMaxMbps      = nMaxBitrateInMbps;
     _objSourceInfo = objSourceInfo;
     _iOutputWidth  = iOutputWidth;
     _iOutputHeight = iOutputHeight;
     _sFFMpegPath   = sFFMpegPath;
     _sOutputExt    = sOutputExt;
 }