Skip to content

Instantly share code, notes, and snippets.

View markwingerd's full-sized avatar

Mark Wingerd markwingerd

  • San Francisco, CA
View GitHub Profile
@markwingerd
markwingerd / GStreamer Tutorial 1
Last active April 6, 2019 23:20
GStreamer Tutorial 1: Whole Project - Plays an mp3 file
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
GStreamer Tutorial 1: Simple Project
In this tutorial we will receive an mp3 file from our harddrive, manipulate
with an equalizer element, and output that to our speakers.
------------------------pipeline-------------------------
| | | | |
@markwingerd
markwingerd / GStreamer Tutorial 1 - 1 Create Elements
Created November 18, 2014 20:22
GStreamer Tutorial 1: Part 1/3 - Plays an mp3 file
import gst
# Create the pipeline for our elements.
pipeline = gst.Pipeline('pipeline')
# Create the elements for our project.
audio_source = gst.element_factory_make('filesrc', 'audio_source')
decode = gst.element_factory_make('mad', 'decode')
convert = gst.element_factory_make('audioconvert', 'convert')
equalizer = gst.element_factory_make('equalizer-3bands', 'equalizer')
@markwingerd
markwingerd / GStreamer Tutorial 1 - 2 Configure, add, and link elements
Created November 18, 2014 20:22
GStreamer Tutorial 1: Part 2/3 - Plays an mp3 file
@markwingerd
markwingerd / GStreamer Tutorial 1 - 3 Play audio
Created November 18, 2014 20:23
GStreamer Tutorial 1: Part 3/3 - Plays an mp3 file
# Set our pipelines state to Playing.
pipeline.set_state(gst.STATE_PLAYING)
# Wait until error or EOS.
bus = pipeline.get_bus()
msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE,
gst.MESSAGE_ERROR | gst.MESSAGE_EOS)
print msg
# Free resources.
@markwingerd
markwingerd / GStreamer Tutorial 2
Last active August 29, 2015 14:09
GStreamer Tutorial 2: Whole Project - Streams multimedia using Playbin2
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
GStreamer Tutorial 2: Playbin2
In this tutorial we will stream a video from a website using
the playbin2 element, change the video using a solarize element
and output the video. The audio is played by playbin2.
---------------------output_bin--------------------------
@markwingerd
markwingerd / GStreamer Tutorial 2 - 1 Create Bin, Elements, and set Uri
Last active August 29, 2015 14:09
GStreamer Tutorial 2: Part 1/3 - Streams multimedia using Playbin2
import gst
# Create the pipeline and bin
output_bin = gst.Bin('output_bin')
# Create the elements.
media_source = gst.element_factory_make('playbin2', 'media_source')
decode = gst.element_factory_make('decodebin', 'decode')
convert = gst.element_factory_make('autoconvert', 'convert')
solarize = gst.element_factory_make('solarize', 'solarize')
@markwingerd
markwingerd / GStreamer Tutorial 2 - 2 Callback function and linking elements
Created November 19, 2014 23:11
GStreamer Tutorial 2: Part 2/3 - Streams multimedia using Playbin2
# Add elements to our bin
output_bin.add(decode, convert, solarize, video_sink)
# Link decodebin with autoconvert when its source pad has been created.
decode.connect('new-decoded-pad', on_new_decoded_pad)
# Callback function to link decodebin to autoconvert.
def on_new_decoded_pad(dbin, pad, islast):
decode = pad.get_parent()
pipeline = decode.get_parent()
@markwingerd
markwingerd / GStreamer Tutorial 2 - 3 Create pads for output_bin and start playing
Created November 19, 2014 23:26
GStreamer Tutorial 2: Part 3/3 - Streams multimedia using Playbin2
# Create pads for the bin.
decode_pad = decode.get_static_pad('sink')
ghost_pad = gst.GhostPad('sink', decode_pad)
ghost_pad.set_active(True)
output_bin.add_pad(ghost_pad)
# Set media_source's video sink.
media_source.set_property('video-sink', output_bin)
# Set our pipeline state to Playing.
@markwingerd
markwingerd / GStreamer Tutorial 3
Last active April 13, 2016 14:32
GStreamer Tutorial 3: Whole Project - Streams and splits multimedia using Playbin2
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
GStreamer Tutorial 3: Splitting multimedia
In this tutorial we will stream a video from a website using
the playbin2 element, split the audio into different element
chains where we play the audio, show a waveform visualization
of the audio, and record the audio.
@markwingerd
markwingerd / GStreamer Tutorial 3 - 1
Last active August 29, 2015 14:10
GStreamer Tutorial 3: Part 1/4 - Streams and splits multimedia using Playbin2
import gst
# Create the pipeline and bin
output_bin = gst.Bin('output_bin')
# Create the elements.
media_source = gst.element_factory_make('playbin2', 'media_source')
decode = gst.element_factory_make('decodebin', 'decode')
convert = gst.element_factory_make('audioconvert', 'convert')
tee = gst.element_factory_make('tee', 'tee')