[istanbul] Box any non divisible by 8 areas by adding a black border. Only use videoscale if we are actually sc



commit da26cfc21caf02a8d4159c36063124bc30919145
Author: Zaheer Merali <zaheermerali gmail com>
Date:   Thu Mar 25 19:02:31 2010 +0100

    Box any non divisible by 8 areas by adding a black border.
    Only use videoscale if we are actually scaling.

 istanbul/main/screencast.py |   41 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/istanbul/main/screencast.py b/istanbul/main/screencast.py
index 5944180..a316371 100644
--- a/istanbul/main/screencast.py
+++ b/istanbul/main/screencast.py
@@ -49,6 +49,10 @@ class Screencast:
         screen = Screen().current
         width = screen.get_width()
         height = screen.get_height()
+        box_left = 0
+        box_right = 0
+        box_top = 0
+        box_bottom = 0
         display_name = screen.get_display().get_name()
         screen_number = screen.get_number()
         if not settings:
@@ -63,13 +67,32 @@ class Screencast:
                 area_y1, area_y2 = area_y2, area_y1
             width = area_x2 - area_x1 - 1
             height = area_y2 - area_y1 - 1
-
+        scaling_needed = False
         if settings["video_size"] == "half":
             width = width / 2
             height = height / 2
+            scaling_needed = True
         elif settings["video_size"] == "quarter":
             width = width / 4
             height = height / 4
+            scaling_needed = True
+
+        if width % 8 > 0:
+            whatsleft = 8 - width % 8
+            box_left = int(whatsleft / 2)
+            box_right = whatsleft - box_left
+            print "whatsleft %d boxing left wth %d and right with %d" % (whatsleft, box_left,
+                box_right)
+            box_left = -box_left
+            box_right = -box_right
+        if height % 8 > 0:
+            whatsleft = 8 - height % 8
+            box_top = int(whatsleft / 2)
+            box_bottom = whatsleft - box_top
+            print "whatsleft %d boxing top wth %d and bottom with %d" % (whatsleft, box_top,
+                box_bottom)
+            box_top = -box_top
+            box_bottom = -box_bottom
 
         videoscale_method = 1
 
@@ -94,8 +117,10 @@ class Screencast:
             vsource = "%s show-pointer=false" % vsource
 
         vcappipeline = '%s ! video/x-raw-rgb,framerate=%s ! videorate ! '\
-            'ffmpegcolorspace ! videoscale method=%d' % (vsource,
-                framerate, videoscale_method)
+            'ffmpegcolorspace'  % (vsource,
+                framerate)
+        if scaling_needed:
+            vcappipeline += " ! videoscale method=%d" % (videoscale_method)
         acappipeline = ''
         asource = ''
         if settings["record_sound"]:
@@ -105,8 +130,14 @@ class Screencast:
                 asource = 'alsasrc name=audiosource'
             acappipeline = '%s ! audioconvert ! vorbisenc' % asource
 
-        vencode_pipeline = 'video/x-raw-yuv,width=%d,height=%d,framerate=%s '\
-            '! theoraenc quality=63 sharpness=2 ' % (width, height, framerate)
+        vbox_pipeline = ""
+        if box_left + box_right + box_bottom + box_top != 0:
+            vbox_pipeline = \
+                " ! videobox left=%d right=%d top=%d bottom=%d " % (
+                box_left, box_right, box_top, box_bottom)
+        vencode_pipeline = 'video/x-raw-yuv,width=%d,height=%d,framerate=%s %s'\
+            '! theoraenc quality=63 sharpness=2 ' % (width, height, framerate,
+            vbox_pipeline)
 
         if settings["record_in_images"]:
             vencode_pipeline = 'pngenc snapshot=false'



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