old-www/LDP/intro-linux/html/sect_11_02.html

596 lines
12 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Sound and video playing</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Introduction to Linux"
HREF="index.html"><LINK
REL="UP"
TITLE="Sound and Video"
HREF="chap_11.html"><LINK
REL="PREVIOUS"
TITLE="Audio Basics"
HREF="sect_11_01.html"><LINK
REL="NEXT"
TITLE="Video playing, streams and television watching"
HREF="sect_11_02_04.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Introduction to Linux: </TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sect_11_01.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 11. Sound and Video</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sect_11_02_04.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="sect_11_02"
></A
>11.2. Sound and video playing</H1
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_11_02_01"
></A
>11.2.1. CD playing and copying</H2
><P
>The <EM
>cdp</EM
> package comes with most distributions and provides <B
CLASS="command"
>cdp</B
> or <B
CLASS="command"
>cdplay</B
>, a text-based CD player. Desktop managers usually include a graphical tool, such as the <B
CLASS="command"
>gnome-cd</B
> player in <SPAN
CLASS="application"
>Gnome</SPAN
>, that can be started from a menu.</P
><P
>Be sure to understand the difference between an audio CD and a data CD.
You do not have to mount an audio CD into the file system in order to listen to it. This is because the data on such a CD are not Linux file system data; they are accessed and sent to the audio output channel directly, using a CD player program. If your CD is a data CD containing <TT
CLASS="filename"
>.mp3</TT
> files, you will first need to mount it into the file system, and then use one of the programs that we discuss below in order to play the music. How to mount CDs into the file system is explained in <A
HREF="sect_07_06.html#sect_07_06_05"
>Section 7.5.5</A
>.</P
><P
>The <B
CLASS="command"
>cdparanoia</B
> tool from the package with the same name
reads audio directly as data from the CD, without analog conversions, and writes data to a file or pipe in different formats, of which <TT
CLASS="filename"
>.wav</TT
> is probably the most popular. Various tools for conversion to other formats, formats,
such as <TT
CLASS="filename"
>.mp3</TT
>, come with most distributions or are downloadable as separate packages. The GNU project provides several CD playing, ripping and encoding tools, database managers; see the <A
HREF="http://www.gnu.org/directory/audio/"
TARGET="_top"
>Free Software Directory, Audio section</A
> for detailed information.</P
><P
>Audio-CD creation is eased, among many others, with the <B
CLASS="command"
>kaudiocreator</B
> tool from the KDE suite. It comes with clear information from the KDE Help Center.</P
><P
>CD burning is covered in general in <A
HREF="sect_09_02.html#sect_09_02_02"
>Section 9.2.2</A
>.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_11_02_02"
></A
>11.2.2. Playing music files</H2
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="sect_11_02_02_01"
></A
>11.2.2.1. mp3 files</H3
><P
>The popular <TT
CLASS="filename"
>.mp3</TT
> format is widely supported on Linux
machines. Most distributions include multiple programs that can play these files. Among many other applications, <SPAN
CLASS="application"
>XMMS</SPAN
>, which is presented in the screenshot below, is one of the most wide-spread, partially because it has the same look and feel as the Windows tool.</P
><DIV
CLASS="figure"
><A
NAME="AEN11486"
></A
><P
><B
>Figure 11-1. XMMS mp3 player</B
></P
><DIV
CLASS="mediaobject"
><P
><IMG
SRC="images/xmms.png"></P
></DIV
></DIV
><P
>Also very popular for playing music are <SPAN
CLASS="application"
>AmaroK</SPAN
>, a KDE application that is steadily gaining popularity, and <SPAN
CLASS="application"
>MPlayer</SPAN
>, which can also play movies.</P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>Restrictions</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>Some distributions don't allow you to play MP3's without modifying your configuration, this is due to license restrictions on the MP3 tools. You might need to install extra software to be able to play your music.</P
></TD
></TR
></TABLE
></DIV
><P
>In text mode, you can use the <B
CLASS="command"
>mplayer</B
> command:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>[tille@octarine ~]$ </TT
><B
CLASS="command"
>mplayer <TT
CLASS="filename"
>/opt/mp3/oriental/*.mp3</TT
></B
>
MPlayer 1.0pre7-RPM-3.4.2 (C) 2000-2005 MPlayer Team
CPU: Advanced Micro Devices Duron Spitfire (Family: 6, Stepping: 1)
Detected cache-line size is 64 bytes
CPUflags: MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 0 SSE2: 0
Playing /opt/oldopt/mp3/oriental/Mazika_Diana-Krozon_Super-Star_Ensani-Ma-
Bansak.mp3.
Cache fill: 1.17% (98304 bytes) Audio file detected.
Clip info:
Title: Ensani-Ma-Bansak.mp3
Artist: Diana-Krozon
Album: Super-Star
Year:
Comment:
Genre: Unknown
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
mpg123: Can't rewind stream by 450 bits!
AUDIO: 44100 Hz, 2 ch, s16le, 160.0 kbit/11.34% (ratio: 20000-&#62;176400)
Selected audio codec: [mp3] afm:mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
Checking audio filter chain for 44100Hz/2ch/s16le -&#62; 44100Hz/2ch/s16le...
AF_pre: 44100Hz/2ch/s16le
AO: [oss] 44100Hz 2ch s16le (2 bps)
Building audio filter chain for 44100Hz/2ch/s16le -&#62; 44100Hz/2ch/s16le...
Video: no video
Starting playback...
A: 227.8 (03:23:.1) 1.8% 12%
</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="sect_11_02_02_02"
></A
>11.2.2.2. Other formats</H3
><P
>It would lead us too far to discuss all possible audio formats and ways to play them. An (incomplete) overview of other common sound playing and manipulating software:</P
><P
></P
><UL
><LI
><P
>Ogg Vorbis: Free audio format: see <A
HREF="http://www.gnu.org/directory/audio/ogg/"
TARGET="_top"
>the GNU audio directory</A
> for tools - they might be included in your distribution as well. The format was developed because MP3 is patented.</P
></LI
><LI
><P
>Real audio and video: <B
CLASS="command"
>realplay</B
> from <A
HREF="http://real.com"
TARGET="_top"
>RealNetworks</A
>.</P
></LI
><LI
><P
>SoX or Sound eXchange: actually a sound converter, comes with th
e <B
CLASS="command"
>play</B
> program. Plays <TT
CLASS="filename"
>.wav</TT
>, <TT
CLASS="filename"
>.
ogg</TT
> and various other formats, including raw binary formats.</P
></LI
><LI
><P
>Playmidi: a MIDI player, see the GNU directory.</P
></LI
><LI
><P
>AlsaPlayer: from the Advanced Linux Sound Architecture project,
see the <A
HREF="http://www.alsaplayer.org"
TARGET="_top"
>AlsaPlayer web site</A
>.</P
></LI
><LI
><P
><B
CLASS="command"
>mplayer</B
>: plays just about anything, including
mp3 files. More info on the <A
HREF="http://www.mplayerhq.hu/"
TARGET="_top"
>MPlayerHQ website</A
>.</P
></LI
><LI
><P
><B
CLASS="command"
>hxplay</B
>: supports RealAudio and RealVideo, mp3, mp4 audio, Flash, wav and more, see <A
HREF="http://www.helixdna.com"
TARGET="_top"
>HelixDNA</A
> (not all components of this software are completely free).</P
></LI
><LI
><P
><B
CLASS="command"
>rhythmbox</B
>: based on the <SPAN
CLASS="application"
>GStreamer</SPAN
> framework, can play everything supported in <SPAN
CLASS="application"
>GStreamer</SPAN
>, which claims to be able to play everything, see the <A
HREF="http://www.rhythmbox.org"
TARGET="_top"
>Rhythmbox</A
> and <A
HREF="http://gstreamer.freedesktop.org"
TARGET="_top"
>GStreamer</A
> sites.</P
></LI
></UL
><P
>Check your system documentation and man pages for particular tools and detailed explanations on how to use them.</P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>I don't have these applications on my system!</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>A lot of the tools and applications discussed in the above sections are optional software. It is possible that such applications are not installed on your system by default, but that you can find them in your distribution as additional packages. It might also very well be that the application that you are looking for is not in your distribution at all. In that case, you need to download it from the application's web site.</P
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="sect_11_02_02_03"
></A
>11.2.2.3. Volume control</H3
><P
><B
CLASS="command"
>aumix</B
> and <B
CLASS="command"
>alsamixer</B
> are two common text tools for adjusting audio controls. Use the arrow keys to toggle settings. The <B
CLASS="command"
>alsamixer</B
> has a graphical interface when started from the <SPAN
CLASS="application"
>Gnome</SPAN
> menu or as <B
CLASS="command"
>gnome-alsamixer</B
> from the command line. The <B
CLASS="command"
>kmix</B
> tool does the same in KDE.</P
><P
>Regardless of how you choose to listen to music or other sounds, remember that there may be other people who may not be interested in hearing you or your
computer. Try to be courteous, especially in office environments. Use a quality head-set, rather than the ones with the small ear pieces. This is better for your ears and causes less distraction for your colleagues.</P
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_11_02_03"
></A
>11.2.3. Recording</H2
><P
>Various tools are again available that allow you to record voice and music. For recording voice you can use <B
CLASS="command"
>arecord</B
> on the command line:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>alexey@russia:~&#62;</TT
> <B
CLASS="command"
>arecord <TT
CLASS="filename"
>/var/tmp/myvoice.wav</TT
></B
>
Recording WAVE '/var/tmp/myvoice.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
Aborted by signal Interrups...
</PRE
></FONT
></TD
></TR
></TABLE
><P
><SPAN
CLASS="QUOTE"
>"Interrupt"</SPAN
> means that the application has caught a <B
CLASS="keycap"
>Ctrl</B
>+<B
CLASS="keycap"
>C</B
>. Play the sample using the simple <B
CLASS="command"
>play</B
> command.</P
><P
>This is a good test that you can execute prior to testing applications that need voice input, like Voice over IP (VoIP). Keep in mind that the microphone input should be activated. If you don't hear your own voice, check your sound settings. It often happens that the microphone is muted or on verry low volume. This can be easily adjusted using <B
CLASS="command"
>alsamixer</B
> or your distribution-specific graphical interface to the sound system.</P
><P
>In KDE you can start the <B
CLASS="command"
>krec</B
> utility, <SPAN
CLASS="application"
>Gnome</SPAN
> provides the <B
CLASS="command"
>gnome-sound-recorder</B
>.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sect_11_01.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sect_11_02_04.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Audio Basics</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="chap_11.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Video playing, streams and television watching</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>