This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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------------------------- | |
| | | | | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure our elements. | |
audio_source.set_property('location', 'myfile.mp3') | |
equalizer.set_property('band1', -24.0) | |
equalizer.set_property('band2', -24.0) | |
# Add our elements to the pipeline. | |
pipeline.add(audio_source, decode, convert, equalizer, audio_sink) | |
# Link our elements together. | |
if (not gst.element_link_many(audio_source, decode, convert, equalizer, audio_sink)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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-------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
OlderNewer