Commits

Justin Lloyd  committed 7eb0d2c

Added VideoProfile parameter
Added Preset parameter
Added MinimumRate parameter
Renamed VideoRate parameter to VideoBitrate to make it consistent with AudioBitrate
Added Pass parameter
Added AudioBitrate parameter
Added AudioChannels parameter
Added AudioRate parameter
Added overloaded version of ExtractSingleFrame to take default dimensions from video

  • Participants
  • Parent commits 005d1eb

Comments (0)

Files changed (2)

File FFMPEGWrapper/FFMPEGParameters.cs

         public bool DisableAudio;
 
         public string VideoFilter;
+        public string VideoProfile;
+        public string Preset;
 
         public int? BufferSize;
 
         public int? MaximumRate;
+        public int? MinimumRate;
+        public int? VideoBitrate;
+        public int? Pass;
+        public int? AudioBitrate;
+        public int? AudioChannels;
+        public int? AudioRate;
 
         private StringBuilder m_assembledOptions;
 
         {
             m_assembledOptions.Append(separator);
         }
-        
+
         protected void AddRawOptions(string rawOptions)
         {
             m_assembledOptions.Append(rawOptions);
                 AddOption("f", Format);
             }
 
-            if (BufferSize!=null)
+            if (BufferSize != null)
             {
                 AddOption("bufsize", String.Format("{0}KB", BufferSize));
             }
 
-            if (MaximumRate!=null)
+            if (MaximumRate != null)
             {
                 AddOption("maxrate", String.Format("{0}KB", MaximumRate));
             }
 
+            if (MinimumRate != null)
+            {
+                AddOption("minrate", String.Format("{0}KB", MinimumRate));
+            }
+
+            if (VideoBitrate != null)
+            {
+                AddOption("b:v", String.Format("{0}k", VideoBitrate));
+            }
+
+            if (AudioBitrate != null)
+            {
+                AddOption("b:a", String.Format("{0}k", AudioBitrate));
+            }
+
+            if (AudioChannels != null)
+            {
+                AddOption("ac", AudioChannels.ToString());
+            }
+
+            if (AudioRate != null)
+            {
+                AddOption("ar", AudioRate.ToString());
+            }
+
+            if (Pass != null)
+            {
+                AddOption("pass", Pass.ToString());
+            }
+
             if (!Size.IsEmpty)
             {
                 AddOption("s", Size.Width.ToString(), "x", Size.Height.ToString());
             }
 
+            if (!String.IsNullOrWhiteSpace(VideoProfile))
+            {
+                AddOption("vprofile", VideoProfile);
+            }
+
+            if (!String.IsNullOrWhiteSpace(Preset))
+            {
+                AddOption("preset", Preset);
+            }
+
+
             if (!String.IsNullOrWhiteSpace(VideoFilter))
             {
                 AddOption("vf", VideoFilter);
 
             AssembleOutputOptions();
 
-            if (!String.IsNullOrWhiteSpace(OutputFilePath))
+
+            if (String.IsNullOrWhiteSpace(OutputFilePath))
+            {
+                AddSeparator(" ");
+                AddParameter("NUL");
+            }
+            else
             {
                 AddSeparator(" ");
                 AddParameter(String.Format("\"{0}\"", OutputFilePath));
-            }
+            } 
 
             return m_assembledOptions.ToString();
         }

File FFMPEGWrapper/VideoFile.cs

             return loadedImage;
         }
 
-        public Image ExtractSingleFrame(int positionToExtract, Size dimensions = Size.Empty)
+        // I would have made "dimensions" be an optional parameter, but
+        // unfortunately C# requires that optional parameters be a "compile
+        // time constant" so I cannot use either "Size.Empty" or "new Size()"
+        // as the default parameter value. Hence, we have to fall back to a
+        // method overload.
+        public Image ExtractSingleFrame(int positionToExtract)
+        {
+            return ExtractSingleFrame(positionToExtract, Size.Empty);
+        }
+
+        public Image ExtractSingleFrame(int positionToExtract, Size dimensions)
         {
             string tempFile = Path.ChangeExtension(Path.GetTempFileName(), "jpg");
             FFMPEGParameters parameters = new FFMPEGParameters()