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 3 - 4
Last active February 16, 2017 18:26
GStreamer Tutorial 3: Part 4/4 - Streams and splits 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 audio sink.
media_source.set_property('audio-sink', output_bin)
# Set our pipeline state to Playing.
@markwingerd
markwingerd / GStreamer Tutorial 3 - 3
Created November 20, 2014 22:51
GStreamer Tutorial 3: Part 3/4 - Streams and splits multimedia using Playbin2
# Request pads to manually link the tee Element.
tee_audio_pad = tee.get_request_pad('src%d')
tee_wavescope_pad = tee.get_request_pad('src%d')
tee_file_pad = tee.get_request_pad('src%d')
print 'Obtained request pad %s for audio branch.'% tee_audio_pad.get_name()
print 'Obtained request pad %s for audio branch.'% tee_wavescope_pad.get_name()
print 'Obtained request pad %s for audio branch.'% tee_file_pad.get_name()
# Manually link the tee pads to the queue pads.
queue_audio_pad = audio_queue.get_static_pad('sink')
@markwingerd
markwingerd / GStreamer Tutorial 3 - 2
Last active August 29, 2015 14:10
GStreamer Tutorial 3: Part 2/4 - Streams and splits multimedia using Playbin2
# Add elements to our bin
output_bin.add(decode, convert, tee, audio_queue, audio_sink, wavescope_queue,
wavescope_visual, wavescope_convert, wavescope_sink, file_queue,
file_encode, file_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):
@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')
@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 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 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 - 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
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 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.