Skip to main content

An ergonomic interface over GStreamer

Project description

Candyfloss

Candyfloss is an ergonomic interface to GStreamer. It allows users to build and run pipelines to decode and encode video files, extract video frames to use from python code, map python code over video frames, etc.

Installation

Candyfloss is installable by running setup.py in the normal way. It should also be available on PyPI soon.

Candyfloss requires that gstreamer is installed. Most desktop linux distros have it installed already. If you aren't on linux or don't have it installed check the GStreamer install docs here. In addition to the installation methods mentioned there if you're on macos you can install it with homebrew by running brew install gstreamer.

Examples

# scale a video file to 300x300

from candyfloss import Pipeline
from candyfloss.utils import decode_file

with Pipeline() as p:

    inp_file = p >> decode_file('input.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 >> decode_file('input.webm')):
    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'
# display random noise frames in a window

from candyfloss import Pipeline
from candyfloss.utils import display_video
from PIL import Image
import numpy as np

def random_frames():
    rgb_shape = (300, 300, 3)
    while 1:
        mat = np.random.randint(0, 256, dtype=np.uint8, size=rgb_shape)
        yield Image.fromarray(mat)

with Pipeline() as p:
    p.from_iter(random_frames(), (300, 300)) >> display_video()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

candyfloss-0.0.1.tar.gz (12.3 kB view details)

Uploaded Source

File details

Details for the file candyfloss-0.0.1.tar.gz.

File metadata

  • Download URL: candyfloss-0.0.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for candyfloss-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dc4a17da4a29a616d6bf050f15b6c83fe86f5cc3d9921b4a42e2a15b1228045c
MD5 113ac15316e36f902a026cf11661c750
BLAKE2b-256 1e5bc1498da16fb36fb552acc5169e3da296496dbeee684de09a697602bb8994

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page