Update
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# GStreamer
|
||||
#
|
||||
# Copyright (C) 2013 Thibault Saunier <tsaunier@gnome.org
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
|
||||
# Boston, MA 02110-1335, USA.
|
||||
|
||||
import os
|
||||
from gi.repository import Gst, GES, GLib
|
||||
|
||||
|
||||
class Simple:
|
||||
def __init__(self, uri):
|
||||
timeline = GES.Timeline.new_audio_video()
|
||||
self.project = timeline.get_asset()
|
||||
|
||||
self.project.connect("asset-added", self._asset_added_cb)
|
||||
self.project.connect("error-loading-asset", self._error_loading_asset_cb)
|
||||
self.project.create_asset(uri, GES.UriClip)
|
||||
self.layer = timeline.append_layer()
|
||||
self._create_pipeline(timeline)
|
||||
self.loop = GLib.MainLoop()
|
||||
|
||||
def _create_pipeline(self, timeline):
|
||||
self.pipeline = GES.Pipeline()
|
||||
self.pipeline.set_timeline(timeline)
|
||||
bus = self.pipeline.get_bus()
|
||||
bus.add_signal_watch()
|
||||
bus.connect("message", self.bus_message_cb)
|
||||
|
||||
def bus_message_cb(self, unused_bus, message):
|
||||
if message.type == Gst.MessageType.EOS:
|
||||
print "eos"
|
||||
self.loop.quit()
|
||||
elif message.type == Gst.MessageType.ERROR:
|
||||
error = message.parse_error()
|
||||
print "error %s" % error[1]
|
||||
self.loop.quit()
|
||||
|
||||
def start(self):
|
||||
self.loop.run()
|
||||
|
||||
def _asset_added_cb(self, project, asset):
|
||||
self.layer.add_asset(asset, 0, 0, Gst.SECOND * 5, GES.TrackType.UNKNOWN)
|
||||
self.pipeline.set_state(Gst.State.PLAYING)
|
||||
|
||||
def _error_loading_asset_cb(self, project, error, asset_id, type):
|
||||
print "Could not load asset %s: %s" % (asset_id, error)
|
||||
self.loop.quit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(os.sys.argv) != 2:
|
||||
print "You must specify a file URI"
|
||||
exit(-1)
|
||||
|
||||
Gst.init(None)
|
||||
GES.init()
|
||||
simple = Simple(os.sys.argv[1])
|
||||
simple.start()
|
||||
@@ -0,0 +1,98 @@
|
||||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
# vim: tabstop=4 shiftwidth=4 expandtab
|
||||
#
|
||||
# GES.py
|
||||
#
|
||||
# Copyright (C) 2012 Thibault Saunier <thibault.saunier@collabora.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
|
||||
import sys
|
||||
from ..overrides import override
|
||||
from ..importer import modules
|
||||
from gi.repository import GObject
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
_basestring = str
|
||||
_callable = lambda c: hasattr(c, '__call__')
|
||||
else:
|
||||
_basestring = basestring
|
||||
_callable = callable
|
||||
|
||||
GES = modules['GES']._introspection_module
|
||||
__all__ = []
|
||||
|
||||
if GES._version == '0.10':
|
||||
import warnings
|
||||
warn_msg = "You have imported the GES 0.10 module. Because GES 0.10 \
|
||||
was not designed for use with introspection some of the \
|
||||
interfaces and API will fail. As such this is not supported \
|
||||
by the GStreamer development team and we encourage you to \
|
||||
port your app to GES 1 or greater. static python bindings is the recomended \
|
||||
python module to use with GES 0.10"
|
||||
|
||||
warnings.warn(warn_msg, RuntimeWarning)
|
||||
|
||||
def __timeline_element__repr__(self):
|
||||
return "%s [%s (%s) %s]" % (
|
||||
self.props.name,
|
||||
Gst.TIME_ARGS(self.props.start),
|
||||
Gst.TIME_ARGS(self.props.in_point),
|
||||
Gst.TIME_ARGS(self.props.duration),
|
||||
)
|
||||
|
||||
__prev_set_child_property = GES.TimelineElement.set_child_property
|
||||
def __timeline_element_set_child_property(self, prop_name, prop_value):
|
||||
res, _, pspec = GES.TimelineElement.lookup_child(self, prop_name)
|
||||
if not res:
|
||||
return res
|
||||
|
||||
v = GObject.Value()
|
||||
v.init(pspec.value_type)
|
||||
v.set_value(prop_value)
|
||||
|
||||
return __prev_set_child_property(self, prop_name, v)
|
||||
|
||||
|
||||
GES.TimelineElement.__repr__ = __timeline_element__repr__
|
||||
GES.TimelineElement.set_child_property = __timeline_element_set_child_property
|
||||
GES.TrackElement.set_child_property = GES.TimelineElement.set_child_property
|
||||
GES.Container.edit = GES.TimelineElement.edit
|
||||
|
||||
__prev_asset_repr = GES.Asset.__repr__
|
||||
def __asset__repr__(self):
|
||||
return "%s(%s)" % (__prev_asset_repr(self), self.props.id)
|
||||
|
||||
GES.Asset.__repr__ = __asset__repr__
|
||||
|
||||
def __timeline_iter_clips(self):
|
||||
"""Iterate all clips in a timeline"""
|
||||
for layer in self.get_layers():
|
||||
for clip in layer.get_clips():
|
||||
yield clip
|
||||
|
||||
GES.Timeline.iter_clips = __timeline_iter_clips
|
||||
|
||||
try:
|
||||
from gi.repository import Gst
|
||||
Gst
|
||||
except:
|
||||
raise RuntimeError("GSt couldn't be imported, make sure you have gst-python installed")
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# __init__.py
|
||||
#
|
||||
# Copyright (C) 2012 Thibault Saunier <thibaul.saunier@collabora.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
|
||||
from pkgutil import extend_path
|
||||
|
||||
__path__ = extend_path(__path__, __name__)
|
||||
@@ -0,0 +1,5 @@
|
||||
install_data(['gi/overrides/GES.py'], install_dir: pygi_override_dir)
|
||||
|
||||
env = environment()
|
||||
env.prepend('_GI_OVERRIDES_PATH', meson.current_source_dir() / 'gi/overrides')
|
||||
meson.add_devenv(env)
|
||||
Reference in New Issue
Block a user