Your SlideShare is downloading. ×
FFMPEG PHP Audio Conversion Basics
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

FFMPEG PHP Audio Conversion Basics


Published on

Learn how to convert audio files using FFMPEG and PHP exec function. Will also how how to record audio from a mic and turn documents into audio files.

Learn how to convert audio files using FFMPEG and PHP exec function. Will also how how to record audio from a mic and turn documents into audio files.

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. FFMPEG Audio Tutorial
  • 2. OverviewObjectiveLearn how to convert audio files using ffmpeg and the phpfunction exec.Requirements Installed version of ffmpeg Understanding of the DEFINESEstimated Time10 minutes
  • 3. Follow Along With A Code Example1. Download a copy of the example code at Install the system in an environment you feel comfortable testing in.3. Proceed to examples/avi/FFMPEG_Audio.php
  • 4. execIn this tutorial we are going to be using the function exec.In PHP this function will allow you to execute programsdirectly on the command line.For more information, read the PHP doc.
  • 5. Location of FFMPEGThe first thing we need to is access ffmpeg on yourserver. The program ffmpeg must be installed on yourserver environment.On my server ffmpeg is accessible from anywhere. But if yourffmpeg is only accessible from /usr/share/ffmpeg, then changeyour value to that or where ever ffmpeg is accessible from. Ifyou are unsure, ask your hosting provider.
  • 6. Input FileFor this example to work, we at least need a video thatalready exist. ProdigyView Example code comes with aaudio in mp3 format. PV_ROOT is one of DEFINES inProdigyView.1. PV_ROOT define for the top level directory of your application 2. Location of video file relative to the top level directory
  • 7. FFMPEG SyntaxThe syntax for converting a file is relatively easy. You need theaudio file to be converted and the location to save the output.Notice in the code at the bottom, we are using PV_VIDEO DEFINEas the location to save the file. Example Syntax: ffmpeg –i input_file.ext output_file.ext 1. Location of FFMPEG program 2. Location of file to convert 3. Output location and name of converted file
  • 8. Format ConversionOne of the great things about FFMPEG is the conversionof formats merely by changing the extension. Rememberthat our input file was a .mp3, lets change it to a .wav1. Location of FFMPEG program 2. Location of file to convert 3. New file extension
  • 9. Add OptionsFFMPEG also has the ability to change the characteristicsof an audio file. Below we are going to change the bitrateto 128k. Remember that options passed always apply tothe next file. This means the-i applies to the input file andthe –b is applied to the output file.Apply option to input file Apply option to the output file
  • 10. Recoding From MicAwesome features of ffmpeg is to directly record audioinput from an outside source such as your mic. This willdiffer among your server environments but that basicswork like below.1. Open Sound System(OSS)specifies the sound input device 2. Output sound to file
  • 11. Hearing FilesOur last demonstration in this tutorial will converting andhearing sounds of files. With FFMPEG we are going toconvert the README.txt file the came with ProdigyView. Output file into dsp and convert link
  • 12. FFMPEG DocumentsThe arguments used here is only an example of the ffmpegarguments available. For more information on ffmpeg, visit: Review 1. FFMPEG must be installed to be used. 2. exec function can be used to access ffmpeg. 3. Ffmpeg follows the format of “ffmpeg –i input_file.ext output_file.ext” 4. Arguments must be added before the file that they are going to affect. 5. Change the file format by changing the extension of the output file
  • 13. More TutorialsFor more tutorials, please visit: