Share Your Music Collection With gnump3d
So, you have a large collection of mp3 or ogg files and you want to share it with your buddy in your working place? Or perhaps you want to share it with your neighbour? Whoever you want to share your collection with is not the matter that we want to discuss here. If you are a Windows user you might often share your files, perhaps including your music files via SMB protocol, just as simple as right click, properties, sharing, checking several boxes and it’s ready to be shared. It might be different if you are UNIX or perhaps simply Linux guys, you might share your collection via NFS. You might think that it will be great running an FTP or HTTP server to share it, but remember that the users still have to download it to their own computers before they can listen. So, here’s gnump3d to help you share your collection. Gnump3d is a streaming server. Although the name is using mp3, it can serve ogg, too, so don’t worry that you have convert all your mp3s to oggs because gnump3d can serve it, too.
Getting The Program
You can get the latest version of gnump3d from the GNUmp3d donwload page.
InstallationBefore you install it, extract the tarball first:
You will get a directory named gnump3d-2.9.8. Change to that directory:
# tar –xzvf gnump3d-2.9.8.tar.gz
# cd gnump3d-2.9.8
And now is the installation time. You might think that the gnump3d installation is difficult, but actually not, it’s so simple, you just need to type:
# make install
Just that? Yeah. It’s so simple, isn’t it? In the next part we will configure it first before running the server.
Before running the server we will configure it first. The configuration file is in /etc/gnump3d/gnump3d.conf. There are just two things that you have to edit to make the server just running, they are:
- Port, used to decide on what port the server will be listening. The default value is 8888, you might want to change it.
- root, used to tell gnump3d where the files that you want to share are located.
Now it’s time to run gnump3d. Just type:
# gnump3d &
The & makes the process running in the background. If you want gnump3d to run automatically everytime the computer boots just add the same command above in /etc/rc.local.
Gnump3d will index your collection first before it starts to run.
If you want to know the statistics of how large your collection is, you can use gnump3d-index with the –stats argument.
# gnump3d-index --stats
Here’s the output on my machine:
Total number of songs: 7246
Total size of archive: 26.2Gb (28194094349 bytes)
Total playlength : 24 days, 15 hours, 3 mins 3 seconds
This service will mostly run on a LAN, but what if you want to serve internet users, or just simply want to make the bandwidth usage more efficient. What you need is downsampling, and it happens on the fly.
To enable downsampling you need to uncomment this line:
# downsample_enabled = 1
If it is commented another setting related to downsampling will be ignored by gnump3d.
Gnump3d uses suffix to control downsampling, so you need a different downsampling program for mp3 and ogg. The default pattern for downsample is:
downsample_high_mp3 = /usr/bin/lame --mp3input -b 128 $FILENAME - downsample_medium_mp3 = /usr/bin/lame --mp3input -b 64 $FILENAME - downsample_low_mp3 = /usr/bin/lame --mp3input -b 32 $FILENAME -
After setting how to downsample, you have to set up the controller, there are two options and you have to set both of them. They are:
downsample_clients = XXX no_downsample_clients = YYY
For example, you want to downsample all clients except from the local network. The setting will look like this:
downsample_clients = all no_downsample_clients = 192.168.0.0/255.255.255.0
Protecting Your Collection
You might want to protect your collection against unauthorized users. You can do this by using the allowed_clients and denied_clients settings or by protecting it with password. When using the allowed_clients setting you just need to supply the IP address or network address with its subnet. The same applies to the denied_clients setting.
If you want to use passwords, you need to uncomment the line (still in /etc/gnump3d/gnump3d.conf) # enable_password_protection = 0 and change it to enable_password_protection = 1. After that make a file in your collection's root (mine is /home/mp3) named .password (be careful, don't forget to include the dots so that the file will be hidden). The file contains a username-password pair like this:
Don’t forget that the .password file must be readable by the user who runs gnump3d. That’s all for this time, have a nice time sharing and streaming your collection.