the phrygian cap


luisbg

@luisbg

luis@debethencourt.com



Ohloh profile for Luis de Bethencourt
Blogalia




<Agosto 2014
Lu Ma Mi Ju Vi Sa Do
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
             

Creative Commons License


planet gnome
planet ubuntu
alberto ruiz
andy wingo
jeff fortin
slomo's blog
jan schmidt
vincent's random waffle



"all religions, arts and sciences are branches of the same tree. all these aspirations are directed toward ennobling man's life, lifting it from the sphere of mere physical existence and leading the individual towards freedom." albert einstein

awesome (gstreamer * clutter)






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.

8 Comentarios


Referencias (TrackBacks)

URL de trackback de esta historia http://luisbg.blogalia.com//trackbacks/61951

Comentarios

1
De: Flimm Fecha: 2009-02-16 21:50

Why isn't python-clutter included in the Intrepid universe repos?
I tried installing python-clutter from Jaunty's repos, but all awesome.py would give me was a black window. Is it meant to work with your webcam?



2
De: luisbg Fecha: 2009-02-16 22:42

./awesome.py
will use the webcam
./awesome.py -i /path/to/videofile
will play a videofile


don't know about the intrepid repo issue.



3
De: Senko Fecha: 2009-02-17 00:36

There's also cluttergst.VideoTexture that encompasses Texture+Playbin+VideoSink functionality.

tx = cluttergst.VideoTexture()
tx.set_uri(content_uri)
tx.set_playing(True)
bin = tx.get_playbin() # if you want to use the inner Playbin directly



4
De: luisbg Fecha: 2009-02-17 01:11

senko: wow! I didn't knew that. that is brilliant.



5
De: martin Fecha: 2009-07-07 14:52

Using kubuntu jaunty:

$ python clutter.py
Fatal Python error: unable to initialise cluttergst module
Cancelado




6
De: deepsight Fecha: 2010-04-21 18:04

Have you tried having two videos at the same time? i try with one v4l2src and one videotestsrc; they show on the screen but they pause continuously at the same time. Any ideas?



7
De: curcumin Fecha: 2012-03-29 14:21

This one is your one of the nice blog dude I like it very much so I want to keep in touch with your blogs therefore post more blogs and thank you dear for sharing with us such nice information.



8
De: maquinas de bordar Fecha: 2012-03-30 07:54

I like the valuable information you provide in your articles. I’ll bookmark your weblog and check again here frequently. I am quite sure I will learn many new stuff right here! Best of luck for the next!



Nombre
Correo-e
URL
Dirección IP: 54.211.44.195 (46c43863dd)
Comentario

©2007-2013 luis de bethencourt guimera
powered by Blogalia