Exemple #1
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  imagelayer = GES.Layer()
  videolayer = GES.Layer()
  timeline.add_layer(imagelayer)
  timeline.add_layer(videolayer)

  asset = GES.UriClipAsset.request_sync(videoFile)
  imageasset = GES.UriClipAsset.request_sync(imageFile)

  imagelayer.add_asset(imageasset, 1 * Gst.SECOND, 0, 1 * Gst.SECOND, GES.TrackType.UNKNOWN)
  videolayer.add_asset(asset, 0 * Gst.SECOND, 0, 10 * Gst.SECOND, GES.TrackType.UNKNOWN)
  
  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)

  pipeline.set_state(Gst.State.PLAYING)

  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect("message", busMessageCb)
  GObject.timeout_add(300, duration_querier, pipeline)
 
  signal.signal(signal.SIGINT, handle_sigint)
  Gtk.main()
Exemple #2
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  video_layer = GES.Layer()
  audio_layer = GES.Layer()
  
  timeline.add_layer(video_layer)
  timeline.add_layer(audio_layer)

  video_asset = GES.UriClipAsset.request_sync(videoFile)
  #video_layer.add_asset(video_asset, 0, 0, 3 * Gst.SECOND, GES.TrackType.UNKNOWN)
  video_layer.add_asset(video_asset, 0, 0, 3 * Gst.SECOND, video_asset.get_supported_formats())

  audio_asset = GES.UriClipAsset.request_sync(audioFile)
  audio_layer.add_asset(audio_asset, 0, 0, timeline.get_duration(), GES.TrackType.AUDIO)
  
  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  pipeline.set_state(Gst.State.PLAYING)
    
  mainLoop = GLib.MainLoop.new(None, False)
  GLib.timeout_add_seconds(3, quit, mainLoop)
  GLib.MainLoop().run()
Exemple #3
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  layer = GES.Layer()
  
  timeline.add_layer(layer)

  asset = GES.UriClipAsset.request_sync(videoFile)
  
  imageasset = GES.UriClipAsset.request_sync(imageFile)

  layer.add_asset(imageasset, 0 * Gst.SECOND, 0, 1 * Gst.SECOND, GES.TrackType.UNKNOWN)
  layer.add_asset(asset, 0 * Gst.SECOND, 0, 10 * Gst.SECOND, GES.TrackType.UNKNOWN)
  
  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  pipeline.set_state(Gst.State.PLAYING)

  mainLoop = GLib.MainLoop.new(None, False)
  GLib.timeout_add_seconds(10, quit, mainLoop)
  GLib.MainLoop().run()
Exemple #4
0
def initialize_modules():
    """
    Initialize the modules.

    This has to be done in a specific order otherwise the app
    crashes on some systems.
    """
    from gi.repository import Gdk
    Gdk.init([])
    from gi.repository import GtkClutter
    GtkClutter.init([])

    import gi
    if not gi.version_info >= (3, 11):
        from gi.repository import GObject
        GObject.threads_init()

    from gi.repository import Gst
    Gst.init(None)
    from gi.repository import GES
    GES.init()

    # This is required because of:
    # https://bugzilla.gnome.org/show_bug.cgi?id=656314
    from gi.repository import GdkX11
    GdkX11  # noop
Exemple #5
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  layer = GES.Layer()
  
  timeline.add_layer(layer)

  asset = GES.UriClipAsset.request_sync(videoFile1)
  asset2 = GES.UriClipAsset.request_sync(videoFile2)

  layer.add_asset(asset, 0 * Gst.SECOND, 0, 3 * Gst.SECOND, GES.TrackType.UNKNOWN)
  layer.add_asset(asset2, 3 * Gst.SECOND, 0, 3 * Gst.SECOND, GES.TrackType.UNKNOWN)
  
  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  
  #encoding
  container_profile = GstPbutils.EncodingContainerProfile.new(
      "pitivi-profile",
      "Pitivi encoding profile",
      Gst.Caps.new_empty_simple("video/x-matroska"),
      None)
 
  video_profile = GstPbutils.EncodingVideoProfile.new(
      Gst.Caps.new_empty_simple("video/x-h264"),
      None,
      Gst.Caps.new_empty_simple("video/x-raw"),
      0)
 
  container_profile.add_profile(video_profile)
 
  audio_profile = GstPbutils.EncodingAudioProfile.new(
      Gst.Caps.new_empty_simple("audio/x-vorbis"),
      None,
      Gst.Caps.new_empty_simple("audio/x-raw"),
      0)
 
  container_profile.add_profile(audio_profile)

  pipeline.set_render_settings(outputFile, container_profile)
  pipeline.set_mode(GES.PipelineFlags.RENDER)
  pipeline.set_state(Gst.State.PLAYING)
  
  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect("message", busMessageCb)
  GObject.timeout_add(1000, duration_querier, pipeline)
 
  signal.signal(signal.SIGINT, handle_sigint)
  Gtk.main()
Exemple #6
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  layer = GES.Layer()
  
  timeline.add_layer(layer)
  
  #asset = GES.UriClipAsset.request_sync(videoFile1)
  
  asset = GES.Asset.request(GES.TestClip, None)
  
  #src = GES.TestClip()
  #asset.set_property("pattern", GES.VideoTestPattern.SMPTE75)
  #src.set_property("duration", 5 * Gst.SECOND)
  #src.set_property("in-point", 5 * Gst.SECOND)
  #src.set_property("supported-formats", GES.TrackType.VIDEO)
  
  #effect = GES.Effect.new("videobalance")

  # this works
  #effect = GES.Effect.new("videobalance hue=0.5")

  #effect = GES.Effect.new("agingtv")
  #effect = GES.Effect.new("videobalance saturation=1.5 hue=+0.5")
  effect = GES.Effect.new("frei0r-filter-scale0tilt")
  #embed()
    
  clip = layer.add_asset(asset, 0 * Gst.SECOND, 0  * Gst.SECOND, 2  * Gst.SECOND, GES.TrackType.VIDEO)
  
  clip.add(effect)
  clip.set_property("vpattern", GES.VideoTestPattern.SMPTE75)

  timeline.commit()

  print(effect.list_children_properties())
  effect.set_child_property("tilt-x", 0.8)

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  pipeline.set_state(Gst.State.PLAYING)
  
  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect("message", busMessageCb)
  GObject.timeout_add(1000, duration_querier, pipeline)
 
  signal.signal(signal.SIGINT, handle_sigint)
  Gtk.main()
Exemple #7
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  layer = GES.SimpleLayer.new()
  
  timeline.add_layer(layer)
  
  """
  GES.VideoTestPattern.BLACK
  GES.VideoTestPattern.BLINK
  GES.VideoTestPattern.BLUE
  GES.VideoTestPattern.CHECKERS_1
  GES.VideoTestPattern.CHECKERS_2
  GES.VideoTestPattern.CHECKERS_4
  GES.VideoTestPattern.CHECKERS_8
  GES.VideoTestPattern.CHROMA_ZONE_PLATE
  GES.VideoTestPattern.CIRCULAR
  GES.VideoTestPattern.GAMUT
  GES.VideoTestPattern.GREEN
  GES.VideoTestPattern.RED
  GES.VideoTestPattern.SMPTE
  GES.VideoTestPattern.SMPTE75
  GES.VideoTestPattern.SNOW
  GES.VideoTestPattern.SOLID_COLOR
  GES.VideoTestPattern.WHITE
  GES.VideoTestPattern.ZONE_PLATE
  """
  for i in range(0, 18):
    src = GES.TestClip()
    src.set_property("vpattern", i)
    src.set_property("duration", 1 * Gst.SECOND)
    layer.add_clip(src)

  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  pipeline.set_state(Gst.State.PLAYING)
  
  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect("message", busMessageCb)
  GObject.timeout_add(1000, duration_querier, pipeline)
 
  signal.signal(signal.SIGINT, handle_sigint)
  Gtk.main()
Exemple #8
0
    def __init__(self, app):
        Gtk.FileChooserDialog.__init__(self)

        self.set_title(_("Open File..."))
        self.set_transient_for(app.gui)
        self.set_action(Gtk.FileChooserAction.OPEN)

        self.add_buttons(_("Cancel"), Gtk.ResponseType.CANCEL,
                         _("Open"), Gtk.ResponseType.OK)
        self.set_default_response(Gtk.ResponseType.OK)
        self.set_select_multiple(False)
        # TODO: Remove this set_current_folder call when GTK bug 683999 is
        # fixed
        self.set_current_folder(app.settings.lastProjectFolder)
        formatter_assets = GES.list_assets(GES.Formatter)
        formatter_assets.sort(
            key=lambda x: - x.get_meta(GES.META_FORMATTER_RANK))
        for format_ in formatter_assets:
            filt = Gtk.FileFilter()
            filt.set_name(format_.get_meta(GES.META_DESCRIPTION))
            filt.add_pattern("*%s" %
                             format_.get_meta(GES.META_FORMATTER_EXTENSION))
            self.add_filter(filt)
        default = Gtk.FileFilter()
        default.set_name(_("All supported formats"))
        default.add_custom(Gtk.FileFilterFlags.URI, self.__can_load_uri, None)
        self.add_filter(default)
Exemple #9
0
    def __init__(self, app):
        self.app = app
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(get_ui_dir(), "startupwizard.ui"))
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("window1")

        self.recent_chooser = self.builder.get_object("recentchooser2")
        # FIXME: gtk creates a combo box with only one item, but there is no
        # simple way to hide it.
        filter = Gtk.RecentFilter()
        filter.set_name(_("Projects"))

        for asset in GES.list_assets(GES.Formatter):
            filter.add_pattern('*.' + asset.get_meta(GES.META_FORMATTER_EXTENSION))

        self.recent_chooser.add_filter(filter)

        if not missing_soft_deps:
            self.builder.get_object("missing_deps_button").hide()

        self.app.projectManager.connect("new-project-failed", self._projectFailedCb)
        self.app.projectManager.connect("new-project-loaded", self._projectLoadedCb)
        self.app.projectManager.connect("new-project-loading", self._projectLoadingCb)

        vbox = self.builder.get_object("topvbox")
        self.infobar = Gtk.InfoBar()
        vbox.pack_start(self.infobar, True, True, 0)
        if self.app.version_information:
            self._appVersionInfoReceivedCb(None, self.app.version_information)
        else:
            self.app.connect("version-info-received", self._appVersionInfoReceivedCb)
Exemple #10
0
    def __init__(self, app):
        Gtk.AboutDialog.__init__(self)
        self.set_program_name(APPNAME)
        self.set_website(APPURL)

        if in_devel():
            version_str = _("Development version: %s") % GITVERSION
        elif not app.isLatest():
            version_str = _("Version %(cur_ver)s — %(new_ver)s is available") % \
                {"cur_ver": GITVERSION,
                 "new_ver": app.getLatest()}
        elif GITVERSION:
            version_str = _("Version %s") % GITVERSION
        else:
            version_str = _("Version %s") % VERSION
        self.set_version(version_str)

        comments = ["",
                    "GES %s" % ".".join(map(str, GES.version())),
                    "GTK+ %s" % ".".join(map(str, (Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION))),
                    "GStreamer %s" % ".".join(map(str, Gst.version()))]
        self.set_comments("\n".join(comments))

        authors = [_("Current maintainers:"),
                   "Thibault Saunier <*****@*****.**>",
                   "Mathieu Duponchelle <*****@*****.**>",
                   "Alexandru Băluț <*****@*****.**>",
                   "",
                   _("Past maintainers:"),
                   "Edward Hervey <*****@*****.**>",
                   "Alessandro Decina <*****@*****.**>",
                   "Brandon Lewis <*****@*****.**>",
                   "Jean-François Fortin Tam <*****@*****.**>",
                   "",
                   # Translators: this paragraph is to be translated, the list
                   # of contributors is shown dynamically as a clickable link
                   # below it
                   _("Contributors:\n" +
                     "A handwritten list here would...\n" +
                     "• be too long,\n" +
                     "• be frequently outdated,\n" +
                     "• not show their relative merit.\n\n" +
                     "Out of respect for our contributors, we point you instead to:\n"),
                   # Translators: keep the %s at the end of the 1st line
                   _("The list of contributors on Ohloh %s\n" +
                     "Or you can run: git shortlog -s -n")
                   % "http://ohloh.net/p/pitivi/contributors", ]
        self.set_authors(authors)
        # Translators: See
        # https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html#gtk-about-dialog-set-translator-credits
        # for details on how this is used.
        translators = _("translator-credits")
        if translators != "translator-credits":
            self.set_translator_credits(translators)
        documenters = ["Jean-François Fortin Tam <*****@*****.**>", ]
        self.set_documenters(documenters)
        self.set_license_type(Gtk.License.LGPL_2_1)
        self.set_logo_icon_name("org.pitivi.Pitivi")
        self.connect("response", self.__about_response_cb)
        self.set_transient_for(app.gui)
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  #timeline = GES.Timeline()
  
  #videotrack = GES.VideoTrack.new()
  #timeline.add_track(videotrack)

  imagelayer = GES.Layer()
  videolayer = GES.Layer()
  
  #imagelayer.set_property("priority", 1)
  #videolayer.set_property("priority", 0)
  #g_object_set (layer2, "priority", 1, NULL);

  timeline.add_layer(imagelayer)
  timeline.add_layer(videolayer)

  asset = GES.UriClipAsset.request_sync(videoFile)
  
  imageasset1 = GES.UriClipAsset.request_sync(imageFile1)
  imageasset2 = GES.UriClipAsset.request_sync(imageFile2)
  imageasset3 = GES.UriClipAsset.request_sync(imageFile3)

  imagelayer.add_asset(imageasset1, 0 * Gst.SECOND, 0, 1 * Gst.SECOND, GES.TrackType.VIDEO)
  #imagelayer.add_asset(imageasset2, 6 * Gst.SECOND, 0, 2 * Gst.SECOND, GES.TrackType.VIDEO)
  #imagelayer.add_asset(imageasset3, 8 * Gst.SECOND, 0, 2 * Gst.SECOND, GES.TrackType.VIDEO)
  #videolayer.add_asset(asset, 1 * Gst.SECOND, 0, 10 * Gst.SECOND, GES.TrackType.VIDEO)
  
  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)

  pipeline.set_state(Gst.State.PLAYING)

  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect("message", busMessageCb)
  GObject.timeout_add(300, duration_querier, pipeline)
 
  signal.signal(signal.SIGINT, handle_sigint)
  Gtk.main()
Exemple #12
0
    def __init__(self):
        '''Initialize the Python class'''
        GES.init()    # we need to init GES for it to work

        self.timeline = GES.Timeline()   # create the central object of the Timeline
        self.pipeline = GES.TimelinePipeline()   # convenience class to render the Timeline
                                                 # handles the clock, bus and other things for us
        self.bus = self.pipeline.get_bus()
        self.pipeline.add_timeline(self.timeline)    # we need to add the Timeline into the Pipeline

        GES.Timeline.__init__(self.timeline)    # initialize the Timeline

        self.audio = GES.Track.audio_raw_new()    # we will have one raw Audio Track
        self.video = GES.Track.video_raw_new()    # and one raw Video Track

        self.timeline.add_track(self.audio)    # we add the Tracks to the Timeline
        self.timeline.add_track(self.video)

        Gst.init(None)    # we need to initialize Gst for it to work
Exemple #13
0
def initialize_modules():
    """Initializes the modules.

    This has to be done in a specific order otherwise the app
    crashes on some systems.
    """
    try:
        import gi
    except ImportError:
        print(_("Could not import 'gi'. "
                "Make sure you have pygobject available."))
        exit(1)

    require_version("Gtk", GTK_API_VERSION)
    require_version("Gdk", GTK_API_VERSION)
    from gi.repository import Gdk
    Gdk.init([])
    from gi.repository import Gtk

    # Monkey patch deprecated methods to use the new variant by default
    Gtk.Layout.get_vadjustment = Gtk.Scrollable.get_vadjustment
    Gtk.Layout.get_hadjustment = Gtk.Scrollable.get_hadjustment

    if not gi.version_info >= (3, 11):
        from gi.repository import GObject
        GObject.threads_init()

    require_version("Gst", GST_API_VERSION)
    require_version("GstController", GST_API_VERSION)
    require_version("GstTranscoder", GST_API_VERSION)
    from gi.repository import Gst
    from pitivi.configure import get_audiopresets_dir, get_videopresets_dir
    Gst.init(None)

    if not os.environ.get("GES_DISCOVERY_TIMEOUT"):
        os.environ["GES_DISCOVERY_TIMEOUT"] = "5"

    require_version("GES", GST_API_VERSION)
    from gi.repository import GES
    res, sys.argv = GES.init_check(sys.argv)
    # Monkey patch deprecated methods to use the new variant by default
    GES.TrackElement.list_children_properties = GES.TimelineElement.list_children_properties

    from pitivi.utils import validate
    if validate.init() and "--inspect-action-type" in sys.argv:
        try:
            action_type = [sys.argv[1 + sys.argv.index("--inspect-action-type")]]
        except IndexError:
            action_type = []
        if validate.GstValidate.print_action_types(action_type):
            exit(0)
        else:
            exit(1)
Exemple #14
0
    def __init__(self, uri):
        timeline = GES.Timeline.new_audio_video()
        layer = timeline.append_layer()
        layer.add_clip(GES.UriClip.new(uri))
        self.pipeline = pipeline = GES.Pipeline()
        pipeline.set_timeline(timeline)
        pipeline.set_state(Gst.State.PLAYING)
        bus = pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect("message", self.bus_message_cb)

        self.loop = GLib.MainLoop()
Exemple #15
0
def init():
    global has_validate
    try:
        from gi.repository import GstValidate
        GstValidate.init()
        has_validate = GES.validate_register_action_types()
        GstValidate.register_action_type("stop", "pitivi",
                                         stop, None,
                                         "Pitivi override for the stop action",
                                         GstValidate.ActionTypeFlags.NONE)
    except ImportError:
        has_validate = False
Exemple #16
0
def init():
    global has_validate
    try:
        from gi.repository import GstValidate
        GstValidate.init()
        has_validate = GES.validate_register_action_types()
        GstValidate.register_action_type(
            "stop", "pitivi", stop, None,
            "Pitivi override for the stop action",
            GstValidate.ActionTypeFlags.NONE)
    except ImportError:
        has_validate = False
Exemple #17
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  asset = GES.UriClipAsset.request_sync(videoFile)
  
  layer = GES.Layer()
  timeline.add_layer(layer)
  layer.add_asset(asset, 0, 0 * Gst.SECOND, 10 * Gst.SECOND, asset.get_supported_formats())
  
  #timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  pipeline.set_state(Gst.State.PLAYING)
    
  mainLoop = GLib.MainLoop.new(None, False)
  GLib.timeout_add_seconds(10, quit, mainLoop)
  GLib.MainLoop().run()
Exemple #18
0
def get_edge(structure):
    try:
        res, edge = GstValidate.utils_enum_from_str(GES.Edge, structure["edge"])
        if not res:
            edge = GES.Edge.EDGE_NONE
        else:
            edge = GES.Edge(edge)

    except KeyError:
        edge = GES.Edge.EDGE_NONE

    return edge
Exemple #19
0
    def test_add_effect_change_property(self):
        stacks = []
        self.action_log.connect("commit", common.TestCase.commit_cb, stacks)

        clip1 = GES.TitleClip()
        self.layer.add_clip(clip1)

        effect1 = GES.Effect.new("agingtv")
        with self.action_log.started("add effect"):
            clip1.add(effect1)

        self.assertEqual(1, len(stacks))
        stack = stacks[0]
        self.assertEqual(1, len(stack.done_actions), stack.done_actions)
        action = stack.done_actions[0]
        self.assertTrue(isinstance(action, TrackElementAdded))

        self.assertTrue(effect1 in clip1.get_children(True))
        self.assertEqual(
            1,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))

        with self.action_log.started("change child property"):
            effect1.set_child_property("scratch-lines", 0)
        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)

        # Undo effect property change.
        self.action_log.undo()
        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 7)

        # Redo effect property change.
        self.action_log.redo()
        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)

        # Undo effect property change.
        self.action_log.undo()
        self.assertTrue(effect1 in clip1.get_children(True))

        # Undo effect add.
        self.action_log.undo()
        self.assertFalse(effect1 in clip1.get_children(True))

        # Redo effect add.
        self.action_log.redo()
        self.assertTrue(effect1 in clip1.get_children(True))
        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 7)

        # Redo effect property change.
        self.action_log.redo()
        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)
Exemple #20
0
def main(argv):
    Gst.init(None)
    GES.init()

    opts = parser.parse_args(argv[1:])
    source = opts.basedir
    width, height = tuple(map(int, opts.size.split("x", 2)))

    p = Presentation(source=source, size=(width, height))

    if opts.start or opts.end:
        p.cut(opts.start, opts.end)

    for fname in opts.opening_credits or []:
        p.add_opening_credits(fname)

    if opts.backdrop:
        p.add_backdrop(opts.backdrop)

    for fname in opts.closing_credits or []:
        p.add_closing_credits(fname)

    margin = opts.margin
    cam_width = opts.webcam_width
    if 0 < cam_width < 1:
        cam_width = int(cam_width * width)

    max_height = int(height - 2 * margin)
    slides_width = int(width - 2 * margin)

    if cam_width > 0:
        slides_width -= int(cam_width + margin)
        p.add_webcams(fit=(slides_width + 2 * margin, margin, cam_width,
                           max_height),
                      align="lt")

    p.add_slides(fit=(margin, margin, slides_width, max_height), align="ct")
    p.add_deskshare(fit=(margin, margin, slides_width, max_height), align="ct")

    p.save(opts.target)
Exemple #21
0
    def test_media_types(self):
        timeline_container = common.create_timeline_container()
        timeline = timeline_container.timeline

        ges_layer_1 = timeline.ges_timeline.append_layer()
        ges_layer_2 = timeline.ges_timeline.append_layer()

        # Timeline should contain no media_types.
        self.assertEqual(timeline.media_types, GES.TrackType(0))

        # Timeline should now contain only audio media type.
        ges_clip_audio = self.add_clip(ges_layer_1,
                                       10,
                                       clip_type=GES.TrackType.AUDIO)
        self.assertEqual(timeline.media_types, GES.TrackType.AUDIO)

        ges_layer_1.remove_clip(ges_clip_audio)
        ges_clip_video = self.add_clip(ges_layer_2,
                                       20,
                                       clip_type=GES.TrackType.VIDEO)
        self.assertEqual(timeline.media_types, GES.TrackType.VIDEO)

        # Timeline should contain no media_types.
        ges_layer_2.remove_clip(ges_clip_video)
        self.assertEqual(timeline.media_types, GES.TrackType(0))

        # Timeline should contain both clips.
        ges_clip_audio = self.add_clip(ges_layer_1,
                                       10,
                                       clip_type=GES.TrackType.AUDIO)
        ges_clip_video = self.add_clip(ges_layer_2,
                                       20,
                                       clip_type=GES.TrackType.VIDEO)
        self.assertEqual(timeline.media_types,
                         GES.TrackType.VIDEO | GES.TrackType.AUDIO)

        # Timeline should contain no clips.
        ges_layer_1.remove_clip(ges_clip_audio)
        ges_layer_2.remove_clip(ges_clip_video)
        self.assertEqual(timeline.media_types, GES.TrackType(0))
Exemple #22
0
    def test_clip_dragged_to_create_layer_below(self):
        self.setup_timeline_container()
        timeline_ui = self.timeline_container.timeline
        layers = self.timeline.get_layers()
        self.assertEqual(len(layers), 1)

        clip = GES.TitleClip()
        self.layer.add_clip(clip)

        # Drag a clip on a separator to create a layer.
        with mock.patch.object(Gtk, 'get_event_widget') as get_event_widget:
            get_event_widget.return_value = clip.ui

            event = mock.Mock()
            event.x = 0
            event.get_button.return_value = True, 1
            timeline_ui._button_press_event_cb(None, event)

            def translate_coordinates(widget, x, y):
                return x, y

            clip.ui.translate_coordinates = translate_coordinates
            event = mock.Mock()
            event.get_state.return_value = Gdk.ModifierType.BUTTON1_MASK
            event.x = 1
            event.y = LAYER_HEIGHT * 2
            event.get_button.return_value = True, 1
            timeline_ui._motion_notify_event_cb(None, event)

        timeline_ui._button_release_event_cb(None, event)

        layers = self.timeline.get_layers()
        self.assertEqual(len(layers), 2)
        self.assertEqual(layers[0], self.layer)
        self.check_layers(layers)
        self.assertEqual(layers[0].get_clips(), [])
        self.assertEqual(layers[1].get_clips(), [clip])

        self.action_log.undo()
        layers = self.timeline.get_layers()
        self.assertEqual(len(layers), 1)
        self.assertEqual(layers[0], self.layer)
        self.check_layers(layers)
        self.assertEqual(layers[0].get_clips(), [clip])

        self.action_log.redo()
        layers = self.timeline.get_layers()
        self.assertEqual(len(layers), 2)
        self.assertEqual(layers[0], self.layer)
        self.check_layers(layers)
        self.assertEqual(layers[0].get_clips(), [])
        self.assertEqual(layers[1].get_clips(), [clip])
Exemple #23
0
    def __init__(self, app):
        Gtk.AboutDialog.__init__(self)
        self.set_program_name(APPNAME)
        self.set_website(APPURL)

        if in_devel():
            version_str = _("Development version: %s") % GITVERSION
        elif not app.is_latest():
            version_str = _("Version %(cur_ver)s — %(new_ver)s is available") % \
                {"cur_ver": GITVERSION,
                 "new_ver": app.get_latest()}
        elif GITVERSION:
            version_str = _("Version %s") % GITVERSION
        else:
            version_str = _("Version %s") % VERSION
        self.set_version(version_str)

        comments = [
            "",
            "GES %s" % ".".join(map(str, GES.version())),
            "GTK+ %s" %
            ".".join(map(str, (Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION))),
            "GStreamer %s" % ".".join(map(str, Gst.version()))
        ]
        self.set_comments("\n".join(comments))

        authors = [
            _("Current maintainers:"), "Thibault Saunier <*****@*****.**>",
            "Mathieu Duponchelle <*****@*****.**>",
            "Alexandru Băluț <*****@*****.**>", "",
            _("Past maintainers:"), "Edward Hervey <*****@*****.**>",
            "Alessandro Decina <*****@*****.**>",
            "Brandon Lewis <*****@*****.**>",
            "Jean-François Fortin Tam <*****@*****.**>", "",
            _("Contributors:"),
            "https://gitlab.gnome.org/GNOME/pitivi/-/graphs/master", ""
        ]
        self.set_authors(authors)
        # Translators: See
        # https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html#gtk-about-dialog-set-translator-credits
        # for details on how this is used.
        translators = _("translator-credits")
        if translators != "translator-credits":
            self.set_translator_credits(translators)
        documenters = [
            "Jean-François Fortin Tam <*****@*****.**>",
        ]
        self.set_documenters(documenters)
        self.set_license_type(Gtk.License.LGPL_2_1)
        self.set_logo_icon_name("org.pitivi.Pitivi")
        self.connect("response", self.__about_response_cb)
        self.set_transient_for(app.gui)
Exemple #24
0
    def testRemoveEffectFromClip(self):
        stacks = []
        self.action_log.connect("commit", TestTimelineUndo.commitCb, stacks)

        clip1 = GES.TitleClip()
        self.layer.add_clip(clip1)

        effect1 = GES.Effect.new("agingtv")
        self.action_log.begin("add effect")
        clip1.add(effect1)
        self.action_log.commit()

        self.assertEqual(1, len(stacks))
        stack = stacks[0]
        self.assertEqual(1, len(stack.done_actions), stack.done_actions)
        action = stack.done_actions[0]
        self.assertTrue(isinstance(action, TrackElementAdded))

        self.assertTrue(effect1 in clip1.get_children(True))
        self.assertEqual(
            1,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))

        self.action_log.begin("remove effect")
        clip1.remove(effect1)
        self.action_log.commit()

        self.assertEqual(
            0,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))

        self.action_log.undo()
        self.assertEqual(
            1,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))

        self.action_log.redo()
        self.assertEqual(
            0,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))
Exemple #25
0
 def _createCb(self, unused_button):
     """
     The user clicked the "Create and insert" button, initialize the UI
     """
     clip = GES.TitleClip()
     clip.set_text("")
     clip.set_duration(int(Gst.SECOND * 5))
     clip.set_color(FOREGROUND_DEFAULT_COLOR)
     clip.set_background(BACKGROUND_DEFAULT_COLOR)
     # TODO: insert on the current layer at the playhead position.
     # If no space is available, create a new layer to insert to on top.
     self.app.gui.timeline_ui.insertEnd([clip])
     self.app.gui.timeline_ui.timeline.selection.setToObj(clip, SELECT)
Exemple #26
0
    def testTrackElementPropertyChanged(self):
        clip1 = GES.TitleClip()
        self.layer.add_clip(clip1)

        with self.action_log.started("Title text change"):
            source = clip1.get_children(False)[0]
            source.set_child_property("text", "pigs fly!")
            self.assertEqual(source.get_child_property("text")[1], "pigs fly!")

        self.action_log.undo()
        self.assertEqual(source.get_child_property("text")[1], "")
        self.action_log.redo()
        self.assertEqual(source.get_child_property("text")[1], "pigs fly!")
Exemple #27
0
def create_project(with_group=False, saved=False):
    """Creates a project with two clips in a group."""
    project = GES.Project()
    timeline = project.extract()
    layer = timeline.append_layer()

    if with_group:
        clip1 = GES.TitleClip()
        clip1.set_start(0)
        clip1.set_duration(10)
        layer.add_clip(clip1)
        clip2 = GES.TitleClip()
        clip2.set_start(100)
        clip2.set_duration(10)
        layer.add_clip(clip2)
        group = GES.Container.group([clip1, clip2])

    if saved:
        uri = "file://%s" % tempfile.NamedTemporaryFile(suffix=".xges").name
        project.save(timeline, uri, None, overwrite=True)

    return timeline
Exemple #28
0
    def testTimeline(self, timeline):
        timeline.set_easing_duration(600)

        Gst.init([])
        GES.init()

        self.project = GES.Project(uri=None, extractable_type=GES.Timeline)

        bTimeline = GES.Timeline()
        bTimeline.add_track(GES.Track.audio_raw_new())
        bTimeline.add_track(GES.Track.video_raw_new())

        self.bTimeline = bTimeline
        timeline.setTimeline(bTimeline)

        layer = GES.Layer()
        bTimeline.add_layer(layer)

        self.bTimeline = bTimeline

        self.project.connect("asset-added", self._doAssetAddedCb, layer)
        self.project.create_asset("file://" + sys.argv[2], GES.UriClip)
Exemple #29
0
 def test_check_media_types_when_no_control_ui(self):
     ges_layer = GES.Layer()
     png = common.get_sample_uri("flat_colour1_640x480.png")
     video_clip = GES.UriClipAsset.request_sync(png).extract()
     self.assertTrue(ges_layer.add_clip(video_clip))
     self.assertEqual(len(ges_layer.get_clips()), 1)
     timeline_container = common.create_timeline_container()
     timeline = timeline_container.timeline
     # This will add widgets for the clips in ges_layer and
     # the layer will use checkMediaTypes which updates the
     # height of layer.control_ui, which now it should not be set.
     self.assertFalse(hasattr(ges_layer, "control_ui"))
     unused_layer = Layer(ges_layer, timeline)
Exemple #30
0
    def testRemoveEffectFromClip(self):
        stacks = []
        self.action_log.connect("commit", BaseTestUndoTimeline.commit_cb,
                                stacks)

        clip1 = GES.TitleClip()
        self.layer.add_clip(clip1)

        effect1 = GES.Effect.new("agingtv")
        with self.action_log.started("add effect"):
            clip1.add(effect1)

        self.assertEqual(1, len(stacks))
        stack = stacks[0]
        self.assertEqual(1, len(stack.done_actions), stack.done_actions)
        action = stack.done_actions[0]
        self.assertTrue(isinstance(action, EffectAddedAction))

        self.assertTrue(effect1 in clip1.get_children(True))
        self.assertEqual(
            1,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))

        with self.action_log.started("remove effect"):
            clip1.remove(effect1)

        self.assertEqual(
            0,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))

        self.action_log.undo()
        self.assertEqual(
            1,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))

        self.action_log.redo()
        self.assertEqual(
            0,
            len([
                effect for effect in clip1.get_children(True)
                if isinstance(effect, GES.Effect)
            ]))
 def testSwitchContextTab(self):
     for expected_tab, bElement in [(2, GES.TitleSource()),
                                    (1, GES.VideoTransition()),
                                    (0, GES.VideoUriSource()),
                                    (1, GES.VideoTransition()),
                                    (0, GES.ImageSource()),
                                    (1, GES.AudioTransition()),
                                    (0, GES.AudioUriSource()),
                                    (1, GES.AudioTransition())]:
         self.mainwindow.switchContextTab(bElement)
         self.assertEqual(expected_tab,
                          self.mainwindow.context_tabs.get_current_page())
         # Make sure the tab does not change when using an invalid argument.
         self.mainwindow.switchContextTab("invalid")
         self.assertEqual(expected_tab,
                          self.mainwindow.context_tabs.get_current_page())
Exemple #32
0
    def test_update_clips_asset(self):
        timeline_container = common.create_timeline_container()
        mainloop = common.create_main_loop()
        mainloop.run(until_empty=True)
        ges_timeline = timeline_container.ges_timeline
        layer, = ges_timeline.get_layers()
        title_clip = GES.TitleClip()
        title_clip.props.duration = 100
        layer.add_clip(title_clip)
        self.assertListEqual(list(timeline_container.timeline.clips()),
                             [title_clip])

        # Check the title clips are ignored.
        timeline_container.update_clips_asset(mock.Mock())
Exemple #33
0
    def test_name(self):
        timeline = mock.MagicMock()
        ges_layer = GES.Layer()
        layer = Layer(ges_layer, timeline)
        self.assertEqual(layer.get_name(), "Layer 0", "Default name generation failed")

        ges_layer.set_meta("audio::name", "a")
        self.assertEqual(layer.get_name(), "a", "Cannot use old audio name")

        ges_layer.set_meta("video::name", "v")
        self.assertEqual(layer.get_name(), "v", "Cannot use old video name")

        layer.set_name("vv")
        self.assertEqual(layer.get_name(), "vv")
Exemple #34
0
 def _createCb(self, unused_button):
     """
     The user clicked the "Create and insert" button, initialize the UI
     """
     source = GES.TitleClip()
     source.set_text("")
     source.set_duration(long(Gst.SECOND * 5))
     self.set_source(source, True)
     # TODO: insert on the current layer at the playhead position.
     # If no space is available, create a new layer to insert to on top.
     self.app.gui.timeline_ui.insertEnd([self.source])
     self.app.gui.timeline_ui.timeline.selection.setToObj(
         self.source, SELECT)
     #After insertion consider as not created
     self.created = False
Exemple #35
0
    def _ensureLayer(self):
        """
        Make sure we have a layer in our timeline

        Returns: The number of layer present in self.timeline
        """
        layers = self.bTimeline.get_layers()

        if not layers:
            layer = GES.Layer()
            layer.props.auto_transition = True
            self.bTimeline.add_layer(layer)
            layers = [layer]

        return layers
Exemple #36
0
def initialize_modules():
    """
    Initialize the modules.

    This has to be done in a specific order otherwise the app
    crashes on some systems.
    """
    from gi.repository import Gdk
    Gdk.init([])
    from gi.repository import GtkClutter
    GtkClutter.init([])

    import gi
    if not gi.version_info >= (3, 11):
        from gi.repository import GObject
        GObject.threads_init()

    from gi.repository import Gst
    Gst.init(None)
    from gi.repository import GES
    GES.init()

    from pitivi.utils import validate
    validate.init()
 def assertGESError(self, error, code, message=""):
     if error is None:
         raise AssertionError("{}{}Received no error".format(
             message, message and ": "))
     if error.domain != "GES_ERROR":
         raise AssertionError(
             "{}{}Received error ({}) in domain {} rather than "
             "GES_ERROR".format(message, message and ": ", error.message,
                                error.domain))
     err_code = GES.Error(error.code)
     if err_code != code:
         raise AssertionError(
             "{}{}Received {} error ({}) rather than {}".format(
                 message, message and ": ", err_code.value_name,
                 error.message, code.value_name))
Exemple #38
0
def initialize_modules():
    """
    Initialize the modules.

    This has to be done in a specific order otherwise the app
    crashes on some systems.
    """
    from gi.repository import Gdk
    Gdk.init([])
    from gi.repository import GtkClutter
    GtkClutter.init([])

    import gi
    if not gi.version_info >= (3, 11):
        from gi.repository import GObject
        GObject.threads_init()

    from gi.repository import Gst
    Gst.init(None)
    from gi.repository import GES
    GES.init()

    from pitivi.utils import validate
    validate.init()
Exemple #39
0
    def test_add_clip(self):
        clip1 = GES.TitleClip()
        with self.action_log.started("add clip"):
            self.layer.add_clip(clip1)

        stack, = self.action_log.undo_stacks
        self.assertEqual(len(stack.done_actions), 2, stack.done_actions)
        self.assertTrue(isinstance(stack.done_actions[0], ClipAdded))
        self.assertTrue(clip1 in self.getTimelineClips())

        self.action_log.undo()
        self.assertFalse(clip1 in self.getTimelineClips())

        self.action_log.redo()
        self.assertTrue(clip1 in self.getTimelineClips())
Exemple #40
0
    def test_rollback_of_nested_operation_does_not_add_actions_to_parent(self):
        clip1 = GES.TitleClip()
        clip1.set_start(0 * Gst.SECOND)
        clip1.set_duration(1 * Gst.SECOND)

        clip2 = GES.TitleClip()
        clip2.set_start(1 * Gst.SECOND)
        clip2.set_duration(1 * Gst.SECOND)

        # begin parent operation
        self.action_log.begin("parent")

        # push one parent action
        self.layer.add_clip(clip1)
        stack_snapshot = self.action_log._get_last_stack().done_actions[::]

        # begin nested operation
        self.action_log.begin("nested")

        # push one nested action
        self.layer.add_clip(clip2)

        self.action_log.rollback()
        self.assertListEqual(self.action_log._get_last_stack().done_actions, stack_snapshot)
Exemple #41
0
    def _loadAvailableTransitionsCb(self):
        """Loads the transitions types and icons into the storemodel."""
        for trans_asset in GES.list_assets(GES.BaseTransitionClip):
            trans_asset.icon = self._getIcon(trans_asset.get_id())
            self.storemodel.append([trans_asset,
                                    str(trans_asset.get_id()),
                                    str(trans_asset.get_meta(
                                        GES.META_DESCRIPTION)),
                                    trans_asset.icon])

        # Now that the UI is fully ready, enable searching
        self.modelFilter.set_visible_func(self._setRowVisible, data=None)
        # Alphabetical/name sorting instead of based on the ID number
        self.storemodel.set_sort_column_id(
            COL_NAME_TEXT, Gtk.SortType.ASCENDING)
Exemple #42
0
def initialize_modules():
    """Initializes the modules.

    This has to be done in a specific order otherwise the app
    crashes on some systems.
    """
    try:
        import gi
    except ImportError:
        print(
            _("Could not import 'gi'. "
              "Make sure you have pygobject available."))
        exit(1)

    require_version("Gtk", GTK_API_VERSION)
    require_version("Gdk", GTK_API_VERSION)
    from gi.repository import Gdk
    Gdk.init([])

    if not gi.version_info >= (3, 11):
        from gi.repository import GObject
        GObject.threads_init()

    require_version("Gst", GST_API_VERSION)
    require_version("GstController", GST_API_VERSION)
    from gi.repository import Gst
    from pitivi.configure import get_audiopresets_dir, get_videopresets_dir
    Gst.init(None)

    if not os.environ.get("GES_DISCOVERY_TIMEOUT"):
        os.environ["GES_DISCOVERY_TIMEOUT"] = "5"

    require_version("GES", GST_API_VERSION)
    from gi.repository import GES
    res, sys.argv = GES.init_check(sys.argv)

    from pitivi.utils import validate
    if validate.init() and "--inspect-action-type" in sys.argv:
        try:
            action_type = [
                sys.argv[1 + sys.argv.index("--inspect-action-type")]
            ]
        except IndexError:
            action_type = []
        if validate.GstValidate.print_action_types(action_type):
            exit(0)
        else:
            exit(1)
Exemple #43
0
 def _createCb(self, unused_button):
     clip = GES.TitleClip()
     clip.set_duration(int(Gst.SECOND * 5))
     self.app.gui.timeline_ui.insertClips([clip])
     # Now that the clip is inserted in the timeline, it has a source which
     # can be used to set its properties.
     source = clip.get_children(False)[0]
     assert source.set_child_property("text", "")
     assert source.set_child_property("foreground-color",
                                      BACKGROUND_DEFAULT_COLOR)
     assert source.set_child_property("color", FOREGROUND_DEFAULT_COLOR)
     assert source.set_child_property("font-desc", DEFAULT_FONT_DESCRIPTION)
     assert source.set_child_property("valignment", DEFAULT_VALIGNMENT)
     assert source.set_child_property("halignment", DEFAULT_HALIGNMENT)
     # Select it so the Title editor becomes active.
     self._selection.setSelection([clip], SELECT)
Exemple #44
0
    def test_effect_toggling(self):
        clip1 = GES.TitleClip()
        self.layer.add_clip(clip1)

        effect1 = GES.Effect.new("agingtv")
        with self.action_log.started("add effect"):
            clip1.add(effect1)
        self.assertTrue(effect1.props.active)
        self.assert_effect_count(clip1, 1)

        with self.action_log.started("toggle effect"):
            effect1.props.active = False
        self.assertFalse(effect1.props.active)

        with self.action_log.started("remove effect"):
            clip1.remove(effect1)
        self.assert_effect_count(clip1, 0)

        # Undo effect removing.
        self.action_log.undo()
        self.assert_effect_count(clip1, 1)

        # Undo effect toggling.
        self.action_log.undo()
        self.assertTrue(effect1.props.active)

        # Redo effect toggling.
        self.action_log.redo()
        self.assertFalse(effect1.props.active)

        # Undo effect toggling.
        self.action_log.undo()
        self.assertTrue(effect1.props.active)

        # Undo effect add.
        self.action_log.undo()
        self.assertFalse(effect1 in clip1.get_children(True))

        # Redo effect add.
        self.action_log.redo()
        self.assertTrue(effect1 in clip1.get_children(True))
        self.assertTrue(effect1.props.active)

        # Redo effect toggling.
        self.action_log.redo()
        self.assertFalse(effect1.props.active)
Exemple #45
0
def initialize_modules():
    """Initializes the modules.

    This has to be done in a specific order otherwise the app
    crashes on some systems.
    """
    try:
        import gi
    except ImportError:
        print(_("Could not import 'gi'. "
                "Make sure you have pygobject available."))
        exit(1)

    require_version("Gtk", GTK_API_VERSION)
    require_version("Gdk", GTK_API_VERSION)
    from gi.repository import Gdk
    Gdk.init([])

    if not gi.version_info >= (3, 11):
        from gi.repository import GObject
        GObject.threads_init()

    require_version("Gst", GST_API_VERSION)
    require_version("GstController", GST_API_VERSION)
    require_version("GstTranscoder", GST_API_VERSION)
    from gi.repository import Gst
    from pitivi.configure import get_audiopresets_dir, get_videopresets_dir
    Gst.init(None)

    if not os.environ.get("GES_DISCOVERY_TIMEOUT"):
        os.environ["GES_DISCOVERY_TIMEOUT"] = "5"

    require_version("GES", GST_API_VERSION)
    from gi.repository import GES
    res, sys.argv = GES.init_check(sys.argv)

    from pitivi.utils import validate
    if validate.init() and "--inspect-action-type" in sys.argv:
        try:
            action_type = [sys.argv[1 + sys.argv.index("--inspect-action-type")]]
        except IndexError:
            action_type = []
        if validate.GstValidate.print_action_types(action_type):
            exit(0)
        else:
            exit(1)
Exemple #46
0
 def _createCb(self, unused_button):
     title_clip = GES.TitleClip()
     duration = self.app.settings.titleClipLength * Gst.MSECOND
     title_clip.set_duration(duration)
     self.app.gui.editor.timeline_ui.insert_clips_on_first_layer([title_clip])
     # Now that the clip is inserted in the timeline, it has a source which
     # can be used to set its properties.
     source = title_clip.get_children(False)[0]
     assert source.set_child_property("text", "")
     assert source.set_child_property("foreground-color", BACKGROUND_DEFAULT_COLOR)
     assert source.set_child_property("color", FOREGROUND_DEFAULT_COLOR)
     assert source.set_child_property("font-desc", DEFAULT_FONT_DESCRIPTION)
     assert source.set_child_property("valignment", DEFAULT_VALIGNMENT)
     assert source.set_child_property("halignment", DEFAULT_HALIGNMENT)
     # Select it so the Title editor becomes active.
     self._selection.setSelection([title_clip], SELECT)
     self.app.gui.editor.timeline_ui.timeline.resetSelectionGroup()
     self.app.gui.editor.timeline_ui.timeline.current_group.add(title_clip)
Exemple #47
0
    def __init__(self, app):
        self.app = app
        self.builder = Gtk.Builder()
        self.builder.add_from_file(
            os.path.join(get_ui_dir(), "startupwizard.ui"))
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("window1")
        # The line below is supremely important, it will NOT work if set
        # only by the GtkBuilder file. The DIALOG TypeHint allows proper
        # attachment (visually, behaviorally) to MainWindow, and
        # prevents other windows from showing on top too easily.
        self.window.set_type_hint(Gdk.WindowTypeHint.DIALOG)

        self.recent_chooser = self.builder.get_object("recentchooser2")
        # FIXME: gtk creates a combo box with only one item, but there is no
        # simple way to hide it.
        _filter = Gtk.RecentFilter()
        _filter.set_name(_("Projects"))

        for asset in GES.list_assets(GES.Formatter):
            _filter.add_pattern(
                '*.' + asset.get_meta(GES.META_FORMATTER_EXTENSION))

        self.recent_chooser.add_filter(_filter)

        missing_button = self.builder.get_object("missing_deps_button")

        if not missing_soft_deps:
            missing_button.hide()

        project_manager = self.app.project_manager
        project_manager.connect("new-project-failed", self._projectFailedCb)
        project_manager.connect("new-project-loaded", self._projectLoadedCb)
        project_manager.connect("new-project-loading", self._projectLoadingCb)

        vbox = self.builder.get_object("topvbox")
        self.infobar = Gtk.InfoBar()
        vbox.pack_start(self.infobar, True, True, 0)
        if self.app.getLatest():
            self._appVersionInfoReceivedCb(self.app, None)
        else:
            self.app.connect(
                "version-info-received", self._appVersionInfoReceivedCb)
Exemple #48
0
def initialize_modules():
    """
    Initialize the modules.

    This has to be done in a specific order otherwise the app
    crashes on some systems.
    """
    from gi.repository import Gdk

    Gdk.init([])

    import gi

    if not gi.version_info >= (3, 11):
        from gi.repository import GObject

        GObject.threads_init()

    from gi.repository import Gst

    Gst.init(None)
    from gi.repository import GES

    res, sys.argv = GES.init_check(sys.argv)

    from pitivi.utils import validate

    if validate.init() and "--inspect-action-type" in sys.argv:
        try:
            action_type = [sys.argv[1 + sys.argv.index("--inspect-action-type")]]
        except IndexError:
            action_type = []
        if validate.GstValidate.print_action_types(action_type):
            exit(0)
        else:
            exit(1)
Exemple #49
0
    Gst.Caps.from_string("video/x-raw"),
    0)
  container_profile.add_profile(video_profile)
 
  audio_profile = GstPbutils.EncodingAudioProfile.new(
    Gst.Caps.from_string(audio),
    None,
    Gst.Caps.from_string("audio/x-raw"),
    0)
  container_profile.add_profile(audio_profile)

  return container_profile
  
if __name__ =="__main__":
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  layer = GES.Layer()
  timeline.add_layer(layer)
  asset = GES.Asset.request(GES.TestClip, None)
  
  layer.add_asset(asset, 0 * Gst.SECOND, 0, 10 * Gst.SECOND, GES.TrackType.UNKNOWN)
  
  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  
  #dudio/mpeg mpegversion: 4 stream-format: raw 
  
Exemple #50
0
def init():
    global has_validate
    try:
        from gi.repository import GstValidate
        GstValidate.init()
        has_validate = GES.validate_register_action_types()
        GstValidate.register_action_type("stop", "pitivi",
                                         stop, None,
                                         "Pitivi override for the stop action",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("seek", "pitivi",
                                         seek, None,
                                         "Pitivi override for the seek action",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("pause", "pitivi",
                                         set_state, None,
                                         "Pitivi override for the pause action",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("play", "pitivi",
                                         set_state, None,
                                         "Pitivi override for the pause action",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("set-state", "pitivi",
                                         set_state, None,
                                         "Pitivi override for the set-state action",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("edit-container", "pitivi",
                                         editContainer, None,
                                         "Start dragging a clip in the timeline",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("split-clip", "pitivi",
                                         split_clip, None,
                                         "Split a clip",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("add-layer", "pitivi",
                                         add_layer, None,
                                         "Add layer",
                                         GstValidate.ActionTypeFlags.NONE)

        GstValidate.register_action_type("remove-clip", "pitivi",
                                         remove_clip, None,
                                         "Remove clip",
                                         GstValidate.ActionTypeFlags.NONE)
        GstValidate.register_action_type("select-clips", "pitivi",
                                         select_clips, [Parametter("clip-name",
                                                                   "The name of the clip to select",
                                                                   True, None, "str")],
                                         "Select clips",
                                         GstValidate.ActionTypeFlags.NONE)

        for z in ["zoom-fit", "zoom-out", "zoom-in"]:
            GstValidate.register_action_type(z, "pitivi", zoom, None, z,
                                             GstValidate.ActionTypeFlags.NO_EXECUTION_NOT_FATAL)
        GstValidate.register_action_type('set-zoom-level', "pitivi", setZoomLevel, None, z,
                                         GstValidate.ActionTypeFlags.NO_EXECUTION_NOT_FATAL)

        Gst.info("Adding pitivi::wrong-window-creation")
        GstValidate.Issue.register(GstValidate.Issue.new(
                                   GLib.quark_from_string("pitivi::wrong-window-creation"),
                                   "A new window for the sink has wrongly been created",
                                   "All sink should display their images in an embedded "
                                   "widget and thus not create a new window",
                                   GstValidate.ReportLevel.CRITICAL))
        return True
    except ImportError:
        has_validate = False
        return False
Exemple #51
0
def initial_checks():
    Gst.init(None)
    reg = Gst.Registry.get()

    if PiTiVi:
        return (
            _("%s is already running") % APPNAME,
            _("An instance of %s is already running in this script.") % APPNAME,
        )
    if not reg.find_plugin("gnonlin"):
        return (
            _("Could not find the GNonLin plugins"),
            _("Make sure the plugins were installed and are available in the GStreamer plugins path."),
        )
    if not reg.find_plugin("autodetect"):
        return (
            _("Could not find the autodetect plugins"),
            _("Make sure you have installed gst-plugins-good and that it's available in the GStreamer plugin path."),
        )
    if not hasattr(Gdk.Window, "cairo_create"):
        return (
            _("PyGTK doesn't have cairo support"),
            _("Please use a version of the GTK+ Python bindings built with cairo support."),
        )
    if not initiate_videosinks():
        return (
            _("Could not initiate the video output plugins"),
            _("Make sure you have at least one valid video output sink available (xvimagesink or ximagesink)."),
        )
    if not initiate_audiosinks():
        return (
            _("Could not initiate the audio output plugins"),
            _("Make sure you have at least one valid audio output sink available (alsasink or osssink)."),
        )
    if not __try_import_from_gi__("cairo"):
        return (
            _("Could not import the cairo Python bindings"),
            _("Make sure you have the cairo Python bindings installed."),
        )
    if not __try_import_from_gi__("GooCanvas"):
        return (
            _("Could not import the goocanvas Python bindings"),
            _("Make sure you have the goocanvas Python bindings installed."),
        )
    if not __try_import__("xdg"):
        return (_("Could not import the xdg Python library"), _("Make sure you have the xdg Python library installed."))
    req, inst = check_required_version("gtk")
    if req:
        return (
            _("You do not have a recent enough version of GTK+ (your version %s)") % inst,
            _("Install a version of GTK+ greater than or equal to %s.") % req,
        )
    req, inst = check_required_version("pygst")
    if req:
        return (
            _("You do not have a recent enough version of GStreamer Python bindings (your version %s)") % inst,
            _("Install a version of the GStreamer Python bindings greater than or equal to %s.") % req,
        )
    req, inst = check_required_version("gst")
    if req:
        return (
            _("You do not have a recent enough version of GStreamer (your version %s)") % inst,
            _("Install a version of the GStreamer greater than or equal to %s.") % req,
        )
    req, inst = check_required_version("cairo")
    if req:
        return (
            _("You do not have a recent enough version of the cairo Python bindings (your version %s)") % inst,
            _("Install a version of the cairo Python bindings greater than or equal to %s.") % req,
        )
    req, inst = check_required_version("gnonlin")
    if req:
        return (
            _("You do not have a recent enough version of the GNonLin GStreamer plugin (your version %s)") % inst,
            _("Install a version of the GNonLin GStreamer plugin greater than or equal to %s.") % req,
        )
    if not __try_import_from_gi__("GES"):
        # FIXME enable version checking in GES
        return (
            _("Could not import GStreamer Editing Services "),
            _("Make sure you have GStreamer Editing Services installed."),
        )
    if not __try_import__("pkg_resources"):
        return (
            _("Could not import the distutils modules"),
            _("Make sure you have the distutils Python module installed."),
        )

    # The following are soft dependencies
    # Note that instead of checking for plugins using Gst.Registry.get().find_plugin("foo"),
    # we could check for elements using Gst.ElementFactory.make("foo")
    if not __try_import__("numpy"):
        soft_deps["NumPy"] = _("Enables the autoalign feature")
    if Gst.ElementFactory.make("frei0r-filter-scale0tilt", None) is None:
        soft_deps["Frei0r"] = _("Additional video effects")
    if not Gst.Registry.get().find_plugin("libav"):
        soft_deps["GStreamer Libav plugin"] = _("Additional multimedia codecs through the Libav library")
    # Test for gst bad
    # This is disabled because, by definition, gst bad is a set of plugins that can
    # move to gst good or ugly, and we don't really have something to rely upon.
    # if not Gst.Registry.get().find_plugin("swfdec"): # FIXME: find a more representative plugin
    #    soft_deps["GStreamer bad plugins"] = _('Additional GStreamer plugins whose code is not of good enough quality, or are not considered tested well enough. The licensing may or may not be LGPL')
    # Test for gst ugly
    # if not Gst.Registry.get().find_plugin("x264"):
    #    soft_deps["GStreamer ugly plugins"] = _('Additional good quality GStreamer plugins whose license is not LGPL or with licensing issues')

    if not GES.init():
        return (
            _("Could not initialize GStreamer Editing Services"),
            _("Make sure you have the gst-editing-services installed."),
        )

    return None
Exemple #52
0
def simple():
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  
  layer = GES.Layer()
  audiolayer = GES.Layer()
  imagelayer = GES.Layer()
  
  timeline.add_layer(layer)
  timeline.add_layer(audiolayer)
  timeline.add_layer(imagelayer)

  asset1 = GES.UriClipAsset.request_sync(videoFile1)
  asset2 = GES.UriClipAsset.request_sync(videoFile2)
  asset3 = GES.UriClipAsset.request_sync(videoFile3)
  asset4 = GES.UriClipAsset.request_sync(videoFile4)
  musicAsset = GES.UriClipAsset.request_sync(musicFile)
  
  imageasset1 = GES.UriClipAsset.request_sync(imageFile1)
  imageasset2 = GES.UriClipAsset.request_sync(imageFile2)
  imageasset3 = GES.UriClipAsset.request_sync(imageFile3)

  #layer.add_asset(imageasset1, 0 * Gst.SECOND, 0, 1 * Gst.SECOND, GES.TrackType.UNKNOWN)
  layer.add_asset(asset1, 0 * Gst.SECOND, 0, 10  * Gst.SECOND, GES.TrackType.UNKNOWN)
  imagelayer.add_asset(imageasset2, 10 * Gst.SECOND, 0, 2 * Gst.SECOND, GES.TrackType.UNKNOWN)
  layer.add_asset(asset2, 10 * Gst.SECOND, 0, 10 * Gst.SECOND, GES.TrackType.UNKNOWN)
  imagelayer.add_asset(imageasset3, 20 * Gst.SECOND, 0, 2 * Gst.SECOND, GES.TrackType.UNKNOWN)
  layer.add_asset(asset3, 20 * Gst.SECOND, 5 * Gst.SECOND, 10 * Gst.SECOND, GES.TrackType.UNKNOWN)
  layer.add_asset(asset4, 30 * Gst.SECOND, 10 * Gst.SECOND, 30 * Gst.SECOND, GES.TrackType.UNKNOWN)
  audiolayer.add_asset(musicAsset, 0, 0, timeline.get_duration(), GES.TrackType.AUDIO)
  
  timeline.commit()

  pipeline = GES.Pipeline()
  pipeline.add_timeline(timeline)
  
  # Firefox
  #format = ["application/ogg", "video/x-theora", "audio/x-vorbis", "ogv"] # very slow after 20 secs, bugs

  # Chrome
  #format = ["video/webm", "video/x-vp8", "audio/x-vorbis", "webm"] # first element
  
  # Safari
  #format = ["video/quicktime", "video/x-h264", "audio/x-aac", "mp4"] #no start
  
  # MPEG
  #format = ["video/mpeg", "video/mpeg", "audio/mpeg", "mpg"] #no start
  
  # Works
  format = ["video/x-matroska", "video/x-h264", "audio/x-vorbis", "mkv"]
  
  # mkv / mpeg
  #(GError('GStreamer error: negotiation problem.',), 'gstvideoencoder.c(1363): gst_video_encoder_chain (): /GESPipeline:gestimelinepipeline0/GstEncodeBin:internal-encodebin/avenc_mpeg1video:avenc_mpeg1video0:\nencoder not initialized')

  # works, slow after 20 secs, vorbis glitches
  #format = ["video/x-matroska", "video/x-theora", "audio/x-vorbis", "mkv"]
  
  # slow after 20 secs, stream kaputt, very big
  #format = ["video/x-matroska", "video/x-raw", "audio/x-vorbis", "mkv"]
  
  # slower after 20 secs, wrong positioning, output shaky
  #format = ["video/x-matroska", "video/x-dv", "audio/x-vorbis", "mkv"]
  
  container_profile = encoderProfile(format[0], format[1], format[2])
  
  pipeline.set_render_settings(outputFile + "." + format[3], container_profile)
  #pipeline.set_mode(GES.PipelineFlags.RENDER)
  pipeline.set_state(Gst.State.PLAYING)
  
  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect("message", busMessageCb)
  GObject.timeout_add(300, duration_querier, pipeline)
 
  signal.signal(signal.SIGINT, handle_sigint)
  Gtk.main()
Exemple #53
0
def check_hard_dependencies():
    missing_hard_deps = {}

    satisfied, req, inst = _check_dependency("Gst", True)
    if not satisfied:
        missing_hard_deps["GStreamer"] = (req, inst)
    satisfied, req, inst = _check_dependency("Clutter", True)
    if not satisfied:
        missing_hard_deps["Clutter"] = (req, inst)
    satisfied, req, inst = _check_dependency("GES", True)
    if not satisfied:
        missing_hard_deps["GES"] = (req, inst)
    satisfied, req, inst = _check_dependency("cairo", False)
    if not satisfied:
        missing_hard_deps["Cairo"] = (req, inst)
    satisfied, req, inst = _check_dependency("xdg", False)
    if not satisfied:
        missing_hard_deps["PyXDG"] = (req, inst)
    satisfied, req, inst = _check_dependency("Gtk", True)
    if not satisfied:
        missing_hard_deps["GTK+"] = (req, inst)
    satisfied, req, inst = _check_dependency("xdg", False)
    if not satisfied:
        missing_hard_deps["PyXDG"] = (req, inst)
    satisfied, req, inst = _check_dependency("numpy", False)
    if not satisfied:
        missing_hard_deps["NumPy"] = (req, inst)

    # Since we had to check Gst beforehand, we only do the import now:
    from gi.repository import Gst
    Gst.init(None)
    reg = Gst.Registry.get()
    # Special case: gnonlin is a plugin, not a python module to be imported,
    # we can't use check_dependency to determine the version:
    inst = Gst.Registry.get().find_plugin("gnonlin")
    if not inst:
        missing_hard_deps["GNonLin"] = (HARD_DEPS["gnonlin"], inst)
    else:
        inst = inst.get_version()
        if _string_to_list(inst) < _string_to_list(HARD_DEPS["gnonlin"]):
            missing_hard_deps["GNonLin"] = (HARD_DEPS["gnonlin"], inst)

    # GES is checked, import and intialize it
    from gi.repository import GES
    GES.init()

    # Prepare the list of hard deps errors to warn about later:
    for dependency in missing_hard_deps:
        req = missing_hard_deps[dependency][0]
        inst = missing_hard_deps[dependency][1]
        if req and not inst:
            message = "%s or newer is required, but was not found on your system." % req
        elif req and inst:
            message = "%s or newer is required, but only version %s was found." % (req, inst)
        else:
            message = "not found on your system."
        missing_hard_deps[dependency] = message

    # And finally, do a few last checks for basic sanity.
    # Yes, a broken/dead autoaudiosink is still possible in 2012 with PulseAudio
    if not _initiate_videosinks(Gst):
        missing_hard_deps["autovideosink"] = \
            "Could not initiate video output sink. "\
            "Make sure you have a valid one (xvimagesink or ximagesink)."
    if not _initiate_audiosinks(Gst):
        missing_hard_deps["autoaudiosink"] = \
            "Could not initiate audio output sink. "\
            "Make sure you have a valid one (pulsesink, alsasink or osssink)."

    return missing_hard_deps
Exemple #54
0
 def __create_project_filter():
     filter_ = []
     for asset in GES.list_assets(GES.Formatter):
         filter_.append(asset.get_meta(GES.META_FORMATTER_EXTENSION))
     return tuple(filter_)