[chronojump] webcam can have custom resolution and framerate (with decimals as string)



commit 6638db0e12431c4c319979166b72600a0485fc07
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri May 17 18:39:13 2019 +0200

    webcam can have custom resolution and framerate (with decimals as string)

 glade/preferences_win.glade | 307 +++++++++++++++++++++++++++++++++-----------
 src/gui/preferences.cs      | 115 ++++++++++++++---
 src/preferences.cs          |   2 +-
 src/sqlite/preferences.cs   |   2 +-
 src/util.cs                 |   2 +-
 src/webcamFfmpeg.cs         |   2 +-
 6 files changed, 332 insertions(+), 98 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index bce6f6e2..5e8f9fe6 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -3512,31 +3512,43 @@ Other</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="border_width">8</property>
-                        <property name="spacing">10</property>
-                        <child>
-                          <widget class="GtkLabel" id="label62">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="label" translatable="yes">Select the camera</property>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
+                        <property name="spacing">12</property>
                         <child>
-                          <widget class="GtkHBox" id="hbox_combo_camera">
+                          <widget class="GtkHBox" id="hbox46">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
+                            <property name="spacing">16</property>
                             <child>
-                              <placeholder/>
+                              <widget class="GtkLabel" id="label62">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Select the camera:</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkHBox" id="hbox_combo_camera">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
                             </child>
                           </widget>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">1</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
@@ -3546,7 +3558,7 @@ Other</property>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">2</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
                         <child>
@@ -3555,10 +3567,13 @@ Other</property>
                             <property name="can_focus">False</property>
                             <property name="spacing">20</property>
                             <child>
-                              <widget class="GtkHBox" id="hbox25">
+                              <widget class="GtkTable" id="table5">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="spacing">10</property>
+                                <property name="n_rows">2</property>
+                                <property name="n_columns">3</property>
+                                <property name="column_spacing">12</property>
+                                <property name="row_spacing">10</property>
                                 <child>
                                   <widget class="GtkLabel" id="label76">
                                     <property name="visible">True</property>
@@ -3566,47 +3581,33 @@ Other</property>
                                     <property name="label" translatable="yes">Resolution</property>
                                   </widget>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">0</property>
+                                    <property name="x_options"/>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox_combo_camera_resolution">
+                                  <widget class="GtkLabel" id="label78">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
+                                    <property name="label" translatable="yes">Framerate</property>
                                   </widget>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options"/>
                                   </packing>
                                 </child>
-                              </widget>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkHBox" id="hbox31">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="spacing">10</property>
                                 <child>
-                                  <widget class="GtkLabel" id="label78">
+                                  <widget class="GtkHBox" id="hbox_combo_camera_resolution">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <property name="label" translatable="yes">Framerate</property>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">0</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="x_options"/>
                                   </packing>
                                 </child>
                                 <child>
@@ -3618,68 +3619,218 @@ Other</property>
                                     </child>
                                   </widget>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options"/>
                                   </packing>
                                 </child>
-                              </widget>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkButton" id="button_video_preview">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip" translatable="yes">Preview video</property>
-                                <signal name="clicked" handler="on_button_video_preview_clicked" 
swapped="no"/>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox321">
-                                    <property name="visible">True</property>
+                                  <widget class="GtkHBox" id="hbox_camera_resolution_custom">
                                     <property name="can_focus">False</property>
-                                    <property name="spacing">4</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <widget class="GtkSpinButton" id="spin_camera_resolution_custom_width">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="has_tooltip">True</property>
+                                        <property name="tooltip" translatable="yes">Width</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="invisible_char_set">True</property>
+                                        <property name="primary_icon_activatable">False</property>
+                                        <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
+                                        <property name="adjustment">800 50 20000 1 10 0</property>
+                                        <property name="climb_rate">1</property>
+                                        <property name="snap_to_ticks">True</property>
+                                        <property name="numeric">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
                                     <child>
-                                      <widget class="GtkImage" id="image_video_preview">
+                                      <widget class="GtkLabel" id="label84">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="stock">gtk-missing-image</property>
+                                        <property name="label">x</property>
                                       </widget>
                                       <packing>
-                                        <property name="expand">True</property>
-                                        <property name="fill">True</property>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkSpinButton" 
id="spin_camera_resolution_custom_height">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="has_tooltip">True</property>
+                                        <property name="tooltip" translatable="yes">Height</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="width_chars">5</property>
+                                        <property name="invisible_char_set">True</property>
+                                        <property name="primary_icon_activatable">False</property>
+                                        <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
+                                        <property name="adjustment">600 50 20000 1 10 0</property>
+                                        <property name="climb_rate">1</property>
+                                        <property name="snap_to_ticks">True</property>
+                                        <property name="numeric">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">2</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                  <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="x_options"/>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox_camera_framerate_custom">
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <widget class="GtkSpinButton" id="spin_camera_framerate_custom">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="has_tooltip">True</property>
+                                        <property name="tooltip" translatable="yes">Framerate</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="width_chars">5</property>
+                                        <property name="invisible_char_set">True</property>
+                                        <property name="primary_icon_activatable">False</property>
+                                        <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
+                                        <property name="adjustment">100 5 9999 1 10 0</property>
+                                        <property name="climb_rate">1</property>
+                                        <property name="snap_to_ticks">True</property>
+                                        <property name="numeric">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
                                         <property name="position">0</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkLabel" id="label392">
+                                      <widget class="GtkLabel" id="label85">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Preview</property>
+                                        <property name="label">.</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkEntry" id="entry_camera_framerate_custom_decimals">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="width_chars">7</property>
+                                        <property name="text" translatable="yes">0</property>
+                                        <property name="primary_icon_activatable">False</property>
+                                        <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
                                       </widget>
                                       <packing>
                                         <property name="expand">True</property>
                                         <property name="fill">True</property>
-                                        <property name="position">1</property>
+                                        <property name="position">2</property>
                                       </packing>
                                     </child>
                                   </widget>
+                                  <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
                                 </child>
                               </widget>
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkVBox" id="vbox30">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <widget class="GtkButton" id="button_video_preview">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
+                                    <property name="tooltip" translatable="yes">Preview video</property>
+                                    <signal name="clicked" handler="on_button_video_preview_clicked" 
swapped="no"/>
+                                    <child>
+                                      <widget class="GtkHBox" id="hbox321">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">4</property>
+                                        <child>
+                                          <widget class="GtkImage" id="image_video_preview">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="stock">gtk-missing-image</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkLabel" id="label392">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="label" translatable="yes">Preview</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </widget>
+                                    </child>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
                               </packing>
                             </child>
                           </widget>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">3</property>
+                            <property name="position">2</property>
                           </packing>
                         </child>
                         <child>
@@ -3798,7 +3949,7 @@ Other</property>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">4</property>
+                            <property name="position">3</property>
                           </packing>
                         </child>
                         <child>
@@ -3816,7 +3967,7 @@ Other</property>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">5</property>
+                            <property name="position">4</property>
                           </packing>
                         </child>
                         <child>
@@ -3828,7 +3979,7 @@ Other</property>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">6</property>
+                            <property name="position">5</property>
                           </packing>
                         </child>
                       </widget>
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index b88d1772..40a62b43 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -149,6 +149,12 @@ public class PreferencesWindow
        [Widget] Gtk.Box hbox_combo_camera;
        [Widget] Gtk.ComboBox combo_camera;
        [Widget] Gtk.HBox hbox_camera_resolution_framerate;
+       [Widget] Gtk.HBox hbox_camera_resolution_custom;
+       [Widget] Gtk.SpinButton spin_camera_resolution_custom_width;
+       [Widget] Gtk.SpinButton spin_camera_resolution_custom_height;
+       [Widget] Gtk.HBox hbox_camera_framerate_custom;
+       [Widget] Gtk.SpinButton spin_camera_framerate_custom;
+       [Widget] Gtk.Entry entry_camera_framerate_custom_decimals;
        [Widget] Gtk.Box hbox_combo_camera_resolution;
        [Widget] Gtk.ComboBox combo_camera_resolution;
        [Widget] Gtk.Box hbox_combo_camera_framerate;
@@ -618,7 +624,7 @@ public class PreferencesWindow
 
        private void createComboCamera(string current, string resolution, string framerate)
        {
-               //videoDevice
+               //1) videoDevice
 
                combo_camera = ComboBox.NewText ();
 
@@ -639,7 +645,7 @@ public class PreferencesWindow
                        vbox_camera_stop_after_all.Visible = false;
                        return;
                }
-               
+
                //UtilGtk.ComboUpdate(combo_camera, wd_list.GetCodes());
                UtilGtk.ComboUpdate(combo_camera, wd_list.GetFullnames());
                hbox_combo_camera.PackStart(combo_camera, true, true, 0);
@@ -650,30 +656,72 @@ public class PreferencesWindow
                
                combo_camera.Active = UtilGtk.ComboMakeActive(combo_camera, current);
 
-               //resolution
+               //2) resolution
 
                combo_camera_resolution = ComboBox.NewText ();
-               //string [] resolutions = { "320x240", "640x480", "1280x720" };
                List<string> resolutions = new List<string>();
                resolutions.Add("320x240");
                resolutions.Add("640x480");
                resolutions.Add("1280x720");
+               resolutions.Add(Catalog.GetString("Custom")); //in SQL will be stored the values not "Custom" 
text
                UtilGtk.ComboUpdate(combo_camera_resolution, resolutions);
+
+               bool found = false;
+               foreach(string str in resolutions)
+                       if(str == resolution)
+                               found = true;
+
+               if(found)
+                       combo_camera_resolution.Active = UtilGtk.ComboMakeActive(combo_camera_resolution, 
resolution);
+               else {
+                       combo_camera_resolution.Active = UtilGtk.ComboMakeActive(combo_camera_resolution, 
Catalog.GetString("Custom"));
+                       string [] strFull = resolution.Split('x');
+                       if(strFull.Length == 2) {
+                               spin_camera_resolution_custom_width.Value = Convert.ToInt32(strFull[0]);
+                               spin_camera_resolution_custom_height.Value = Convert.ToInt32(strFull[1]);
+                       }
+                       hbox_camera_resolution_custom.Visible = true;
+               }
+
                hbox_combo_camera_resolution.PackStart(combo_camera_resolution, true, true, 0);
                hbox_combo_camera_resolution.ShowAll();
-               combo_camera_resolution.Active = UtilGtk.ComboMakeActive(combo_camera_resolution, resolution);
+               combo_camera_resolution.Changed += new EventHandler (on_combo_camera_resolution_changed);
 
-               //framerate
+               //3) framerate
 
                combo_camera_framerate = ComboBox.NewText ();
-               //string [] framerates = { "30", "60" };
                List<string> framerates = new List<string>();
                framerates.Add("30");
                framerates.Add("60");
+               framerates.Add(Catalog.GetString("Custom")); //in SQL will be stored the values not "Custom" 
text
                UtilGtk.ComboUpdate(combo_camera_framerate, framerates);
+
+               found = false;
+               foreach(string str in framerates)
+                       if(str == framerate)
+                               found = true;
+
+               if(found)
+                       combo_camera_framerate.Active = UtilGtk.ComboMakeActive(combo_camera_framerate, 
framerate);
+               else {
+                       combo_camera_framerate.Active = UtilGtk.ComboMakeActive(combo_camera_framerate, 
Catalog.GetString("Custom"));
+                       string [] strFull = framerate.Split(new char[] {'.'});
+
+                       if(strFull.Length == 1)
+                       {
+                               spin_camera_framerate_custom.Value = Convert.ToInt32(framerate);
+                       }
+                       else if(strFull.Length == 2)
+                       {
+                               spin_camera_framerate_custom.Value = Convert.ToInt32(strFull[0]);
+                               entry_camera_framerate_custom_decimals.Text = strFull[1];
+                       }
+                       hbox_camera_framerate_custom.Visible = true;
+               }
+
                hbox_combo_camera_framerate.PackStart(combo_camera_framerate, true, true, 0);
                hbox_combo_camera_framerate.ShowAll();
-               combo_camera_framerate.Active = UtilGtk.ComboMakeActive(combo_camera_framerate, framerate);
+               combo_camera_framerate.Changed += new EventHandler (on_combo_camera_framerate_changed);
        }
 
        private void on_check_camera_stop_after_toggled (object o, EventArgs args)
@@ -681,7 +729,16 @@ public class PreferencesWindow
                //vbox_camera_stop_after.Visible = check_camera_stop_after.Active;
                hbox_camera_stop_after_seconds.Visible = check_camera_stop_after.Active;
        }
-               
+
+       private void on_combo_camera_resolution_changed (object o, EventArgs args)
+       {
+               hbox_camera_resolution_custom.Visible = UtilGtk.ComboGetActive(combo_camera_resolution) == 
Catalog.GetString("Custom");
+       }
+       private void on_combo_camera_framerate_changed (object o, EventArgs args)
+       {
+               hbox_camera_framerate_custom.Visible = UtilGtk.ComboGetActive(combo_camera_framerate) == 
Catalog.GetString("Custom");
+       }
+
        private void on_check_appearance_maximized_toggled (object obj, EventArgs args)
        {
                alignment_undecorated.Visible = check_appearance_maximized.Active;
@@ -734,10 +791,34 @@ public class PreferencesWindow
                        return;
 
                Webcam webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(),
-                               cameraCode, UtilGtk.ComboGetActive(combo_camera_resolution), 
UtilGtk.ComboGetActive(combo_camera_framerate));
+                               cameraCode, getSelectedResolution(), getSelectedFramerate());
                Webcam.Result result = webcamPlay.PlayPreviewNoBackground ();
        }
 
+       private string getSelectedResolution()
+       {
+               string selected = UtilGtk.ComboGetActive(combo_camera_resolution);
+               if(selected == Catalog.GetString("Custom"))
+                       selected = string.Format("{0}x{1}", spin_camera_resolution_custom_width.Value, 
spin_camera_resolution_custom_height.Value);
+
+               return selected;
+       }
+       private string getSelectedFramerate()
+       {
+               string selected = UtilGtk.ComboGetActive(combo_camera_framerate);
+               if(selected == Catalog.GetString("Custom"))
+               {
+                       string decStr = entry_camera_framerate_custom_decimals.Text;
+                       if(decStr != "0" && Util.IsNumber(decStr, false))
+                               selected = string.Format("{0}.{1}", spin_camera_framerate_custom.Value, 
decStr); //decimal in ffmpeg has to be '.'
+                       else
+                               selected = string.Format("{0}", spin_camera_framerate_custom.Value);
+               }
+
+               LogB.Information("selected framerate: " + selected);
+               return selected;
+       }
+
        // ---- end of multimedia stuff
 
        // ---- Language stuff
@@ -1568,14 +1649,16 @@ public class PreferencesWindow
                        preferences.videoDevice = cameraCode;
                }
 
-               if( preferences.videoDeviceResolution != UtilGtk.ComboGetActive(combo_camera_resolution) ) {
-                       SqlitePreferences.Update("videoDeviceResolution", 
UtilGtk.ComboGetActive(combo_camera_resolution), true);
-                       preferences.videoDeviceResolution = UtilGtk.ComboGetActive(combo_camera_resolution);
+               string resolution = getSelectedResolution();
+               if( preferences.videoDeviceResolution != resolution ) {
+                       SqlitePreferences.Update("videoDeviceResolution", resolution, true);
+                       preferences.videoDeviceResolution = resolution;
                }
 
-               if( preferences.videoDeviceFramerate != UtilGtk.ComboGetActive(combo_camera_framerate) ) {
-                       SqlitePreferences.Update("videoDeviceFramerate", 
UtilGtk.ComboGetActive(combo_camera_framerate), true);
-                       preferences.videoDeviceFramerate = UtilGtk.ComboGetActive(combo_camera_framerate);
+               string framerate = getSelectedFramerate();
+               if( preferences.videoDeviceFramerate != framerate ) {
+                       SqlitePreferences.Update("videoDeviceFramerate", framerate, true);
+                       preferences.videoDeviceFramerate = framerate; //if it has decimals, separator should 
be a point
                }
 
                int selected_camera_stop_after = Convert.ToInt32(spin_camera_stop_after.Value);
diff --git a/src/preferences.cs b/src/preferences.cs
index 1a978ec1..7f3e87c0 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -77,7 +77,7 @@ public class Preferences
        
        public string videoDevice;
        public string videoDeviceResolution;
-       public string videoDeviceFramerate;
+       public string videoDeviceFramerate; //cannot be a double because decimals seem exactly important on 
mac. if decimal will have always a '.' as needed by ffmpeg
        public int videoStopAfter;
        public string CSVExportDecimalSeparator;
        public string language;
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 0ad500a4..e1275b80 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -378,7 +378,7 @@ class SqlitePreferences : Sqlite
                        else if(reader[0].ToString() == "videoDeviceResolution")
                                preferences.videoDeviceResolution = reader[1].ToString();
                        else if(reader[0].ToString() == "videoDeviceFramerate")
-                               preferences.videoDeviceFramerate = reader[1].ToString();
+                               preferences.videoDeviceFramerate = reader[1].ToString(); //if it is decimal 
will be always a '.' as needed by ffmpeg
                        else if(reader[0].ToString() == "videoStopAfter")
                                preferences.videoStopAfter = Convert.ToInt32(reader[1].ToString());
                        else if(reader[0].ToString() == "CSVExportDecimalSeparator")
diff --git a/src/util.cs b/src/util.cs
index bb839962..d49ffbb4 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -103,7 +103,7 @@ public class Util
                else 
                        return("OTHER");
        }
-       
+
        //used for load from the database all numbers with correct decimal separator (locale defined)
        //used also for the tvString, tcString, and runIntervalTimesString
        //also used for reading . data coming from force sensor
diff --git a/src/webcamFfmpeg.cs b/src/webcamFfmpeg.cs
index 9d4e03c2..d633ff03 100644
--- a/src/webcamFfmpeg.cs
+++ b/src/webcamFfmpeg.cs
@@ -182,7 +182,7 @@ public class WebcamFfmpeg : Webcam
                        parameters.Insert (i ++, "avfoundation");
 
                parameters.Insert (i ++, "-framerate");
-               if(videoDeviceFramerate != "" && Util.IsNumber(videoDeviceFramerate, false))
+               if(videoDeviceFramerate != "")
                        parameters.Insert (i ++, videoDeviceFramerate);
                else
                        parameters.Insert (i ++, "30");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]