Esempio n. 1
0
 def vcodec_setter(self, widget, vencoder_name):
     set_combo_value(widget,
                     Encoders().factories_by_name.get(vencoder_name))
     self.project.setEncoders(vencoder=vencoder_name)
     if not self.muxer_combo_changing:
         # The user directly changed the video encoder combo.
         self.preferred_vencoder = vencoder_name
Esempio n. 2
0
    def test_encoder_restrictions(self):
        """Checks the mechanism to respect encoder specific restrictions."""
        project = self.create_simple_project()
        dialog = self.create_rendering_dialog(project)

        # Explicitly set the encoder
        self.assertTrue(
            set_combo_value(dialog.muxer_combo,
                            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
            profile = project.container_profile.copy()
            vprofile, = [
                p for p in profile.get_profiles()
                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")
Esempio n. 3
0
 def acodec_setter(self, widget, aencoder_name):
     set_combo_value(widget,
                     Encoders().factories_by_name.get(aencoder_name))
     self.project.aencoder = aencoder_name
     if not self.muxer_combo_changing:
         # The user directly changed the audio encoder combo.
         self.preferred_aencoder = aencoder_name
Esempio n. 4
0
 def _displayRenderSettings(self):
     """Display the settings which can be changed only in the RenderDialog.
     """
     # Video settings
     # note: this will trigger an update of the video resolution label
     self.scale_spinbutton.set_value(self.project.render_scale)
     # Muxer settings
     # note: this will trigger an update of the codec comboboxes
     set_combo_value(self.muxercombobox, Gst.ElementFactory.find(self.project.muxer))
Esempio n. 5
0
 def _displayRenderSettings(self):
     """Displays the settings available only in the RenderDialog."""
     # Video settings
     # This will trigger an update of the video resolution label.
     self.scale_spinbutton.set_value(self.project.render_scale)
     # Muxer settings
     # This will trigger an update of the codec comboboxes.
     set_combo_value(self.muxer_combo,
                     Encoders().factories_by_name.get(self.project.muxer))
Esempio n. 6
0
 def _displayRenderSettings(self):
     """Displays the settings available only in the RenderDialog."""
     # Video settings
     # This will trigger an update of the video resolution label.
     self.scale_spinbutton.set_value(self.project.render_scale)
     # Muxer settings
     # This will trigger an update of the codec comboboxes.
     set_combo_value(self.muxercombobox,
                     Gst.ElementFactory.find(self.project.muxer))
Esempio n. 7
0
 def _displayRenderSettings(self):
     """Displays the settings available only in the RenderDialog."""
     # Video settings
     # This will trigger an update of the video resolution label.
     self.scale_spinbutton.set_value(self.project.render_scale)
     # Muxer settings
     # This will trigger an update of the codec comboboxes.
     set_combo_value(self.muxer_combo,
                     Encoders().factories_by_name.get(self.project.muxer))
Esempio n. 8
0
    def muxer_setter(self, widget, muxer_name):
        set_combo_value(widget, Encoders().factories_by_name.get(muxer_name))
        self.project.setEncoders(muxer=muxer_name)

        # Update the extension of the filename.
        basename = os.path.splitext(self.fileentry.get_text())[0]
        self.updateFilename(basename)

        # Update muxer-dependent widgets.
        self.updateAvailableEncoders()
Esempio n. 9
0
 def _displayRenderSettings(self):
     """Display the settings which can be changed only in the RenderDialog.
     """
     # Video settings
     # note: this will trigger an update of the video resolution label
     self.scale_spinbutton.set_value(self.project.render_scale)
     # Muxer settings
     # note: this will trigger an update of the codec comboboxes
     set_combo_value(self.muxercombobox,
         Gst.ElementFactory.find(self.project.muxer))
Esempio n. 10
0
    def muxer_setter(self, widget, muxer_name):
        set_combo_value(widget, Encoders().factories_by_name.get(muxer_name))
        self.project.setEncoders(muxer=muxer_name)

        # Update the extension of the filename.
        basename = os.path.splitext(self.fileentry.get_text())[0]
        self.updateFilename(basename)

        # Update muxer-dependent widgets.
        self.updateAvailableEncoders()
Esempio n. 11
0
 def _updateEncoderCombo(self, encoder_combo, preferred_encoder):
     """Selects the specified encoder for the specified encoder combo."""
     if preferred_encoder:
         # A preference exists, pick it if it can be found in
         # the current model of the combobox.
         vencoder = Gst.ElementFactory.find(preferred_encoder)
         set_combo_value(encoder_combo, vencoder, default_index=0)
     else:
         # No preference exists, pick the first encoder from
         # the current model of the combobox.
         encoder_combo.set_active(0)
Esempio n. 12
0
 def _updateEncoderCombo(self, encoder_combo, preferred_encoder):
     """Select the specified encoder for the specified encoder combo."""
     if preferred_encoder:
         # A preference exists, pick it if it can be found in
         # the current model of the combobox.
         vencoder = Gst.ElementFactory.find(preferred_encoder)
         set_combo_value(encoder_combo, vencoder, default_index=0)
     else:
         # No preference exists, pick the first encoder from
         # the current model of the combobox.
         encoder_combo.set_active(0)
Esempio n. 13
0
    def muxer_setter(self, widget, value):
        set_combo_value(widget, Gst.ElementFactory.find(value))
        self.project.setEncoders(muxer=value)

        # Update the extension of the filename.
        basename = os.path.splitext(self.fileentry.get_text())[0]
        self.updateFilename(basename)

        # Update muxer-dependent widgets.
        self.muxer_combo_changing = True
        try:
            self.updateAvailableEncoders()
        finally:
            self.muxer_combo_changing = False
Esempio n. 14
0
    def muxer_setter(self, widget, value):
        set_combo_value(widget, Gst.ElementFactory.find(value))
        self.project.setEncoders(muxer=value)

        # Update the extension of the filename.
        basename = os.path.splitext(self.fileentry.get_text())[0]
        self.updateFilename(basename)

        # Update muxer-dependent widgets.
        self.muxer_combo_changing = True
        try:
            self.updateAvailableEncoders()
        finally:
            self.muxer_combo_changing = False
Esempio n. 15
0
 def _displaySettings(self):
     """Display the settings that also change in the ProjectSettingsDialog.
     """
     # Video settings
     set_combo_value(self.frame_rate_combo, self.project.videorate)
     # Audio settings
     set_combo_value(self.channels_combo, self.project.audiochannels)
     set_combo_value(self.sample_rate_combo, self.project.audiorate)
     set_combo_value(self.sample_depth_combo, self.project.audiodepth)
Esempio n. 16
0
    def test_encoder_restrictions(self):
        """Checks the mechanism to respect encoder specific restrictions."""
        project = self.create_simple_project()
        dialog = self.create_rendering_dialog(project)

        # Explicitly set the encoder
        self.assertTrue(set_combo_value(dialog.muxer_combo,
                                        Gst.ElementFactory.find("matroskamux")))
        self.assertTrue(set_combo_value(dialog.video_encoder_combo,
                                        Gst.ElementFactory.find("x264enc")))

        # Set encoding profile
        if getattr(GstPbutils.EncodingProfile, "copy"):  # Available only in > 1.11
            profile = project.container_profile.copy()
            vprofile, = [p for p in profile.get_profiles()
                         if isinstance(p, GstPbutils.EncodingVideoProfile)]
            vprofile.set_restriction(Gst.Caps("video/x-raw"))
            project.set_container_profile(profile)
Esempio n. 17
0
 def _update_encoder_combo(self, encoder_combo, preferred_encoder):
     """Selects the specified encoder for the specified encoder combo."""
     if preferred_encoder:
         # A preference exists, pick it if it can be found in
         # the current model of the combobox.
         encoder = Encoders().factories_by_name.get(preferred_encoder)
         set_combo_value(encoder_combo, encoder)
     if not preferred_encoder or not get_combo_value(encoder_combo):
         # No preference exists or it is not available,
         # pick the first encoder from the combobox's model.
         first = encoder_combo.props.model.get_iter_first()
         if not first:
             # Model is empty. Should not happen.
             self.warning("Model is empty")
             return
         if not encoder_combo.props.model.iter_has_child(first):
             # The first item is a supported factory.
             encoder_combo.set_active_iter(first)
         else:
             # The first element is the Unsupported group.
             second = encoder_combo.props.model.iter_nth_child(first, 0)
             encoder_combo.set_active_iter(second)
Esempio n. 18
0
 def _update_encoder_combo(self, encoder_combo, preferred_encoder):
     """Selects the specified encoder for the specified encoder combo."""
     if preferred_encoder:
         # A preference exists, pick it if it can be found in
         # the current model of the combobox.
         encoder = Encoders().factories_by_name.get(preferred_encoder)
         set_combo_value(encoder_combo, encoder)
     if not preferred_encoder or not get_combo_value(encoder_combo):
         # No preference exists or it is not available,
         # pick the first encoder from the combobox's model.
         first = encoder_combo.props.model.get_iter_first()
         if not first:
             # Model is empty. Should not happen.
             self.warning("Model is empty")
             return
         if not encoder_combo.props.model.iter_has_child(first):
             # The first item is a supported factory.
             encoder_combo.set_active_iter(first)
         else:
             # The first element is the Unsupported group.
             second = encoder_combo.props.model.iter_nth_child(first, 0)
             encoder_combo.set_active_iter(second)
Esempio n. 19
0
    def _update_valid_restriction_values(self, caps, combo, caps_template,
                               model, value,
                               caps_template_expander=None):
        def caps_template_expander_func(caps_template, value):
            return caps_template % value

        if not caps_template_expander:
            caps_template_expander = caps_template_expander_func

        model_headers = [model.get_column_type(i) for i in range(model.get_n_columns())]
        reduced_model = Gtk.ListStore(*model_headers)
        for name, value in dict(model).items():
            ecaps = Gst.Caps(caps_template_expander(caps_template, value))
            if not caps.intersect(ecaps).is_empty():
                reduced_model.append((name, value))

        combo.set_model(reduced_model)

        set_combo_value(combo, value)
        if get_combo_value(combo) != value:
            combo.set_active(len(reduced_model) - 1)
            self.warning("%s in %s not supported, setting: %s",
                value, caps_template, get_combo_value(combo))
Esempio n. 20
0
    def test_preset_reset_when_changing_muxer(self):
        """Tests setting the container profile manually."""
        project = self.create_simple_project()
        dialog = self.create_rendering_dialog(project)
        self.select_render_preset(dialog, "youtube")

        # The container and video encoder profiles in the "youtube"
        # EncodingTarget are "qtmux" and "x264enc". They have a common
        # "preset" called "Profile YouTube".
        # When changing the container manually from qt4mux to mp4mux
        # the container profile's "preset" needs to be reset, otherwise
        # rendering will hang because mp4mux is missing the
        # "Profile YouTube" preset.
        self.assertTrue(
            set_combo_value(dialog.muxer_combo,
                            Gst.ElementFactory.find("mp4mux")))

        self.render(dialog)
Esempio n. 21
0
    def updateUI(self):

        self.width_spinbutton.set_value(self.settings.videowidth)
        self.height_spinbutton.set_value(self.settings.videoheight)

        # video
        self.frame_rate_fraction_widget.setWidgetValue(self.settings.videorate)
        self.par_fraction_widget.setWidgetValue(self.settings.videopar)

        # audio
        set_combo_value(self.channels_combo, self.settings.audiochannels)
        set_combo_value(self.sample_rate_combo, self.settings.audiorate)
        set_combo_value(self.sample_depth_combo, self.settings.audiodepth)

        self._selectDarRadiobuttonToggledCb(self.select_dar_radiobutton)

        # metadata
        self.title_entry.set_text(self.project.name)
        self.author_entry.set_text(self.project.author)
        if self.project.year:
            year = int(self.project.year)
        else:
            year = datetime.now().year
        self.year_spinbutton.get_adjustment().set_value(year)
Esempio n. 22
0
 def channels_setter(self, widget, value):
     set_combo_value(widget, value)
     self.settings.setAudioProperties(nbchanns=value)
Esempio n. 23
0
 def framerate_setter(self, widget, value):
     self.project.videorate = set_combo_value(widget, value)
Esempio n. 24
0
 def channels_setter(self, widget, value):
     self.project.audiochannels = set_combo_value(widget, value)
Esempio n. 25
0
 def sample_rate_setter(self, widget, value):
     self.project.audiorate = set_combo_value(widget, value)
Esempio n. 26
0
 def vcodec_setter(self, widget, value):
     set_combo_value(widget, Gst.ElementFactory.find(value))
     self.project.setEncoders(vencoder=value)
     if not self.muxer_combo_changing:
         # The user directly changed the video encoder combo.
         self.preferred_vencoder = value
Esempio n. 27
0
 def sample_depth_setter(self, widget, value):
     set_combo_value(widget, value)
     self.settings.setAudioProperties(depth=value)
Esempio n. 28
0
 def channels_setter(self, widget, value):
     set_combo_value(widget, value)
     self.project.audiochannels = value
Esempio n. 29
0
    def test_quality_widget(self):
        project = self.create_simple_project()
        dialog = self.create_rendering_dialog(project)
        self.check_quality_widget(dialog,
                                  vencoder="x264enc",
                                  vcodecsettings={
                                      "quantizer": 21,
                                      "pass": 5
                                  },
                                  preset="youtube",
                                  sensitive=True,
                                  value=Quality.MEDIUM)

        self.assertEqual(project.video_profile.get_preset_name(), "x264enc")
        dialog.quality_adjustment.props.value = Quality.HIGH
        self.check_quality_widget(dialog,
                                  vencoder="x264enc",
                                  vcodecsettings={
                                      "quantizer": 18,
                                      "pass": 5
                                  },
                                  preset="youtube",
                                  sensitive=True,
                                  value=Quality.HIGH)

        self.select_render_preset(dialog, "dvd")
        self.check_quality_widget(dialog,
                                  vencoder=None,
                                  vcodecsettings={},
                                  preset="dvd",
                                  sensitive=False,
                                  value=Quality.LOW)

        self.select_render_preset(dialog, "youtube")
        self.assertEqual(project.video_profile.get_preset_name(), "x264enc")
        self.check_quality_widget(dialog,
                                  vencoder="x264enc",
                                  vcodecsettings={
                                      "quantizer": 21,
                                      "pass": 5
                                  },
                                  preset="youtube",
                                  sensitive=True,
                                  value=Quality.MEDIUM)

        self.assertTrue(
            set_combo_value(dialog.video_encoder_combo,
                            Gst.ElementFactory.find("pngenc")))
        self.check_quality_widget(dialog,
                                  vencoder="pngenc",
                                  vcodecsettings={},
                                  preset=None,
                                  sensitive=False,
                                  value=Quality.LOW)

        self.select_render_preset(dialog, "youtube")
        self.check_quality_widget(dialog,
                                  vencoder="x264enc",
                                  vcodecsettings={
                                      "quantizer": 21,
                                      "pass": 5
                                  },
                                  preset="youtube",
                                  sensitive=True,
                                  value=Quality.MEDIUM)
Esempio n. 30
0
 def acodec_setter(self, widget, aencoder_name):
     set_combo_value(widget, Encoders().factories_by_name.get(aencoder_name))
     self.project.aencoder = aencoder_name
     if not self.muxer_combo_changing:
         # The user directly changed the audio encoder combo.
         self.preferred_aencoder = aencoder_name
Esempio n. 31
0
 def _updateCombo(self, unused, combo, fraction):
     set_combo_value(combo, fraction.getWidgetValue())
Esempio n. 32
0
 def bindCombo(self, mgr, name, widget):
     mgr.bindWidget(name,
         lambda x: set_combo_value(widget, x),
         lambda: get_combo_value(widget))
Esempio n. 33
0
 def vcodec_setter(self, widget, vencoder_name):
     set_combo_value(widget, Encoders().factories_by_name.get(vencoder_name))
     self.project.setEncoders(vencoder=vencoder_name)
     if not self.muxer_combo_changing:
         # The user directly changed the video encoder combo.
         self.preferred_vencoder = vencoder_name
Esempio n. 34
0
 def sample_rate_setter(self, widget, value):
     set_combo_value(widget, value)
     self.settings.setAudioProperties(rate=value)
Esempio n. 35
0
 def acodec_setter(self, widget, value):
     set_combo_value(widget, gst.element_factory_find(value))
     self.settings.setEncoders(aencoder=value)
     if not self.muxer_combo_changing:
         # The user directly changed the audio encoder combo.
         self.preferred_aencoder = value
Esempio n. 36
0
 def acodec_setter(self, widget, value):
     set_combo_value(widget, Gst.ElementFactory.find(value))
     self.project.aencoder = value
     if not self.muxer_combo_changing:
         # The user directly changed the audio encoder combo.
         self.preferred_aencoder = value
Esempio n. 37
0
 def sample_depth_setter(self, widget, value):
     self.project.audiodepth = set_combo_value(widget, value)
Esempio n. 38
0
 def sample_rate_setter(self, widget, value):
     set_combo_value(widget, value)
     self.project.audiorate = value
Esempio n. 39
0
 def framerate_setter(self, widget, value):
     set_combo_value(widget, value)
     self.settings.setVideoProperties(framerate=value)
Esempio n. 40
0
 def framerate_setter(self, widget, value):
     set_combo_value(widget, value)
     self.project.videorate = value
Esempio n. 41
0
 def acodec_setter(self, widget, value):
     set_combo_value(widget, Gst.ElementFactory.find(value))
     self.project.aencoder = value
     if not self.muxer_combo_changing:
         # The user directly changed the audio encoder combo.
         self.preferred_aencoder = value
Esempio n. 42
0
 def updateParFromFractionWidget(self):
     set_combo_value(self.par_combo, self.par_fraction_widget.getWidgetValue())
Esempio n. 43
0
 def vcodec_setter(self, widget, value):
     set_combo_value(widget, Gst.ElementFactory.find(value))
     self.project.setEncoders(vencoder=value)
     if not self.muxer_combo_changing:
         # The user directly changed the video encoder combo.
         self.preferred_vencoder = value