The merger of two mp3 players

Do you know a class to merge two MP3 files using PHP?

I did not find anything on Google.

+3
source share
5 answers

If by merging you mean placing one sound over another, then please do not pay any answer to it.

If you do not want to transcode MP3s, you can simply add them. I know this worked for MPEG movies, so I think it can work for MP3s too. Another option is to add audio files to the Zip archive without compression, and then rename the extension to .mp3.

I did a quick test and this

file_put_contents('combined.mp3',
    file_get_contents('file1.mp3') .
    file_get_contents('file2.mp3'));

. ID3 , . . .

, googling

+8

. PHP MP3. . (, , PHP, @ceejayoz.)

. :

+2

.mp3 MPEG-1 MPEG-2 Layer III, . . , , , . , .. , . , , .

ID3- ( ) .

MPEG-1 MPEG-2 . , . , , .

ID3 , , , , , .

getID3() (http://getid3.sourceforge.net/) . , , MP3 ID3 ​​.

+2

:

  • . () / ( Audacity).
  • Content-length - .

"-". 1- MP3-, :

$output_audio = textToMP3("Hello World");               // Original audio
$silent_audio = file_get_contents("silence.mp3");       // 1 second silence
$content_length = strlen($output_audio) + strlen($silent_audio);

// Output the audio stream
header('Content-type: audio/mpeg');
header('Content-length: ' . $content_length);
header('Cache-Control: no-cache');
header("Pragma: no-cache");
header("Expires: 0");
echo $audio . $silent_audio;
0

, , , : https://github.com/falahati/PHP-MP3

composer require falahati/php-mp3

MP3:

$audio1 = \falahati\PHPMP3\MpegAudio::fromFile("1.mp3");
$audio2 = \falahati\PHPMP3\MpegAudio::fromFile("2.mp3");
$audio1->append($audio2)->saveFile("3.mp3");
0

Source: https://habr.com/ru/post/1770825/


All Articles