Quellcode durchsuchen

wxGUI/animation: let the user enter options for creating AVI (different ffmpeg versions require different options)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58210 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová vor 11 Jahren
Ursprung
Commit
0cb3a75c41
2 geänderte Dateien mit 22 neuen und 2 gelöschten Zeilen
  1. 1 1
      gui/wxpython/animation/controller.py
  2. 21 1
      gui/wxpython/animation/dialogs.py

+ 1 - 1
gui/wxpython/animation/controller.py

@@ -557,7 +557,7 @@ class AnimationController(wx.EvtHandler):
                 writeAvi(filename=exportInfo['file'], images=pilImages,
                 writeAvi(filename=exportInfo['file'], images=pilImages,
                             duration=self.timeTick / float(1000),
                             duration=self.timeTick / float(1000),
                             encoding=exportInfo['encoding'],
                             encoding=exportInfo['encoding'],
-                            inputOptions='-sameq')
+                            inputOptions=exportInfo['options'])
         except Exception, e:
         except Exception, e:
             del busy
             del busy
             GError(parent=self.frame, message=str(e))
             GError(parent=self.frame, message=str(e))

+ 21 - 1
gui/wxpython/animation/dialogs.py

@@ -40,6 +40,8 @@ from utils import TemporalMode, getRegisteredMaps, validateTimeseriesName, valid
 from nviztask import NvizTask
 from nviztask import NvizTask
 
 
 from grass.pydispatch.signal import Signal
 from grass.pydispatch.signal import Signal
+import grass.script.core as gcore
+
 
 
 class SpeedDialog(wx.Dialog):
 class SpeedDialog(wx.Dialog):
     def __init__(self, parent, title = _("Adjust speed of animation"),
     def __init__(self, parent, title = _("Adjust speed of animation"),
@@ -1019,7 +1021,7 @@ class ExportDialog(wx.Dialog):
         helpSizer = wx.BoxSizer(wx.HORIZONTAL)
         helpSizer = wx.BoxSizer(wx.HORIZONTAL)
         helpSizer.AddStretchSpacer(1)
         helpSizer.AddStretchSpacer(1)
         self.formatPanelSizer = wx.BoxSizer(wx.VERTICAL)
         self.formatPanelSizer = wx.BoxSizer(wx.VERTICAL)
-        helpSizer.Add(self.formatPanelSizer, proportion = 5)
+        helpSizer.Add(self.formatPanelSizer, proportion=5, flag=wx.EXPAND)
         borderSizer.Add(helpSizer, proportion = 1, flag = wx.EXPAND)
         borderSizer.Add(helpSizer, proportion = 1, flag = wx.EXPAND)
         self.formatPanels = []
         self.formatPanels = []
 
 
@@ -1087,6 +1089,12 @@ class ExportDialog(wx.Dialog):
 
 
         # panel for avi
         # panel for avi
         aviPanel = wx.Panel(parent = panel, id = wx.ID_ANY)
         aviPanel = wx.Panel(parent = panel, id = wx.ID_ANY)
+        ffmpeg = gcore.find_program('ffmpeg', '--help')
+        if not ffmpeg:
+            warning = _("Program 'ffmpeg' was not found.\nPlease install it first "
+                        "and make sure\nit's in the PATH variable.")
+            warningLabel = wx.StaticText(parent=aviPanel, label=warning)
+            warningLabel.SetForegroundColour(wx.RED)
         self.aviBrowse = filebrowse.FileBrowseButton(parent = aviPanel, id = wx.ID_ANY,
         self.aviBrowse = filebrowse.FileBrowseButton(parent = aviPanel, id = wx.ID_ANY,
                                                      fileMask = "AVI file (*.avi)|*.avi",
                                                      fileMask = "AVI file (*.avi)|*.avi",
                                                      labelText = _("AVI file:"),
                                                      labelText = _("AVI file:"),
@@ -1095,11 +1103,22 @@ class ExportDialog(wx.Dialog):
                                                      startDirectory = os.getcwd(), fileMode = wx.SAVE)
                                                      startDirectory = os.getcwd(), fileMode = wx.SAVE)
         encodingLabel = wx.StaticText(parent = aviPanel, id = wx.ID_ANY, label = _("Video codec:"))
         encodingLabel = wx.StaticText(parent = aviPanel, id = wx.ID_ANY, label = _("Video codec:"))
         self.encodingText = wx.TextCtrl(parent = aviPanel, id = wx.ID_ANY, value = 'mpeg4')
         self.encodingText = wx.TextCtrl(parent = aviPanel, id = wx.ID_ANY, value = 'mpeg4')
+        optionsLabel = wx.StaticText(parent=aviPanel, label=_("Additional options:"))
+        self.optionsText = wx.TextCtrl(parent=aviPanel)
+        self.optionsText.SetToolTipString(_("Consider adding '-sameq' or '-qscale 1' "
+                                            "if not satisfied with video quality. "
+                                            "Options depend on ffmpeg version."))
         aviGridSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
         aviGridSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
         aviGridSizer.AddGrowableCol(1)
         aviGridSizer.AddGrowableCol(1)
         aviGridSizer.Add(self.aviBrowse, pos = (0, 0), span = (1, 2), flag = wx.EXPAND)
         aviGridSizer.Add(self.aviBrowse, pos = (0, 0), span = (1, 2), flag = wx.EXPAND)
         aviGridSizer.Add(encodingLabel, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
         aviGridSizer.Add(encodingLabel, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
         aviGridSizer.Add(self.encodingText, pos = (1, 1), flag = wx.EXPAND)
         aviGridSizer.Add(self.encodingText, pos = (1, 1), flag = wx.EXPAND)
+        aviGridSizer.Add(optionsLabel, pos=(2, 0), flag=wx.ALIGN_CENTER_VERTICAL)
+        aviGridSizer.Add(self.optionsText, pos=(2, 1), flag=wx.EXPAND)
+        if not ffmpeg:
+            aviGridSizer.Add(warningLabel, pos=(3, 0), span=(1, 2),
+                             flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
+
         aviPanel.SetSizer(aviGridSizer)
         aviPanel.SetSizer(aviGridSizer)
         aviGridSizer.Fit(aviPanel)
         aviGridSizer.Fit(aviPanel)
 
 
@@ -1277,6 +1296,7 @@ class ExportDialog(wx.Dialog):
             info['method'] = 'avi'
             info['method'] = 'avi'
             info['file'] = self.aviBrowse.GetValue()
             info['file'] = self.aviBrowse.GetValue()
             info['encoding'] = self.encodingText.GetValue()
             info['encoding'] = self.encodingText.GetValue()
+            info['options'] = self.optionsText.GetValue()
 
 
         return info
         return info