[pitivi] Make rendering video only or audio only work again. Partly fixes #584135.



commit 23ec69353ceb2f7a40a00c8dd7c5e95558559be7
Author: Alessandro Decina <alessandro d gmail com>
Date:   Sun Feb 21 00:53:00 2010 +0100

    Make rendering video only or audio only work again. Partly fixes #584135.

 pitivi/settings.py          |    7 ++++---
 pitivi/ui/encodingdialog.py |   22 ++++++++++++++++++----
 2 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 47d527c..20c768f 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -588,19 +588,20 @@ class ExportSettings(Signallable, Loggable):
         if changed:
             self.emit("encoders-changed")
 
-def export_settings_to_render_settings(export):
+def export_settings_to_render_settings(export,
+        have_video=True, have_audio=True):
     # Get the audio and video caps/encoder/settings
     astream = get_stream_for_caps(export.getAudioCaps())
     vstream = get_stream_for_caps(export.getVideoCaps())
 
     encoder_settings = []
-    if export.vencoder is not None:
+    if export.vencoder is not None and have_video:
         vset = StreamEncodeSettings(encoder=export.vencoder,
                                     input_stream=vstream,
                                     encodersettings=export.vcodecsettings)
         encoder_settings.append(vset)
 
-    if export.aencoder is not None:
+    if export.aencoder is not None and have_audio:
         aset = StreamEncodeSettings(encoder=export.aencoder,
                                     input_stream=astream,
                                     encodersettings=export.acodecsettings)
diff --git a/pitivi/ui/encodingdialog.py b/pitivi/ui/encodingdialog.py
index 53bd368..45d9f95 100644
--- a/pitivi/ui/encodingdialog.py
+++ b/pitivi/ui/encodingdialog.py
@@ -38,8 +38,9 @@ from pitivi.ui.exportsettingswidget import ExportSettingsDialog
 from pitivi.ui.glade import GladeWindow
 from pitivi.action import render_action_for_uri, ViewAction
 from pitivi.factories.base import SourceFactory
+from pitivi.factories.timeline import TimelineSourceFactory
 from pitivi.settings import export_settings_to_render_settings
-from pitivi.stream import AudioStream, VideoStream
+from pitivi.stream import VideoStream, AudioStream
 from pitivi.utils import beautify_length
 
 class EncodingDialog(GladeWindow, Loggable):
@@ -174,10 +175,23 @@ class EncodingDialog(GladeWindow, Loggable):
             self.pipeline.connect('eos', self._eosCb)
             self.debug("Setting pipeline to STOP")
             self.pipeline.stop()
-            settings = export_settings_to_render_settings(self.settings)
-            sources = [x for x in self.pipeline.factories if isinstance(x, SourceFactory)]
+
+            # we can only render TimelineSourceFactory
+            timeline_source = self.pipeline.factories.keys()[0]
+            assert isinstance(timeline_source, TimelineSourceFactory)
+            have_video = False
+            have_audio = False
+            for track in timeline_source.timeline.tracks:
+                if isinstance(track.stream, AudioStream) and track.duration > 0:
+                    have_audio = True
+                elif isinstance(track.stream, VideoStream) and \
+                        track.duration > 0:
+                    have_video = True
+            settings = export_settings_to_render_settings(self.settings,
+                    have_video, have_audio)
             self.debug("Creating RenderAction")
-            self.renderaction = render_action_for_uri(self.outfile, settings, *sources)
+            self.renderaction = render_action_for_uri(self.outfile,
+                    settings, timeline_source)
             self.debug("setting action on pipeline")
             self.pipeline.addAction(self.renderaction)
             self.debug("Activating render action")



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