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

Preface

Multimedia applications are used in a broad spectrum of fields. 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 very appealing.

This book is all about multimedia processing using Python. This step by step guide gives you a hands-on experience with developing exciting multimedia applications. You will build applications for processing images, creating 2D animations and processing audio and video.

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 some of these (open source) libraries through several implausibly exciting projects. Popular multimedia frameworks and libraries, such as GStreamer, Pyglet, QT Phonon, and Python Imaging library are used to develop various multimedia applications.

What this book covers

Chapter 1, Python and Multimedia teaches you a few things about popular multimedia frameworks for multimedia processing using Python and shows you how to develop a simple interactive application using PyGame.

Chapter 2, Working with Images explains basic image conversion and manipulation techniques using the Python Imaging Library. With the help of several examples and code snippets, we will perform some basic manipulations on the image, such as pasting an image on to another, resizing, rotating/flipping, cropping, and so on. We will write tools to capture a screenshot and convert image files between different formats. The chapter ends with an exciting project where we develop an image processing application with a graphical user interface.

Chapter 3, Enhancing Images describes how to add special effects to an image using Python Imaging Library. You will learn techniques to enhance digital images using image filters, for example, reducing 'noise' from a picture, smoothing and sharpening images, embossing, and so on. The chapter will cover topics such as selectively changing the colors within an image. We will develop some exiting utilities for blending images together, adding transparency effects, and creating watermarks.

Chapter 4, Fun with Animations introduces you to the fundamentals of developing animations using Python and Pyglet multimedia application development frameworks. We will work on some exciting projects such as animating a fun car out for a ride in a thunderstorm, a 'bowling animation' with keyboard controls, and so on.

Chapter 5, Working with Audios teaches you how to get to grips with the primer on GStreamer multimedia framework and use this API for audio and video processing. In this chapter, we will develop some simple audio processing tools for 'everyday use'. We will develop tools such as a command-line audio player, a file format converter, an MP3 cutter and audio recorder.

Chapter 6, Audio Controls and Effects describes how to develop tools for adding audio effects, mixing audio tracks, creating custom music tracks, visualizing an audio track, and so on.

Chapter 7, Working with Videos explains the fundamentals of video processing. This chapter will cover topics such as converting video between different video formats, mixing or separating audio and video tracks, saving one or more video frames as still images, performing basic video manipulations such as cropping, resizing, adjusting brightness, and so on.

Chapter 8, GUI-based Media Players using QT Phonon takes you through the fundamental components of the QT Phonon framework. We will use QT Phonon to develop audio and video players using a graphical user interface.

Who this book is for

Python developers who want to dip their toes into working with images, animations, and audio and video processing using Python.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Time for action – heading

  1. Action 1

  2. Action 2

  3. Action 3

Instructions often need some extra explanation so that they make sense, so they are followed with:

What just happened?

This heading explains the working of tasks or instructions that you have just completed.

You will also find some other learning aids in the book, including:

Pop quiz – heading

These are short multiple choice questions intended to help you test your own understanding.

Have a go hero – heading

These set practical challenges and give you ideas for experimenting with what you have learned.

You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The dictionary self.addedEffects keeps track of all the audio."

A block of code is set as follows:

1 def __init__(self):
2  self.constructPipeline()
3  self.is_playing = False
4  self.connectSignals()

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

1 def constructPipeline(self):
2   self.pipeline = gst.Pipeline()
3   self.filesrc = gst.element_factory_make(
4                  "gnlfilesource")

Any command-line input or output is written as follows:

>>>import pygst

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "You will need to tweak the Effects menu UI and make some other changes in the code to keep track of the added effects."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Tip

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.