About the mp3 Combination Program

Asked 2 months ago, Updated 2 months ago, 7 views

Nice to meet you
I would like to combine multiple mp3s in php into one file and play it.

<php
$mp1 = '../mp3/1.mp3';
$mp2 = '../mp3/2.mp3';
$mp9 = '../mp3/9.mp3';

$cmd = "cat$mp1$mp2>";
shell_exec($cmd,$mp9,$rtn);
?>

<audiosrc="<?phpecho$mp9;?>"autoplay="true">

Then only 9.mp3 will be heard, and the connection will not work.

Is the 1.cat connection wrong?
2. Where is the combined mp3 stored?Root, under mp3 folder?
3. Can this combined mp3 file be saved as data?

Thank you for your cooperation.

php mp3

2022-09-30 13:45

1 Answers

    Due to the
  • mp3 specification, there is software that can play mp3 files created by combining cat.However, there are two disadvantages: "Re-encoding will not be done" and "Tag information such as song title will become inconsistent," so if you want to combine properly, you should use another software for mp3 combination.
    • More specifically, mp3 has a file format of File Header for Tags--Audio Data--File Footer for Tags, and music data is in the format of Frame Header--Audio Byte String.Therefore, simply cat the byte column simply puts the tag in the order of the frames, and if you try to force it into an mp3 file, you can read it.However, the tag information that has been shredded is usually lost.
      • Conversely, if the original files are not tagged, cat can join successfully.
    • The following Q&A is helpful for software that can accurately combine mp3.
  • The shell_exec() function receives only one argument.The current source code has three, so something is wrong.exec()Is it the function ?
  • If you executed the command
  • cat../mp3/1.mp3../mp3/2.mp3>../mp3/9.mp3, the merge results are stored in the file ../mp3/9.mp3.
  • In the first place, passing the variable directly to the shell command can be a security hazard.The source code in the question text has a fixed filename, but if this can change dynamically (especially if any input string can be substituted), you should be careful about how to implement it.
  • More specifically, mp3 has a file format of File Header for Tags--Audio Data--File Footer for Tags, and music data is in the format of Frame Header--Audio Byte String.Therefore, simply cat the byte column simply puts the tag in the order of the frames, and if you try to force it into an mp3 file, you can read it.However, the tag information that has been shredded is usually lost.
    • Conversely, if the original files are not tagged, cat can join successfully.
  • The following Q&A is helpful for software that can accurately combine mp3.
  • Conversely, if the original files are not tagged, cat can join successfully.


2022-09-30 13:45

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.