Apache::MP3::Resample can downsample MP3/FLAC/Shorten files during streaming.
# httpd.conf or access.conf
AddType audio/shorten .shn .SHN
AddType audio/flac .flac
Alias /apache_mp3 /usr/share/libapache-mp3-perl
< Location /songs >
PerlSetVar CacheDir /var/cache/Apache::MP3
PerlSetVar AllowDownload no
PerlSetVar SortFields Album,Track,Title,-Duration
PerlSetVar Fields Track,Title,Artist,Album,Duration,Bitrate
< /Location >
Apache::MP3::Resample subclasses Apache::MP3::Playlist to allow the user to downsample audio files before streaming them. This allows users on slower connections to stream songs. When this module is installed, a menu of bitrates is presented in the upper right-hand corner of the screen. The user can choose from one of the bitrates, or select a mode that performs no resampling. The selected bitrate is maintained in a persistent cookie so that resampling is performed whenever the user returns to the site.
This module requires a command-line MP3 encoder to resample and reencode the audio data. If not otherwise specified, Apache::MP3::Resample will try to use the Open Source Lame MP3 encoder. This utility is available at http://www.sulaco.org/mp3. Version 3.90 was used during the development of this module. Your results with other versions may vary.
When you install Lame (or the encoder of your choice), be sure to place it in a directory located in Apache's PATH so that the module can find them at run time. You may need to set the PATH environment variable during Apache's launch, or by explicitly adding a SetEnv directive to the Apache configuration file.
You should be aware that the decoding/reencoding process is CPU-intensive, and server performance may degrade as the number of simultaneous users increases.