[pitivi: 2/9] Fix single stream encoding. Fixes #573897.



commit 39e4f573789fddb24626d3a9902059fea95af23d
Author: Alessandro Decina <alessandro decina collabora co uk>
Date:   Tue Mar 3 16:42:45 2009 +0100

    Fix single stream encoding. Fixes #573897.
---
 pitivi/project.py           |   30 ++++++++++++++++++------------
 pitivi/settings.py          |   21 ++++++++++++++-------
 pitivi/ui/encodingdialog.py |    8 ++++++--
 3 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/pitivi/project.py b/pitivi/project.py
index 538428c..6689ee9 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -271,20 +271,26 @@ class Project(Serializable, Signallable, Loggable):
         If it has more than one, it will return the largest setting that suits
         all contained sources.
         """
+        settings = ExportSettings()
         if not self.timeline:
             self.warning("project doesn't have a timeline, returning default settings")
-            return ExportSettings()
-        #settings = self.timeline.getAutoSettings()
-        settings = None
-        if not settings:
-            self.warning("Timeline didn't return any auto settings, return default settings")
-            return ExportSettings()
-
-        # add the encoders and muxer of the default settings
-        curset = self.settings or ExportSettings()
-        settings.vencoder = curset.vencoder
-        settings.aencoder = curset.aencoder
-        settings.muxer = curset.muxer
+            return settings
+
+        # FIXME: this is ugly, but rendering for now assumes at most one audio
+        # and one video tracks
+        have_audio = have_video = False
+        for track in self.timeline.tracks:
+            if isinstance(track.stream, VideoStream) and track.duration != 0:
+                have_video = True
+            elif isinstance(track.stream, AudioStream) and track.duration != 0:
+                have_audio = True
+
+        if not have_audio:
+            settings.aencoder = None
+
+        if not have_video:
+            settings.vencoder = None
+
         return settings
 
     def setModificationState(self, state):
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 0862283..ec6f8c2 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -581,13 +581,20 @@ def export_settings_to_render_settings(export):
     astream = get_stream_for_caps(export.getAudioCaps())
     vstream = get_stream_for_caps(export.getVideoCaps())
 
-    vset = StreamEncodeSettings(encoder=export.vencoder,
-                                input_stream=vstream,
-                                encodersettings=export.vcodecsettings)
-    aset = StreamEncodeSettings(encoder=export.aencoder,
-                                input_stream=astream,
-                                encodersettings=export.acodecsettings)
-    settings = RenderSettings(settings=[vset, aset],
+    encoder_settings = []
+    if export.vencoder is not None:
+        vset = StreamEncodeSettings(encoder=export.vencoder,
+                                    input_stream=vstream,
+                                    encodersettings=export.vcodecsettings)
+        encoder_settings.append(vset)
+
+    if export.aencoder is not None:
+        aset = StreamEncodeSettings(encoder=export.aencoder,
+                                    input_stream=astream,
+                                    encodersettings=export.acodecsettings)
+        encoder_settings.append(aset)
+
+    settings = RenderSettings(settings=encoder_settings,
                               muxer=export.muxer,
                               muxersettings=export.containersettings)
     return settings
diff --git a/pitivi/ui/encodingdialog.py b/pitivi/ui/encodingdialog.py
index 119af1e..7238f1c 100644
--- a/pitivi/ui/encodingdialog.py
+++ b/pitivi/ui/encodingdialog.py
@@ -36,6 +36,7 @@ from pitivi.ui.glade import GladeWindow
 from pitivi.action import render_action_for_uri, ViewAction
 from pitivi.factories.base import SourceFactory
 from pitivi.settings import export_settings_to_render_settings
+from pitivi.stream import AudioStream, VideoStream
 
 class EncodingDialog(GladeWindow, Loggable):
     """ Encoding dialog box """
@@ -76,8 +77,11 @@ class EncodingDialog(GladeWindow, Loggable):
         self.destroy()
 
     def _displaySettings(self):
-        self.vinfo.set_markup(self.settings.getVideoDescription())
-        self.ainfo.set_markup(self.settings.getAudioDescription())
+        if self.settings.vencoder:
+            self.vinfo.set_markup(self.settings.getVideoDescription())
+
+        if self.settings.aencoder:
+            self.ainfo.set_markup(self.settings.getAudioDescription())
 
     def _fileButtonClickedCb(self, button):
         dialog = gtk.FileChooserDialog(title=_("Choose file to render to"),



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