Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Audio files to .flac format using php code

Tags:

php

flac

I have audio files on my server and wanted to convert them into flac format in order to convert them into text. Please let me know how can we achieve that..

like image 356
PrashJ Avatar asked Jun 13 '26 06:06

PrashJ


2 Answers

You can use FFmpeg: https://ffmpeg.org/

ffmpeg -i input.mp3 output.flac

There is a php wrapper for the ffmpeg binary on github. https://github.com/PHP-FFMpeg/PHP-FFMpeg

like image 58
Michael Avatar answered Jun 16 '26 01:06

Michael


In case you can't install ffmpeg you might want to try this free API:

<?php
$url = 'http://server.com/sound.mp3';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/sound_convert.php?url=' . $url . '&format=flac'));

if (@$data->success !== 1)
{
    die('Failed');
}
$flac = file_get_contents($data->file);
file_put_contents('sound.flac', $flac);
like image 33
Jack Avatar answered Jun 16 '26 03:06

Jack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!