tags:

views:

227

answers:

1

Does anybody know a purely PHP based way to alter the frequency of an MP3 file?

I am on shared hosting with this, so installing ffmpeg or something similar is out of the question.

If this requires actually altering the audio data, then I guess it is not possible nor feasible to do with PHP, but I was thinking maybe this is just a header setting. I don't know.

Background:

A client's website is utilizing a Flash based MP3 player to play some audio. The client is producing the audio herself.

The trouble is that the tools that she is producing it with, and is familiar with, automatically produces MP3 files with a frequency of 48000hz, while some versions of Flash have trouble playing anything with a frequency differing from 44100khz. (See my related question here).

I would like to avoid adding yet another program to the already complex audio production process, and solve this on the web server end if possible.

+2  A: 

I was thinking maybe this is just a header setting.

No. That is, you can probably change it in the header, if you don't mind your MP3s being played too slow or too fast with a shifted pitch.

If you want it to sound the same, you will need to re-encode. Decoding to WAV (or raw samples), resampling, then re-encoding is a possibility, and probably your only one.

Maybe the way MP3 works allows for a shortcut (like JPEG allowing for lossless rotation), but I am unaware of any such methods.

Thomas
ALl right, I thought that was the case. Thanks. Re-encoding is definitely not an option in PHP, even if somebody has been crazy enough to implement it :) I will leave the question open for some time in case somebody comes up with something I can't think of, and will otherwise accept this answer.
Pekka