[pitivi] Save the render scale in the export settings.
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Save the render scale in the export settings.
- Date: Sun, 22 May 2011 21:36:43 +0000 (UTC)
commit a8b386f6829d2c669d54ec13dbf96e719218d33a
Author: Alex BÄ?luÈ? <alexandru balut gmail com>
Date: Fri May 20 02:08:53 2011 +0200
Save the render scale in the export settings.
pitivi/formatters/etree.py | 7 +++++--
pitivi/settings.py | 37 ++++++++++++++++++++++++++++---------
pitivi/ui/encodingdialog.py | 22 ++++++----------------
3 files changed, 39 insertions(+), 27 deletions(-)
---
diff --git a/pitivi/formatters/etree.py b/pitivi/formatters/etree.py
index 544113a..c48f915 100644
--- a/pitivi/formatters/etree.py
+++ b/pitivi/formatters/etree.py
@@ -281,6 +281,7 @@ class ElementTreeFormatter(Formatter):
element = Element('export-settings')
element.attrib["videowidth"] = str(int(settings.videowidth))
element.attrib["videoheight"] = str(int(settings.videoheight))
+ element.attrib["render-scale"] = str(int(settings.render_scale))
element.attrib["videorate-num"] = str(int(settings.videorate.num))
element.attrib["videorate-denom"] = str(int(settings.videorate.denom))
element.attrib["videopar-num"] = str(int(settings.videopar.num))
@@ -309,6 +310,8 @@ class ElementTreeFormatter(Formatter):
settings = ExportSettings()
settings.videowidth = int(element.attrib["videowidth"])
settings.videoheight = int(element.attrib["videoheight"])
+ if "render-scale" in element.attrib:
+ settings.render_scale = int(element.attrib["render-scale"])
settings.videorate = gst.Fraction(int(element.attrib["videorate-num"]),
int(element.attrib["videorate-denom"]))
settings.videopar = gst.Fraction(int(element.attrib["videopar-num"]),
@@ -316,8 +319,8 @@ class ElementTreeFormatter(Formatter):
settings.audiochannels = int(element.attrib["audiochannels"])
settings.audiorate = int(element.attrib["audiorate"])
settings.audiodepth = int(element.attrib["audiodepth"])
- settings.aencoder = element.attrib["aencoder"] or None
- settings.vencoder = element.attrib["vencoder"] or None
+ settings.aencoder = element.attrib["aencoder"]
+ settings.vencoder = element.attrib["vencoder"]
settings.muxer = element.attrib["muxer"]
sett = element.find("container-settings")
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 56b6a21..7a3d10e 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -472,6 +472,7 @@ class ExportSettings(Signallable, Loggable):
Loggable.__init__(self)
self.videowidth = 720
self.videoheight = 576
+ self.render_scale = 100
self.videorate = gst.Fraction(25, 1)
self.videopar = gst.Fraction(16, 15)
self.audiochannels = 2
@@ -512,14 +513,26 @@ class ExportSettings(Signallable, Loggable):
msg += _("\nMuxer: ") + str(self.muxer) + " " + str(self.containersettings)
return msg
- def getVideoCaps(self):
+ def getVideoWidthAndHeight(self, render=False):
+ """ Returns the video width and height as a tuple
+
+ @param render: Whether to apply self.render_scale to the returned
+ values.
+ @type render: bool
+ """
+ if render:
+ scale = self.render_scale
+ else:
+ scale = 100
+ return self.videowidth * scale / 100, self.videoheight * scale / 100
+
+ def getVideoCaps(self, render=False):
""" Returns the GstCaps corresponding to the video settings """
- astr = "width=%d,height=%d,pixel-aspect-ratio=%d/%d,framerate=%d/%d" % (self.videowidth,
- self.videoheight,
- self.videopar.num,
- self.videopar.denom,
- self.videorate.num,
- self.videorate.denom)
+ videowidth, videoheight = self.getVideoWidthAndHeight(render=render)
+ astr = "width=%d,height=%d,pixel-aspect-ratio=%d/%d,framerate=%d/%d" % (
+ videowidth, videoheight,
+ self.videopar.num, self.videopar.denom,
+ self.videorate.num, self.videorate.denom)
vcaps = gst.caps_from_string("video/x-raw-yuv,%s;video/x-raw-rgb,%s" % (astr, astr))
if self.vencoder:
return get_compatible_sink_caps(self.vencoder, vcaps)
@@ -535,7 +548,8 @@ class ExportSettings(Signallable, Loggable):
# interset with current audioencoder sink pad caps
- def setVideoProperties(self, width=-1, height=-1, framerate=-1, par=-1):
+ def setVideoProperties(self, width=-1, height=-1, framerate=-1, par=-1,
+ render_scale=-1):
""" Set the video width, height and framerate """
self.info("set_video_props %d x %d @ %r fps", width, height, framerate)
changed = False
@@ -545,6 +559,9 @@ class ExportSettings(Signallable, Loggable):
if not height == -1 and not height == self.videoheight:
self.videoheight = height
changed = True
+ if not render_scale == -1 and not render_scale == self.render_scale:
+ self.render_scale = render_scale
+ changed = True
if not framerate == -1 and not framerate == self.videorate:
self.videorate = framerate
changed = True
@@ -621,9 +638,11 @@ class ExportSettings(Signallable, Loggable):
def export_settings_to_render_settings(export,
have_video=True, have_audio=True):
+ """Convert the specified ExportSettings object to a RenderSettings object.
+ """
# Get the audio and video caps/encoder/settings
astream = get_stream_for_caps(export.getAudioCaps())
- vstream = get_stream_for_caps(export.getVideoCaps())
+ vstream = get_stream_for_caps(export.getVideoCaps(render=True))
encoder_settings = []
if export.vencoder is not None and have_video:
diff --git a/pitivi/ui/encodingdialog.py b/pitivi/ui/encodingdialog.py
index db671f0..1715eb9 100644
--- a/pitivi/ui/encodingdialog.py
+++ b/pitivi/ui/encodingdialog.py
@@ -144,14 +144,11 @@ class EncodingDialog(GladeWindow, Renderer, Loggable):
self.updateResolution()
def _displaySettings(self):
- self.width = self.settings.videowidth
- self.height = self.settings.videoheight
-
# Video settings
self.frame_rate_combo.set_model(frame_rates)
set_combo_value(self.frame_rate_combo, self.settings.videorate)
- self.scale_spinbutton.set_value(100)
- self.updateResolution()
+ # note: this will trigger an update of the video resolution label
+ self.scale_spinbutton.set_value(self.settings.render_scale)
# Audio settings
self.channels_combo.set_model(audio_channels)
@@ -215,28 +212,21 @@ class EncodingDialog(GladeWindow, Renderer, Loggable):
self.audio_encoder_combo, preferred_aencoder, default_index=0)
def _scaleSpinbuttonChangedCb(self, button):
- width, height = self.updateResolution()
- self.settings.setVideoProperties(width=width, height=height)
+ render_scale = self.scale_spinbutton.get_value()
+ self.settings.setVideoProperties(render_scale=render_scale)
+ self.updateResolution()
def updateResolution(self):
- scale = self.scale_spinbutton.get_value() / 100
- width = int(self.width * scale)
- height = int(self.height * scale)
+ width, height = self.settings.getVideoWidthAndHeight(render=True)
self.resolution_label.set_text("%d x %d" % (width, height))
- return width, height
def _projectSettingsButtonClickedCb(self, button):
from pitivi.ui.projectsettings import ProjectSettingsDialog
- self.settings.setVideoProperties(width=self.width, height=self.height)
d = ProjectSettingsDialog(self.window, self.project)
d.window.connect("destroy", self._projectSettingsDestroyCb)
d.show()
def _projectSettingsDestroyCb(self, dialog):
- self.width = self.settings.videowidth
- self.height = self.settings.videoheight
- width, height = self.updateResolution()
- self.settings.setVideoProperties(width=width, height=height)
self._displaySettings()
def _frameRateComboChangedCb(self, combo):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]