This tutorial explains how to use PHP together with FFmpeg to convert AMR audio files into MP3 format. With just a few steps, you can easily achieve audio format conversion — ideal for projects involving voice processing or audio uploads.
Before writing the PHP code, make sure FFmpeg is installed on your server or local environment. You can check this by running the following command:
ffmpeg -version
If the command is not recognized, FFmpeg is not installed. Visit the official FFmpeg website to download and install it according to your operating system.
Next, let’s write the PHP code that uses the exec() function to call FFmpeg and perform the conversion. Here’s a complete example:
<?php
$amrFile = "input.amr";
$mp3File = "output.mp3";
$cmd = "ffmpeg -i $amrFile -acodec libmp3lame $mp3File";
exec($cmd);
?>
Explanation of the code:
Make sure your PHP environment has permission to run system commands, otherwise the conversion may fail.
Save the above code as convert.php and place it on your server. Modify the $amrFile and $mp3File variables to match your actual file paths, then run the following command in your terminal:
php convert.php
Once executed successfully, you should find the converted MP3 file in the specified directory.
In this tutorial, you learned how to convert AMR files to MP3 format using PHP and FFmpeg. This approach is efficient and easy to integrate into audio upload systems, voice recognition platforms, or file management tools. FFmpeg is a powerful multimedia framework that supports numerous audio and video formats — you can explore further based on your project needs.
We hope this guide helps you successfully perform your conversions. Good luck!