Convert Audio Files to M4A Format in PHP
Wide compatibility and Advanced Audio Coding (AAC) compression are just a few of the benefits of converting audio to M4A format. Using our free “Convert Audio to M4A” API, you can easily implement an M4A conversion service into your web apps and standardize future audio uploads.
To help you take advantage of this API, we’ve provided ready-to-run PHP code examples below which you can use to structure your API calls.
First, run the following command to install the client SDK:
composer require cloudmersive/cloudmersive_video_api_client
Next, use the following examples to structure your API call. To authenticate your requests for free, register a free account on our website (this provides a free-tier API key with a limit of 800 API calls per month):
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');
$apiInstance = new Swagger\Client\Api\AudioApi(
new GuzzleHttp\Client(),
$config
);
$input_file = "/path/to/inputfile"; // \SplFileObject | Input file to perform the operation on.
$file_url = "file_url_example"; // string | Optional; URL of an audio file being used for conversion. Use this option for files larger than 2GB.
$bit_rate = 56; // int | Optional; Specify the desired bitrate of the converted audio file in kilobytes per second (kB/s). Value may be between 48 and 1,411. By default, the optimal bitrate will be chosen automatically.
try {
$result = $apiInstance->audioConvertToM4a($input_file, $file_url, $bit_rate);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AudioApi->audioConvertToM4a: ', $e->getMessage(), PHP_EOL;
}
?>
That’s all there is to it — no more code required!