Help, how to make using JS and PHP to change the audio bitrate? So that when you upload an audio file to the server, the bitrate is automatically changed to the desired one.

    1 answer 1

    There is such a utility / program / set of ffmpeg that allows you to work with audio and video formats. Here its PHP support is PHP

     <?php require 'vendor/autoload.php'; // Добавление $ffmpeg = FFMpegFFMpeg::create(array( 'ffmpeg.binaries' => '/usr/bin/ffmpeg', // path to file ffmpeg 'ffprobe.binaries' => '/usr/bin/ffprobe', 'timeout' => 3600, // The timeout for the underlying process 'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use ) , $logger); //---------------------------------------------------------------- // $audio = $ffmpeg->open('uploaded-file-path.mp3'); $format = new FFMpegFormatAudioFlac(); // Есть еще варианты mp3, aac, wav... $format->on('progress', function ($audio, $format, $percentage) { echo "$percentage % transcoded"; }); $format->setAudioChannels(2) ->setAudioKiloBitrate(96); // Изменяйте на нужный $audio->save($format, 'output-file-path.flac'); 

    Off site ffmpeg

    Install ffmpeg

    PHP-FFMpeg