Fade in/out audio?

Is there a way to make a fade in and fade out to a mp3 file that a user is uploading to my server?
I’m making a page where the user can upload their sound file and then I want my page to make a 30 sec sample of that sound.

Any ideas?

My first impulse is to say ffmpeg it.

PHP itself cant do this; javascript might, but that would involve the browser redownloading the entire audio file to do a 30 second sweep; probably not what you want.

And what is ffmpeg doing? Is that something I can use on my server and do with an uploaded file while the user is still logged in? Or what?
But uploading the complete file is no problem, since I want a full length audio track is also supposed to be uploaded. The 30 sec sample is just a teaser.

ffmpeg is a command-line program that processes and manipulates audio and video.

A quick search pulls up various threads on how to write a command to fade in and out, but there’s some debate on if this actually affects audio volume or not.