it is a known fact that
gstreamer and
clutter are both very cool. so what if we have gstreamer inside clutter, that is cool^2 which equals awesome.
let's go through a simple example
awesome.py. the key of gstreamer inside clutter is the cluttergst python and its VideoSink function.
so you are going to create a gstreamer pipeline (just like we did in the previous blog post
just shoot me), but use the cluttergst.VideoSink instead of gst element xvimagesink and feed that to a clutter.Texture():
import clutter, gst, cluttergst
video_texture = clutter.Texture()
pipeline = gst.Pipeline()
src = gst.element_factory_make("v4l2src", "src")
colorspace = gst.element_factory_make("ffmpegcolorspace", "colorspace")
sink = cluttergst.VideoSink(video_texture)
pipeline.add(src, colorspace, sink)
gst.element_link_many(src, colorspace, sink)
pipeline.set_state(gst.STATE_PLAYING)
now you need a clutter stage with the videotexture in it:
stage = clutter.stage_get_default()
stage.add(video_texture)
stage.set_size(800,600)
wait, this is clutter... let's animate the gstreamer texture! for this you need a clutter timeline, alpha (value as function of time) and behaviour:
timeline = clutter.Timeline(250,50)
timeline.set_loop(True)
alpha = clutter.Alpha(timeline, clutter.sine_half_func)
behaviour = clutter.BehaviourRotate(alpha=alpha, \
angle_start=30.0, angle_end=5.0, axis=clutter.Y_AXIS, \
direction = "ccw")
behaviour.apply(video_texture)
we are ready for the show:
timeline.start()
stage.show_all()
clutter.main()
wasn't that awesome \m/?
now check the example
awesome.py, it has videofile playback and more animation behaviours.