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 – viewing an existing animation


This is going to be a short exercise. The goal of this section is to develop a primary understanding on use of Pyglet for viewing animations. So let's get on with it.

  1. Download the file SimpleAnimation.py from the Packt website. Also download the file SimpleAnimation.gif and place it in a sub-directory images. The code is illustrated as follows:

    1 import pyglet
    2 
    3 animation = pyglet.image.load_animation(
    4               "images/SimpleAnimation.gif")
    5
    6 # Create a sprite object as an instance of this animation.
    7 animSprite = pyglet.sprite.Sprite(animation)
    8 
    9 # The main pyglet window with OpenGL context
    10 w = animSprite.width
    11 h = animSprite.height
    12 win = pyglet.window.Window(width=w, height=h)
    13
    14 # r,g b, color values and transparency for the background
    15 r, g, b, alpha = 0.5, 0.5, 0.8, 0.5
    16
    17 # OpenGL method for setting the background.
    18 pyglet.gl.glClearColor(r, g, b, alpha)
    19 
    20 # Draw the sprite in the API method on_draw...