[pitivi/1.0] render: Remove exception forcing x264enc to work with Y444



commit 0b0b8a2dcbb9d99edc627bf2510f216b0a7a3b30
Author: Thibault Saunier <tsaunier igalia com>
Date:   Wed Apr 4 17:30:09 2018 -0300

    render: Remove exception forcing x264enc to work with Y444
    
    This forces the encoder to output high-4:4:4 which is not well supported
    by hw decoders and youtube will force reencoding when using that profile.
    
    Closes #2182

 pitivi/project.py    | 21 ---------------------
 pitivi/render.py     | 14 +++++++++++---
 tests/test_render.py |  4 ----
 3 files changed, 11 insertions(+), 28 deletions(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index bad39d9f..5ade84a5 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -62,17 +62,6 @@ from pitivi.utils.widgets import FractionWidget
 
 DEFAULT_NAME = _("New Project")
 
-# This is a dictionary to allow adding special restrictions when using a specific
-# encoder element.
-# For example x264enc can't encode frame with odd size if its input format is not Y444
-# so in that case we make sure to force Y444 as x264enc input format.
-ENCODERS_RESTRICTIONS_SETTER = {
-    # To avoid restriction of size in x264enc, make sure that the encoder
-    # input color space is Y444 so that we do not have any restriction
-    "x264enc": lambda project, profile: project._set_restriction(
-        profile, "format", "Y444")
-}
-
 ALL_RAW_VIDEO_FORMATS = []
 # Starting at 2 as 0 is UNKNOWN and 1 is ENCODED.
 # We want to make sure we do not try to force ENCODED
@@ -933,14 +922,6 @@ class Project(Loggable, GES.Project):
             self.audio_profile.set_preset(None)
             self._emit_change("aencoder")
 
-    def _enforce_video_encoder_restrictions(self, encoder, profile=None):
-        """Enforces @encoder specific restrictions."""
-        if not profile:
-            profile = self.video_profile
-        restriction_setter = ENCODERS_RESTRICTIONS_SETTER.get(encoder)
-        if restriction_setter:
-            restriction_setter(self, profile)
-
     @property
     def vencoder(self):
         return self.video_profile.get_preset_name()
@@ -954,7 +935,6 @@ class Project(Loggable, GES.Project):
             self.video_profile.set_preset_name(value)
             # Gst.Preset can be set exclusively through EncodingTagets for now.
             self.video_profile.set_preset(None)
-            self._enforce_video_encoder_restrictions(value)
             self._emit_change("vencoder")
 
     @property
@@ -1713,7 +1693,6 @@ class Project(Loggable, GES.Project):
         profile.set_restriction(restriction)
         profile.set_preset_name(preset_name)
 
-        self._enforce_video_encoder_restrictions(preset_name, profile)
         self.info("Fully set restriction: %s", profile.get_restriction().to_string())
 
     def _ensureVideoRestrictions(self, profile=None):
diff --git a/pitivi/render.py b/pitivi/render.py
index e0c0be22..3ed81737 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -839,12 +839,20 @@ class RenderDialog(Loggable):
         self.dialog.ok_btn.connect(
             "clicked", self._okButtonClickedCb, settings_attr)
 
+    def __additional_debug_info(self, error):
+        if self.project.vencoder == 'x264enc':
+            if self.project.videowidth % 2 or self.project.videoheight % 2:
+                return "\n\n%s\n\n" % _("<b>Make sure your rendering size is even, "
+                         "x264enc might not be able to render otherwise.</b>\n\n")
+
+        return ""
+
     def _showRenderErrorDialog(self, error, unused_details):
         primary_message = _("Sorry, something didn’t work right.")
         secondary_message = _("An error occurred while trying to render your "
-                              "project. You might want to check our "
-                              "troubleshooting guide or file a bug report. "
-                              "The GStreamer error was:") + "\n\n<i>" + str(error) + "</i>"
+                              "project.") + self.__additional_debug_info(str(error)) + (
+            "You might want to check our troubleshooting guide or file a bug report. "
+            "The GStreamer error was:") + "\n\n<i>" + str(error) + "</i>"
 
         dialog = Gtk.MessageDialog(transient_for=self.window, modal=True,
                                    message_type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK,
diff --git a/tests/test_render.py b/tests/test_render.py
index 90e2809b..687e955f 100644
--- a/tests/test_render.py
+++ b/tests/test_render.py
@@ -151,8 +151,6 @@ class TestRender(BaseTestMediaLibrary):
                                         Gst.ElementFactory.find("matroskamux")))
         self.assertTrue(set_combo_value(dialog.video_encoder_combo,
                                         Gst.ElementFactory.find("x264enc")))
-        self.assertEqual(project.video_profile.get_restriction()[0]["format"],
-                         "Y444")
 
         # Set encoding profile
         if getattr(GstPbutils.EncodingProfile, "copy"):  # Available only in > 1.11
@@ -161,8 +159,6 @@ class TestRender(BaseTestMediaLibrary):
                          if isinstance(p, GstPbutils.EncodingVideoProfile)]
             vprofile.set_restriction(Gst.Caps("video/x-raw"))
             project.set_container_profile(profile)
-            self.assertEqual(project.video_profile.get_restriction()[0]["format"],
-                             "Y444")
 
     @skipUnless(*factory_exists("vorbisenc", "theoraenc", "oggmux",
                                 "opusenc", "vp8enc"))


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