Streaming music with gnump3p and Linux - mp3, ogg, movies | How toFollow @ggarron
If you have a big collection of music, you can’t have in all your computers, so you’d better have it only in one of them and share it with the others.
There are a lot of ways to do that, you can use Samba, NFS, or other means to share you drive with others, and thus your music collection, but a better way IMHO, is to share it using a streaming server.
According to Wikipedia:
Streaming media is multimedia that is constantly received by and presented to an end-user while being delivered by a streaming provider. The name refers to the delivery method of the medium rather than to the medium itself. The distinction is usually applied to media that are distributed over telecommunications networks, as most other delivery systems are either inherently streaming (e.g., radio, television) or inherently non-streaming (e.g., books, video cassettes, audio CDs). The verb ‘to stream’ is also derived from this term, meaning to deliver media in this manner. Internet television is a commonly streamed medium.
Live streaming, more specifically, means taking the media and broadcasting it live over the Internet. The process involves a camera for the media, an encoder to digitize the content, a media publisher where the streams are made available to potential end-users and a content delivery network to distribute and deliver the content. The media can then be viewed by end-users live.
In our case, this basically means, that the files does not need to be downloaded in order to play them, and they will flow over the network connection from the server to the computer with the mp3 player software. This “flow” will occur while the music is playing on the other side of the server.
The software we will use to stream the music is gnump3d
From its homepage
GNUMP3d is a streaming server for MP3s, OGG vorbis files, movies and other media formats.
And they also assure the server is highly secure, with these three aspects in mind:
- Nobody should be able to browse your filesystem, except that specific part which you make your server root
- Nobody should be able to crash the server, so that you can’t use it. (A denial of service attack).
- Nobody should be able to trick the server into running code of their choosing
This being said, let’s go directly to the installation and configuration of
Streaming music with gnump3d
pacman -Sy gnump3d
Install if from slackbuilds
I’ve not tested in other distributions but chances are that your package tool, can install if for you, if not you can download the last version from here, and install it like its homepage recommends.
GNUMP3d has only one requirement - a working Perl installation with the fork() function implemented.
In practice this means some for of Unix system, or a Microsoft Windows system with a very recent version of ActiveState’s Perl port.
GNUMP3d installation should require no more than the following:-
This will install the software in /usr/bin, with the configuration files in /etc/gnump3d/
The configuration is
/etc/gnump3d/gnump3d.conf and it is the only file you need to edit, the simpliest one could be:
port = 80 #Default: port = 8888 root = /home/user/mp3collection #Defaul: root = /home/mp3 # logfile = /var/log/gnump3d/access.log # log_format = $connected_address - $user [$date] "GET $REQUEST" $HTTP_CODE $SERVED_SIZE "-" "$USER_AGENT" # errorlog = /var/log/gnump3d/error.log # user = nobody # allowed_clients = 10.1.1.0/24 # Default: allowed_clients = all # always_stream = 1 # advanced_playlists = 1 # theme = Tabular ## theme_directory = /usr/share/gnump3d/ ## # directory_format =
## new_format = New ## new_days = 7 # #Default: file_format = $DIR_NAME $NEW $SONG_COUNT $DIR_COUNT [$RECURSE] # #As I do not want to offer the option do download the song, but only to hear it, I modify the above line, and take the Download link out. I understand that this is not really secure, but for the standard user it will work. # file_format = $SONG_FORMAT [Info] [Download] # song_format = $TRACK - $ARTIST - $ALBUM - $SONGNAME [ $GENRE - $LENGTH / $SIZE ] $NEW # Default to sorting by the track number, due to popular. sort_order = $TRACK # plugin_directory = /usr/lib/perl5/5.10.1/gnump3d/plugins # mime_file = /etc/gnump3d/mime.types # file_types = /etc/gnump3d/file.types # now_playing_path = /var/cache/gnump3d/serving # tag_cache = /var/cache/gnump3d/song.tags # shoutcast_streaming = 1 # use_client_host = 1 ## # End of gnump3d.conf #### $SONG_FORMAT [Info]
Few more tweaks
If you want to tweak it a little bit more, you can implement the downsampling, this is useful if you plan to stream over the internet, because if have your music from iTunes like me, you have notices that the files are really big at 256 Kbps, and that may not work very well over the Internet, but it is great for the Local Network.
First install a software capable to down sample the files, such as
pacman -Sy lame
apt-get install lame
Note: You need multimedia repository, enabled in you
Use slackbuilds once again, here is the link
OK, now that
lame is installed, you need to enable the feature in the server.
downsample_enabled = 1
Add that line to the
Then, add these lines, to decide which clients will have its songs downsampled
downsample_clients = ALL no_downsample_clients = 10.1.1.0/24
That will downsample for all expect the local network users.
You can also downsample to all users
downsample_clients = ALL no_downsample_clients = NONE
Finally, add these other lines to define the lever of downsampling
downsample_high_mp3 = /usr/bin/lame --mp3input -b 56 $FILENAME - downsample_medium_mp3 = /usr/bin/lame --mp3input -b 32 $FILENAME - downsample_low_mp3 = /usr/bin/lame --mp3input -b 16 $FILENAME -
And the default quality:
default_quality = medium
When the clients access the server using their browser, they will be able to select the quality in the preferences tab, that will apply to that specific user.