Reputation: 2239
I would like know if it is possible to create embedding of audio message to audio files?
For example, on playing every 10 sec of an audio, it would be interrupted with an audio message "You are currently listening to an audio by XYZ band" and then the audio continues. And even if someone were to download the mp3 file, the audio message is still embedded with that downloaded file?
May I know if there are any libraries or classes that can work with php to achieve the above result? And what would be the workflow?
Thank you very much.
Upvotes: 1
Views: 891
Reputation: 6776
I would use sox for everything. It can decode and chop up the audio into segments, into which you can interject your message, and then render the sequence into a new mp3 file. It should also be able to overlay the messages onto the audio, so you don't break up the music, which might sound more pleasant.
Of course, this means using PHP just for management. The signal processing would be done by sox. If you really want to do as much as possible in PHP, use an external tool to decode the mp3 into a wave file, load the PCM into an integer array in PHP, and manipulate it there. PHP is probably not very fast when it comes to number crunching like this, but it should be possible. Save the PCM to disk for final encoding.
Upvotes: 0
Reputation: 449613
You definitely can't do that in pure PHP - in theory you could write a MP3 decoding and encoding engine for PHP but it's an insane idea - and you will need some server side help for the task.
ffmpeg should enable you to mix multiple MP3s together to one file, provided your host supports it.
Upvotes: 1