2. Overview
Objective
Learn how to convert audio files using PVAudio class
Requirements
Installed version of ffmpeg
Understanding of ffmpeg from the ffmpeg tutorial
Understanding of the defines
Estimated Time
10 minutes
www.prodigyview.com
3. Follow Along With A Code
Example
1. Download a copy of the example code at
www.prodigyview.com/source.
2. Install the system in an environment you feel
comfortable testing in.
3. Proceed to examples/avi/Audio_Conversion.php
http://www.prodigyview.com
4. Basic Conversion
Basic conversion of audio files can be accomplished with
the PVAudio class. We simply pass in the file the be
converted and the location to save the outputted file.
1. Location of the file to be converted
2. Location and name of the outputted file
www.prodigyview.com
5. Converting Formats
Converting formats is very simple. The only thing that needs to
be done changing the extension of the output file, and the
format will be automatically changed. Remember that our
original file was an .mp3
Change the extension to change the format of the file
www.prodigyview.com
6. Add Options
Our next step is adding options. Options can be added to
both the input and output files. In our example, we are
going to add options to the output file by prefixing an the
ffmpeg option acodec with ‘output.’.
1. Add acodec to options of the output file
2. Pass options to conversion
www.prodigyview.com
7. Compression Audio Files
For the remainder of this tutorial, we are going to be compressing
audio files by changing the bit rate. There are various qualities when
converting's files.
1. CD Audio: The highest quality of audio.
2. 320kbs: A very high quality of audio, barely distinguishable from
the cd quality.
3. 256kbs: A still very high quality of audio, hard to distinguish from
the cd quality.
4. 192kbs: Slight differences from the original cd audio.
5. 160kbs: More notable difference in the quality and depth of the
sound.
6. 112kbs:Sound in the stage of very noticeably, quality is no where
near as sharp.
7. 96kbs: Poor quality of sound, considered radio quality.
8. Compression Example 1
For a simple compression of sound we, are are going to
start by changing the bit rate to 160kbs. The ffmpeg
option used is –ab.
1. Set the audio bit rate to 160kbs
2. Pass options to conversion
www.prodigyview.com
9. Compression Example 2
For the next example, we no longer want the full song and
want a lesser quality. We can delay the start location with
–ss option.
1. Set the audio bit rate to 128kbs 2. Set the time to start converting
3. Pass options to conversion
www.prodigyview.com
10. Compression Example 3
For our last examples, we are going to add the ffmpeg
option –t, that will set a limit on how much is converted.
1. Set the audio bit rate to 96kbs 2. Set the time to start converting
3. Set the amount of time to convert for
11. API Reference
For a better understanding of the audio
manipulation, check out the api at the two links below.
PVAudio
FFMPEG API
More Tutorials
For more tutorials, please visit:
http://www.prodigyview.com/tutorials
www.prodigyview.com