Enjoying Multimedia


Multimedia makes computing fun, whether it's music, video, images, or any combination of these. While it's doubtful that you'll ever use Knoppix as a true multimedia box acting as the hub of your digital life, it's still really cool that this Live CD comes with software that you can use to enjoy your multimedia files. Let's walk through the highlights of the software, taking brief looks at some of the best multimedia on any OS, not just Linux.

Listening to Sound

Noise. Notes. Speech. Lines from a movie. Verses from a song. With Knoppix, you can hear it all and change it as well.

Listening to Music with XMMS

Linux users have a huge variety of audio players from which to choose, with more coming out every day, but Knoppix includes an old standby that many people still use and rely upon: XMMS, the X Multimedia System.

Open XMMS from the K menu by selecting Multimedia XMMS. To use XMMS effectively, you need to be able to see it, and by default the interface is built for folks with perfect eyes who are also looking at the program through powerful electron microscopes. Right-click on a blank area of the program and select Options DoubleSize. That's much better! Once you master XMMS and its interface, you can go back to the regular size, but for now, use the enlarged view.

Besides the main XMMS window, you really need to display the Playlist Editor window, so click the PL button (or right-click on the program and choose Playlist Editor). The Playlist Editor window opens, docked to XMMS. Resize the playlist by grabbing the bottom right corner and dragging it so that it's bigger. That makes it easier to see the songs that you have queued. Figure 1-9 shows XMMS with a docked Playlist Editor.

image from book
Figure 1-9: XMMS is simple and effective.

XMMS plays tunes in a wide variety of formats, including MP3, OGG (a patent-free alternative to MP3 — and it sounds better, too!), WAV, and CD audio (in fact, XMMS plays videos in the MPEG format as well). You can add songs to the XMMS playlist by clicking on the +FILE icon, which opens a Load Files dialog box. Navigate to your music, find the files you want to hear, select them, close the dialog, and click the Play button in XMMS. Assuming that your sound card is supported, you should hear your music.

Here's another way to add music to your playlist: Open the Konqueror file manager, navigate to your songs, select the ones you want to hear, and drag them onto the XMMS playlist. Much easier, especially if you always have Konqueror open to manage files.

XMMS isn't a complicated program. If you've ever used any audio player on a computer, you'll probably figure out XMMS pretty quickly. If you get stuck, or you just want to learn more about XMMS, as well as download skins and plug-ins, visit the project's home page at http://www.xmms.org.

Editing Sound Files with Audacity

Audacity is a free audio recorder and editor that can import digital audio files, manipulate them in an astonishing variety of ways, and then export them. Before you can use Audacity, though, you need a sound file to edit. The sidebar "Converting MP3s to WAVs" explains how you can acquire a sound file.

Once you have a sound file, open Audacity (see Figure 1-10) from the K menu by selecting Multimedia Audacity.

image from book
Figure 1-10: Audacity, when you first open it

image from book
Converting MP3s to WAVs

At IT Conversations (http://www.itconversations.com), you can listen to streaming audio of interviews and talks by some of the leading thinkers in technology. Streaming audio is cool, but we prefer to have files on our machine for convenience; fortunately, IT Conversations also makes everything available as a download in MP3 format. You can download a bunch of MP3 files, but some of us can't listen to someone talk while we try to write and work!

You can, however, convert the MP3s into CD audio, so you can listen to the interviews and talks while you're driving around in your car (if the CD player in your car handles MP3s, you can skip this section). To convert the MP3s into WAVs, run the following script, which you can name mp32wav and place in your ~/bin directory:

     for i in *.[mM][pP]3 ; do       # convert uppercase to lowercase & space to underscore       name=$(echo $i | tr '[A-Z ]' '[a-z_]')       # replace .mp3 with .wav       name=${name//.mp3/.wav}       # convert mp3 to wav       mp3-decoder $i --wav $name     done 
Caution 

WAV files are a lot bigger than MP3 files, so make sure you have enough space on your hard drive. A rough rule of thumb is that every 1MB of an MP3 will turn into 10MB of a WAV. Knoppix uses your RAM as its "hard drive," and you may quickly use it up if you're not careful. Run df -h to see how much space you have available on your /ramdisk. If you don't have a lot of RAM, check how much is available on one of your "real" hard drives. If you see that you have space on a "real" hard drive, mount it with write access (right-click on the icon on the Knoppix desktop, select Properties, go to the Device tab, uncheck Read only, and mount the drive).

At the end of the process, you should have several WAV files that you could burn to a CD-R/W to listen to in your car (to find out how to burn them, see the "Burning CDs with K3b" section later in this chapter). Keep an eye on your available space, though. When we tried to burn the WAV for Professor Clayton Christensen's "Capturing the Upside" (available from http://www.itconversations.com/shows/detail135.html), however, it was too big—in fact, at 1 hour and 48 minutes, his talk would take almost two CDs!

image from book

Tip 

If you get an error message when you first open Audacity informing you Error Initializing Audio: There was an error initializing the audio i/o layer. You will not be able to play or record audio. Error: Host error, another program is using your sound card. Are you listening to music with XMMS? Close it! Are your system alert sounds beeping and booping? Turn them off (from the K menu, select Control Center Sound & Multimedia System Notifications, check the box next to Apply To All Applications, and click Turn Off All Sounds)! For more help on this issue, see http://www.audacityteam.org/wiki/index.pl?LinuxIssues.

With Audacity running, open your sound file. (We opened clayton_christensen__capturing_the_upside.wav by selecting File Open and navigating to the file.) Audacity imports the file — slowly, because it's a big one — and displays it as shown in Figure 1-11.

image from book
Figure 1-11: Audacity with a WAV file, open and ready to edit

The entire file is visible, with the waveform showing the progress of the audio. For this example, we want to break the file roughly in half, say around the first hour mark, at a nice pause (and not just cut Prof. Christensen off in the middle of a sentence). Click somewhere near the hour mark and then click the Play button. When you hear what sounds like a good place to stop, click the Pause button, hold down the Shift key, and press and hold the left arrow key until the cursor gets all the way back to the beginning of the WAV file. (You can use the mouse, although it does have a tendency to slip and you end up cutting off the speaker in the middle of a thought.) Be sure to click the Stop button in Audacity before continuing or you won't be able to use the Edit menu. With the first hour selected, choose Edit Cut, immediately choose File New, and, in the new window, choose Edit Paste.

Tip 

If the new waveform doesn't look like it did just a few seconds before, that's because Audacity has spread this new one out — if you scroll to the right, you can see the whole file. To return to the previous view, go to View Fit in Window, and everything is scrunched together again.

To save the new WAV file, select File Export As WAV, navigate to the location where you want to save the file, and enter an appropriate filename; for this example, that might be clayton_christensen_-_capturing_the_upside_1.wav (remember that it was taken from the beginning of the original file, so it's now part one).

Close this file and go back to the original. Once again, select File Export As WAV, navigate, and save the file as clayton_christensen_-_capturing_the_upside_2.wav (because it's the second half of the original file). The original WAV file isn't needed any longer, so you can delete it to reclaim that disk space.

Now there are two files of CD-burnable length; you can burn them both using K3b (discussed later in this chapter) and enjoy Prof. Christensen's brilliant observations in your car during those long road trips. That's just one of the many, many things possible with Audacity. To use the program to the maximum of its capabilities, you really need to investigate Audacity further. You can start with a visit to Audacity's home page at http://audacity.sourceforge.net, and then move on to a Google search for "audacity tutorial." You'll find a lot of great stuff.

Viewing Images

Who doesn't like importing and viewing pictures of their friends? And then using software to distort their friends' heads so they look like yumpkin-headed freaks before emailing the results to other friends? Yes, Knoppix makes it all possible. In fact, that's its new motto: "Knoppix: Making Yumpkin-Heads Possible for Years." OK, that part's a silly joke — but the rest is true. Honest!

Using Kuickshow

When it's time to view pictures, you're looking for three things: speed, wide compatibility with a variety of image formats, and the capability to automatically resize an image when it's larger than the monitor. Knoppix comes with Kuickshow (see Figure 1-12), a program that nicely meets those three goals. Open Kuickshow from the K menu by selecting Graphics Kuickshow:

image from book
Figure 1-12: Kuickshow, open and ready to display pictures

Theoretically, once Kuickshow is open, you choose File Open and navigate to the image you want to see, select it, and then view it in Kuickshow. In reality, many folks use the Konqueror file manager to navigate to the image they want, right-click it, and select Open With Kuickshow. Kuickshow opens, displaying the image. If you want to view other images in the directory, the quickest way is to press PgDn/Page Down on your keyboard to view the next image, and PgUp/ Page Up to view the previous image.

There aren't any menus visible in Kuickshow, because it's kind of a bare-bones app. You can, however, make a few changes to the image you're viewing in Kuickshow. To see your options, right-click the image and take a look at the contextual menu (shown in Figure 1-13).

image from book
Figure 1-13: The Kuickshow contextual menu offers many options.

Everything is pretty self-explanatory in this menu, so it's easy to use. Don't forget that it's available at any time with a simple right-click.

Editing Images with GIMP

Think of the GIMP (the GNU Image Manipulation Program) as an attempt to create an opensource PhotoShop. Now, it's not there yet but it's getting better all the time, and it's probably good enough for the needs of at least 90 percent of users. Certainly, if you're using Knoppix to perform some quick ‘n’ dirty work, you'll find that the GIMP is probably just right. You'll also find that it's a big, complicated program, worthy of a book on its own. There is no way to cover even a fraction of the GIMP's capabilities here, but we'll point out a couple of things to whet your interest in this fascinating addition to Knoppix.

From the K menu, select Graphics GIMP Image Editor and then open an image from within the program, right-click an image, and choose Open With. Unfortunately, KDE in Knoppix isn't set to include the GIMP by default in the list of Open With programs, so you need to add it. Here's how: Select Open With Other. The Open With window appears. Click the + next to Graphics to expand it, and then choose GIMP Image Editor. Before you click OK, check the box next to Remember Application Association for This Type of File if you plan to use the GIMP quite a bit.

GIMP displays an image much like what's shown in Figure 1-14. (This particular image is of Libby, a wonderful dog of one of the authors, back when she was a puppy.)

image from book
Figure 1-14: The GIMP, ready to edit an image of a really cute little dog

Three windows are open. From left to right, they are the main toolbox, which contains the basic tools you use to work on your images; the image window, containing the picture you're manipulating; and a window containing several panels joined together, including Layers, Channels, Paths, Brushes, Patterns, and Gradients (let's call it the dialog window). Notice the menus — the main toolbox has the highest-level menus that govern the image in general, the image window contains all the goodies that enable you to change the image in an almost bewildering variety of ways, while the dialog window lacks menus, which is just fine.

If you know PhotoShop or Fireworks or any other image-manipulation program, then dive into the GIMP and start discovering where it has placed the equivalents to the commands you know. Don't expect to find everything — as mentioned earlier, the GIMP isn't yet up to the capabilities of the proprietary programs, but it's gaining fast.

If your experience with image manipulation is neither deep nor broad), check out the GIMP's Website (http://www.gimp.org) for documentation and just start playing. Jump in with a picture on which you can test techniques and see what happens.

Although most people end up using the GIMP simply to crop and resize images, here's one cool trick that shows you how powerful the program really is. The two most fun menus are Filters and Script-Fu: Filters apply pre-made changes to your picture that alter how it looks, with effects involving light, distortion, and colors; and Script-Fu enables developers to write scripts that perform several actions on a photo, changing it in amazing ways, especially for those of us who don't really know what we're doing. You can access one of our favorites by selecting Script-Fu Decor Old Photo. Use the dialog box that appears to make some selections and then click OK. The result is truly cool. Figure 1-15 shows the Script-Fu'd picture of Libby, which looks like it was taken around the turn of the century (not the most recent one).

image from book
Figure 1-15: That same really cute little dog, circa 1900

The changes are kind of hard to see in a book with grayscale images, so you just have to try it out for yourself. There are a lot more where that came from — enough to make it possible even for someone who isn't a graphics expert to do some cool things, thanks to a great program, clever programming, and some welcome hand-holding. Acquaint yourself at least a little bit with the GIMP: It's the open-source gold standard for image manipulation.

Note 

For more information on the GIMP, check out the program's Website at http://www.gimp.org. Users have written a lot about the GIMP online; search Google and you're sure to find much more information about virtually every aspect of the app.

Manipulating Graphics via the Command Line with ImageMagick

The GIMP is a great program, but it's a GUI app. If you want speed or scriptability, turn to ImageMagick, a command-line program that is amazingly comprehensive and powerful.

Note 

man imagemagick tells you just about everything you can do with the program. There's a lot there, and it bears your careful reading. For more info, see the program's Website, at http://www.imagemagick.org.

Let's look at a couple of ways that you can use ImageMagick. It is hoped that these will start to give you some ideas that will inspire you to do far cooler things (if you develop something, share it with us — we're always looking to add new tricks to our toolbox).

Here's an example. In preparing this book, we took a lot of screenshots. We could use KDE's screen capture utility, KSnapshot (available from the K menu by selecting Graphics More Applications KSnapshot), but it doesn't save files in TIFF format, which is what our publishers want. So we used ImageMagick and the following six lines, inserted at the bottom of the .bashrc file in /home/knoppix:

 # take screenshot of chosen window, incl. kde frame alias window='sleep 3; import -depth 8 -frame window.tif' # take screenshot of selected area alias selection='sleep 3; import -depth 8 selection.tif' # take screenshot of entire screen alias screenshot='sleep 3; import -depth 8 -window root screen.tif' 
Note 

After adding these lines to .bashrc, don't forget to run source ~/.bashrc so you can immediately begin using your new commands.

The sleep 3 command gives you three seconds to get things set up before the screenshot is taken; if you need more (or less) time, change the number. The import command, part of ImageMagick, does the real work. It grabs an image of the window, a selection of the screen that you specify by clicking and dragging a box, or the entire screen, depending on the name of the file at the end of the command. If you don't want the image to be a TIFF, change the extension to .jpg, .gif, or whatever else you'd like.

Tip 

We used -depth 8 in the command because if you don't, ImageMagick takes a 16-bit TIFF image, which causes the GIMP and other image programs in Knoppix to complain. If you're not saving the image as a TIFF, remove the depth option.

Here's another way you can use ImageMagick: to convert a lot of images from one format to another. If you have a folder full of TIFFs that you want to convert to JPGs, for example, cd to the directory containing the images and run the following:

 for i in *.tif ; do convert "$i" "${i%.tif}.jpg" ; rm $i ; done 

This is a for loop that works on every TIFF in the directory. It converts the file from a TIFF to a JPEG, and removes the original TIFF image to keep things neat and clean. Don't want the original file removed? Then get rid of rm $i ; and the original TIFF will remain.

If you'll be using this command a lot, turn it into an alias. If you want the freedom to use different image formats on the fly, create an executable file, named converting or something like that, in your ~/bin directory, place the following line in the file, and save it:

 for i in *.$1 ; do convert "$i" "${i%.$1}.$2" ; rm $i ; done 

Notice that you're including variables now. To use your script, run the following command:

 $ converting tif jpg 

tif replaces $1, and jpg replaces $2 in the script. Want to convert a batch of PNGs to GIFs? Use converting png gif instead, and so on.

The final ImageMagick example is one that one of us wrote one night to offer some digital photos on a Website for people to download and use as wallpaper. You can try it too: Gather 50 or so images and begin opening each one in the GIMP, saving the original image in several different common desktop dimensions, including 1024 × 768, 800 × 600, and 640 × 480. You might also want a thumbnail image of about 200 × 150 so folks could have an idea of the image before they start downloading it. You want the JPEGs to be of the highest quality, except for the thumbnails, which don't need to look as nice.

Manually changing multiple images is boring and tedious, so use the following script, which you can place in a file named photoresize in the ~/bin directory:

 for i in *.jpg ; do width=$(identify "$i" | sed -re 's/^.* ([0-9]+)x[0-9]+ . image from book *$/\1/g' ) i="${i%.jpg}" if test $width -eq 1600 ; then for size in 1600x1200 1024x768 800x600 640x480 ; do convert "$i.jpg" -resize $size -compress none -quality image from book     100 "${i}_${size}.jpg" done size=200x150 convert "$i.jpg" -resize $size -compress JPEG -quality image from book     75 "${i}_${size}.jpg"   fi done 

After making it executable with chmod 744 photoresize, the script ran perfectly. Most of our images were 1600 × 1200, but not all. We needed some way to only work with the largest images, and the identify command was it. Running identify sample.jpg gives you information about the image that looks like this: sample.jpg JPEG 1600x1200 DirectClass 8-bit 641kb 0.0u 0:01. Now you know the dimensions, but if you only care about the width, that's where sed (stream editor, an old Unix command) comes in.

Basically, sed and some regular expression work get the number that corresponds to the width of the original image and write that number to the width variable.

Note 

For more on regular expressions, see Andrew Watt's Beginning Regular Expressions at (http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764574892.html).

Now the script performs a test: Does the number in the width variable equal 1600? If not, nothing happens, and the image is skipped. If it does match, the oh-so-versatile convert command kicks in and changes the dimensions of each image, while also using the highest quality and no compression. Each file is renamed to include the dimensions in the filename to make things clear.

Tip 

Yes, convert can change more than just file types and dimensions. In fact, it can do a whole lot more. man convert should be your next stop.

When the whole process is finished, you'll have a nice collection of photographs in a variety of common dimensions, ready for upload to a Website to be shared (under a Creative Commons license!) with anyone. If you'd like to see one of the author's, head to http://www.granneman.com/personal/photos/. Every photo on those pages appears courtesy of ImageMagick.

Watching Video

Digital movies have been getting more and more popular over the last several years as the Internet pipes coming into our homes and businesses have been getting larger and faster. Although ultimately limited in a few key ways, Knoppix enables you to listen to and watch those movies and videos.

Checking Out Video with xine

xine is hardly my favorite video player, for a simple reason: Its UI is pretty bad. Don't get us wrong: The underlying xine video engine is great, but the xine interface is almost baffling in its complexity and lack of clues and feedback. Regardless, that's what Knoppix includes, and so that's what we'll peek at.

Note 

You can use APT to install other video players with better UIs. In particular, check out mplayer, Kaffeine, or Totem.

Open xine from the K menu by selecting Multimedia Video xine media player, but you'll probably use it more often by right-clicking a video file and choosing Open With xine. Figure 1-16 shows a video file opened in xine.

image from book
Figure 1-16: Xine, playing Thomas A. Edison's "May Irwin Kiss" (1896)

To control playback, right-click the movie and use the items in the menu. Although xine is pretty simple, it's simply not very pretty to use.



Hacking Knoppix
Hacking Knoppix (ExtremeTech)
ISBN: 0764597841
EAN: 2147483647
Year: 2007
Pages: 118

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net