Book Image

Python Multimedia

By : Ninad Sathaye
Book Image

Python Multimedia

By: Ninad Sathaye

Overview of this book

Multimedia applications are used by a range of industries to enhance the visual appeal of a product. This book will teach the reader how to perform multimedia processing using Python. This step-by-step guide gives you hands-on experience for developing exciting multimedia applications using Python. This book will help you to build applications for processing images, creating 2D animations and processing audio and video. Writing applications that work with images, videos, and other sensory effects is great. Not every application gets to make full use of audio/visual effects, but a certain amount of multimedia makes any application a lot more appealing. There are numerous multimedia libraries for which Python bindings are available. These libraries enable working with different kinds of media, such as images, audio, video, games, and so on. This book introduces the reader to the most widely used open source libraries through several exciting, real world projects. Popular multimedia frameworks and libraries such as GStreamer,Pyglet, QT Phonon, and Python Imaging library are used to develop various multimedia applications.
Table of Contents (13 chapters)
Python Multimedia Beginner's Guide
Credits
About the Author
About the Reviewers
Preface

Time for action – playing an audio: method 1


There are a number of ways to play an audio using Python and GStreamer. Let's start with a simple one. In this section, we will use a command string, similar to what you would specify using the command-line version of GStreamer. This string will be used to construct a gst.Pipeline instance in a Python program.

So, here we go!

  1. Start by creating an AudioPlayer class in a Python source file. Just define the empty methods illustrated in the following code snippet. We will expand those in the later steps.

    1 import thread
    2 import gobject
    3 import pygst
    4 pygst.require("0.10")
    5 import gst
    6
    7 class AudioPlayer:
    8   def __init__(self):
    9     pass
    10  def constructPipeline(self):
    11    pass
    12  def connectSignals(self):
    13    pass
    14  def play(self):
    15    pass
    16  def message_handler(self):
    17    pass
    18
    19 # Now run the program 
    20 player = AudioPlayer()
    21 thread.start_new_thread(player.play, ())
    22 gobject.threads_init()
    23 evt_loop = gobject.MainLoop...