Candyfloss: an eDSL sugar python library for gstreamer

candyfloss is a set of python bindings to GStreamer.

examples:


# scale a video file to 300x300

from candyfloss import Pipeline

with Pipeline() as p:

    inp_file = p >> ['uridecodebin', {'uri':'file:///tmp/inp.mp4'}]
    scaled_video = inp_file >> 'videoconvert' >> 'videoscale' >> ('video/x-raw', {'width':300,'height':300})

    mux = p >> 'mp4mux'
    scaled_video >> 'x264enc' >> mux
    inp_file >> 'avenc_aac' >> mux
    mux >> ['filesink', {'location':'output.mp4'}]



# iterate over frames from a video file

from candyfloss import Pipeline

for frame in Pipeline(lambda p: p >> ['filesrc', {'location':'input.webm'] >> 'decodebin')):
    frame.save('frame.jpeg') # frame is a PIL image



# display your webcam with the classic emboss effect applied

from candyfloss import Pipeline
from PIL import ImageFilter

with Pipeline() as p:
    p >> 'autovideosrc' >> p.map(lambda frame: frame.filter(ImageFilter.EMBOSS)) >> 'autovideosink'

It aims to give you a few things over calling GStreamer from PyGObject:

  • providing a higher level and more pythonic interface than what you can easily get on top of PyGObject
  • moving the abstraction boundary between python and Gst/GObject code higher up reduces the amount of GObject implementation details that end up leaking up into application code
  • designing the python syntax and the C bindings together lets us provide a more pythonic interface where you can do most things without implementing custom GstElement’s

I’ve been using it for a while for my own projects and I’d love to hear what other people think.