Community Tutorial 01

From Osgrid Wiki
Jump to: navigation, search

This tutorial will help you setup your own local Shoutcast / Icecast server, and stream media to it from a Mediaplayer, like Winamp, VirtualDJ or SAM. Once done, you can set your own streams, and play your favorite tunes in the metaverse / Become a DJ !.

Warning : Mind that running a stream, especially if you have commercial intentions, run ads, or permanently embed it somewhere, can require you to have a permit to do so. This is dependent on your country / state / nations laws and rules. This is something you need to figure out by yourself, we waive any responsibility for your actions by following the information in this tutorial. We're not lawyers nor experts. You are subject to your local laws, we write all this with information gathered from public sources on the internet. Behave mature and make sure that you’re allowed to do what you do, before you do, and do not infringe on other people's rights.

Goals of this class :
*-  Understanding terminology
*-  Calculate Bitrates & users
*-  Setting up and configuring Shoutcast Server
*-  Configuring your mediaplayer to stream to shoutcast
*-  Troubleshooting your stream

Terminology

  • Shoutcast / Icecast Server: A server that can provide audiosteams to multiple users on the internet simultaneously.
  • Stream: Data streaming, commonly seen in the forms of audio and video streaming, is when a multimedia file can be played back without being completely downloaded first.
  • Bitrate, as the name implies, describes the rate at which bits are transferred from one location to another. In other words, it measures how much data is transmitted in a given amount of time. Bitrate can also describe the quality of an audio or video file. For example, an MP3audio file that is compressed at 192 Kbps will have a greater dynamic range and may sound slightly more clear than the same audio file compressed at 128 Kbps.
  • Internet Radio : ALl sorts of permanent audiostreams you can listen to on the internet, there are hundreds of thousands of them.
  • Webpage: When you install and run a shoutcast server, it fires up a web interface in port 8000. There you can manage users, check who’s listening, and see song history. Also is handy to test if stream is up. If the page is not there, or sais server is down, you have not properly switched it on yet in VDJ or winamp.
  • Relay : Relays act as clients to a server, but are able to rebroadcast the music. Meaning you can put 1 stream on multiple servers, and / or share the load.
  • DST plugin : A plugin for winamp that adds an encoder, that can encode / convert the audio output of your winamp into a stream of bits with a pre-determined sampling rate, that you can send to a streaming server.
  • Delay: The time between you and your listener. A song gets buffered for approximately 10 seconds before it starts streaming. Generally your delay between what you send and what the other person receives varies between 14-18 seconds.
  • DNAS : Shoutcast is referred to as a DNAS. It stands for Distributed Network Audio Server.
  • Audio streaming programs / mediaplayers : The programs used to stream the music from. Mind these are generally NOT the server. Some do have built in streaming facilities, like SAM, VDJ and serrato. Others require a plugin, like winamp or windows mediaplayer.
  • Built-in streaming : A mediaplayer that can serve streams without external streaming server, see examples above.
  • Encoders and DLL’s : The encoder is the program that makes a bitsteam out of the output of your mediaplayer. It uses a custom DLL ( Dynamic Link Library) to be able to do so. This library enables your program to “talk” to the encoder.
  • Cuts / chops : If you have a poor or overloaded connection, the audio stream will suffer cutouts. This is either packet loss, connection loss, or buffering of the incoming stream. Result s the same at the user end. Silence. Mind that browsers can “hijack” audio from the average viewer !
  • Buffer : A stream of audio is not constant, due to internet. So it buffers the connection for a bit before it starts. That and the connection / data retransmission causes the 10-18 second delay between you and your listener.
  • Format (AAC for windows media+plugin /winamp) or MP3, Flac it are all file formats, with a certain compression, or lossless format.
  • Playlist files : Most webpages do not serve direct links to online radiostations. Instead they offer playlist files, which effectively allows the stream to open in a mediaplayer. These are typically pls, m3u, asx, qtl, ram, or other extensions. You can open these type of files with notepad++ instead of your mediaplayer, and see where they route to. Typically you find an IP and a port in there. If you copy that address into your land media tab, audio URL, it will play the station. If you put the URL with the pls or other extension, nothing will happen, as the viewer will not find a stream.
  • Sampling Rate : In signal processing, sampling is the reduction of a continuous signal to a discrete signal. A common example is the conversion of a sound wave (a continuous signal) to a sequence of samples (a discrete-timed signal).

Things to consider:

Unless you own a Mac, do NOT install "Apple Music". Just before we start. Because, reasons. And yes, might have been a bug, but still. Let's start off by stating our goal is not to serve 1000's of users ! We hold small confined "party's" for some friends, to which we stream music as if they were in our living room with us, from our personal music library's. If you want anything more, you need a hosted stream. Period. Here's why : Our streams have a bitrate. An amount of bits sent off in a stream to the client. The more bits we send, the more data, thus the higher quality is our music, is the public idea. That is a partially misplaced idea. The quality of the audio is dependent on the quality of the audio you send out. If you use loss-less uncompressed music (Like FLAC) , you get high quality audio. If you use 128 Kb MP3, which is nothing more than a compression format, you send out compressed music. It has little use to give that a mega lot of bandwidth, as the input will not improve. MP3 is a storage format, its compressed with a certain bitrate. It won’t be uncompressed ( the data that was removed in the compression process is deleted, its just no longer there), so you will never get the 'original quality' back. The quality is thus dependable on the input bitrate of the compressed music, and not so much the bitrate of the stream, Make sense ? It works more or less the same as with resolutions in pictures. If you save a PNG, and covert it into a Jpeg (compress), you chop out data. You can send a Jpeg over the web quicker than a PNG as its smaller. But you can't make a PNG of the same quality the original was, from the Jpg. Same with converting MP3's. This massively reduces the size of the file, which is great for storing and uploading and/or streaming it, but it also affects the "quality" of a song, as it's "ranges" are cut due to the compression.

That's why any professional DJ nor artist will tolerate bitrates of below 320KB/s at the least, some might use 192, but 128 or lower is sort of Blasphemy to them. Most run a minimum of 320Kb/ps, and some even prefer the real loss less format of 11.4 They claim this is required to fully make use of the sampling rates within the complete audible spectrum of the music they own. It's not based on "superiority feelings" though, there is a theory behind this. The range of human hearing is approximately 20 to 20,000 Hz. There’s something called the Nyquist theorem that states that to properly reproduce sound, the sampling rate of a digital recording should be twice the highest frequency contained within that sound. Since the upper range of human hearing is 20,000 Hz, you'd need a sampling rate of at least twice that amount. This is why for instance an audio CD’s sampling rate is 44.1kHz. Now this here is all theoretical. To the best of my knowledge most adults can't hear anything above 16.000 Khz anymore, and their disco-ears MP3 Phone using kids... well. Some can, but not the majority, promise. You can have the same pointless long discussion on the above, as on what is the best viewer, or nicest operating system. Enjoy that after class, and don't ask me plz. As a user and "Hobby DJ", just use what you have, it is generally sufficient. If you want to go pro, there is simply more to learn and consider.

For now mind that below bitrates of 96KB you can more noticeably hear, if your source files are of poor quality. If you have good headphones or decent speakers, you can hear this more clearly. But like stated, if you’re not some audiofreak, you’re unlikely to notice the difference a lot anyways, so don’t worry about this too much. I would like to advise and mind it is very worth “normalizing” your music if you DJ. ( there are programs that can automatically do that ). They adjust volume & peek in and output levels to acceptable and similar level on all tunes. It prevents one song from being real loud / distorted and the next real “soft”.

Bits Bytes and Users.

Each User stream you server uses 128 KB/s RAM & Bandwidth. (or, the amount of bitrate you set per user in the Audioprogram/mediaplayer. The server just sends what it receives). Now how many Mbit upload and GB RAM you had again ? Mind there is a often a discrepancy between what you think you have, and you actually have. My ISP tells me I have a 150/15 M/bit connection. Which i do, when i measure. It's nice and fast. Now i don't care about download for running a server, i need the upload speed to determine how many KB/s i can serve to how many users. How do i know. I have Files in KiloBytes, networkspeed in Kilobits, Download and upload speeds in M/bit... I'm confused.

Measure of file size: KB
File size i.e. how big the file or how much space a file occupies on your hard disk, is measured in terms of KiloBytes (KB upper case “K” and upper case “B”). In    computing terms the upper case “K” stands for 1024 bits. 1024 is computed from 2`10. (2 power 10). 2 denotes the number of characters in the binary system which are used to store data on your harddrive (ones and zeroes / power on and power off. It's in a nutshell how your computer calculates).
So. 8 bit's form 1 Byte.  Other abbreviations like mega, giga and terra also use 1024 as their base. 
1KB (KiloByte) = 1024 Bytes (approximately 1000 Bytes)
1MB (MegaByte) = 1024 KB (approximately 1000 KiloBytes or 1 million Bytes)
1GB (GigaByte) = 1024 MB (approximately 1000 MegaBytes or 1 billion Bytes)
1TB (TerraByte) = 1024 GB (approximately 1000 GigaBytes or 1 trillion Bytes)
Measure of data transfer speeds: kbps 
Data transfer speed over any networks (including the internet) is calculated in terms of bits per second: kilobits (kb small case “k” and small case “b”) per second. The higher the kbps i.e. more the bits transferred per second, more the speed, faster the network/connection. Here k stands for 1000.
1 kbps (kilo bits per second) = 1000 bits per second
1 Mbps (mega bits per second) = 1000 kilo bits per second.
1 Gbps (giga bits per second) = 1,000 mega bits per second.

Now to add to the confusion, (we can calculate as we know 8 bits go into 1 byte) ISP's use Mbit/ps, or kb/ps and shoutcast uses KB/ps, notice the capitol catch ? Bits, Bytes. 1 or 1000, makes kind of a difference. So we need to convert numbers if we want to calculate possible speeds.

Internet connectivity Upload Speed (approx)
256 kbps 31.3 KBps
384 kbps 46.9 KBps
512 kbps 62.5 KBps
512 kbps 93.8 KBps
1 mbps ~ 1000kbps 122.1 KBps

This table learns me that my 15 M/bit upstream is actually 1941.25 KB/s. People often get confused, because storage formats are in Bytes, and network speeds in Bits. Add conversion of Mbit & Bytes to the mix, and you get utter confusion.

Well, Since that still doesn’t tell you what you need, as you want to know what Maxusers and bitrate you can set, above might not be convenient enough. (Boring theory & math, nobody likes that). So here is another table, to make it more simple. Let’s say you have 1000KB/ps upload (which translates into 1 M/bit.) Take careful notice how many users this 1 Mbit can have at what bitrate. You can simply multiply, if you have more M/bit upload speed. Before you tell me some of these numbers seem slightly off, mind i didn't calculate this table, some shoutcast host did, it apparently includes overhead and is based on actual use statistics & experiences:

Listeners Bitrate
62 16 KBps
41 24 KBps
31 32 KBps
25 40 KBps
20 48 KBps
17 56 KBps
15 64 KBps
12 80 KBps
10 96 KBps
8 112 KBps
7 128 KBps
6 160 KBps
5 192 KBps
4 224 KBps
3 256 KBps
3 320 KBps
1 Higher

-* This table is based on 1Mb/s

normally I stream on 128 KB/s but I know that if I go above 96 Kbit, people in Oceania and “down under” start to get buffering or suffer cuts. Extremely likely due to latency on their end, but that does not make the problem less real. Since i have listeners from that region, i consider this, and lower my bitrate. I also know that streaming below 96 Kbit starts to have / can have a noticeable impact on sound quality, so people that still suffer cuts, should get a more decent connection. I can host around 150 users (1 mbit on 96 KB/s allows 10 users, times 15 is 150) on that 96KB/s bitrate. Now only 100 people fit in a sim, and i will tell you from experience that at least 15% of users never has audio on anyways. How many users did you expect at your metaverse event again ? It’s all just Math, and people claiming you need a supercomputer typically are the ones renting out streams. Do mind that you should not Max out your connection, or your RAM especially if you have other servers / programs running !!.

So if you have a low upload speed, you have no other options than to either send out low bitrates, or rent a stream. This way you connect to someone else's shoutcast server, and your listeners connect there, rather than to your machine. So instead of 100 listeners, your pc serves only 1. Also mind that hosted streams can have other benefits, and are a very affordable and feasible option for many people. Much more bandwidth (ISP’s in the world don’t hand out a lot of upload generally), way less impact on your end, and they generally they carry required licensing (ask proof for this if you need to pay anyways) for actually streaming in your country / region, should this be required. Again, to the best of my knowledge this is only required if you do “commercial” work, unless local laws say otherwise. For events in OSgrid, we have a licensed 1000 user Plaza server available on 128KB/ps.

Setting up your Router

Like Opensimulator, Shoutcast is a server. So clients want to connect to it. For this to work, you will need to have TCP and UDP ports 8000 and 8001 forwarded to the PC running shoutcast. ( If you run another service on port 8000, you need a different port for shoutcast, as you can only map a port once). If you get a message in shoutcast that it could not connect, this is always a result of incorrect routing or ports being blocked. (Or you have forgotten to set the stream to 'public' in your DSP plugin in Winamp). In either case, very little can fail, if you properly configure.

Shoutcast and it’s INI file.

Shoutcast works rather similar to any other server. It’s has a ini file that you need to configure to give it the parameters people can connect to. Very similar to what you are used already if you run an OSgrid server installation, but simpler. You can access the ini file through the GUI, or copy the one from the discussion page in the above menu, and save it as SC_SRV.ini in your shoutcast folder. Mind to change the passwords. You only use IP’s and ports in the ini file if you get failures, else leave them default.

Important : For this server to work, port 8000 and 8001 TCP and UDP need to be forwarded towards the shoutcast server IP in your router. Again, since it is a server, it is recommendable to set a static IP address for it. Mind also firewalls need to allow this traffic for it to work !  

Setting appropriate Ports, passwords and maxusers are mandatory, and all the rest of settings are explained in the file. Don’t touch what you don’t need, or of which you're not sure how to operate it, and guidance is found on shoutcast forums when/if you try more complex setups, like multi-stations. (they need own config files and ports/passwords set). If you have a shoutcast server, and give someone else the IP and password, they can use it to stream, through your server / URL. You can also connect to another shoutcast server, and relay its stream through yours, if this server is configured to allow this in it's ini file. If the server is started, you can send streams to it with your media player of choice. Configure the player's encoder with the IP and password of the server, (127.0.0.1 or localhost, if your on the same machine), set the desired bitrate and sampling rate, and you’re good to go. Do mind that in the shoutcast server ini as well as in the encoder, as stream must be set to public, for people to be able to connect to it. If things fail, this is the first thing to check after a restart of the server.

Mind that most audioprograms/media players will fail if the server is down when you send a stream to it, (really, captain obvious?) Yes, and they often keep failing if you start it, without restarting the media player. The session will not pick up. In other words, first boot the server, than boot the stream, else it fails. And trust me, it sux if you find out after 20 minutes your stream is either not switched to your url, or dead due to some connection error. Therefor check if your webinterface is up, and see if users are connected. http://youripaddress:8000 If it's there, and people say they hear nothing, whilst for everyone else it works fine, having them check their volume is typically a good fix. Another quirk, is that when you change bitrates, some clients ( browsers, viewers, media players), have a real hard time coping with the change, if you don’t restart them, even if you start / stop the stream (due to caching in the buffer, is my best guess) .

Streaming your Media to Shoutcast server:

Shoutcast is 'just a server'. It does not play audio nor can it maintain libraries other than configurations for multiple instances. You need to feed it with an input stream for it to be able to serve clients. There are various programs that have in built streaming facilities, like SAM broadcaster, Serrato, VirtualDJ, and more. Some others like windows media player, Itunes, or winamp use a plugin encoder to be able to convert their output to a valid input stream for Shoutcast. There are various encoders typically included with the program/plugins you stream with. They have their own DLL files to enable them to perform this task.

Setting up Winamp with the DSP Plugin :

Now configuring winamp with the Nullsoft DSP plugin (encoder) is widely described very thoroughly on the web, including configuration of the encoder. I’m not going to type that again, too much hassle, but we will quickly discuss it, and point out that you should not skip any steps, as it will fail : http://www.shouthost.com/how-to-setup-shoutcast-with-winamp

Setting up VirtualDJ

1. make sure shoutcast server is up and running. 
2. Halfway down your screen you see 4 buttons, the last one being "record" click it.
3. In the left pane, you see 4 buttons, click the one with "Broadcast"
4. Hit the config button in the resulting screen
5. Select mpeg shoutcast / icecast2 with the Lame encoder ( its in your \\VirtualDJ\Plugins\lame_enc.dll folder if not selected already ) 
6. Set bitrate. 128 is "normal" 
7. Under Server, select broadcast to a radio server
8. Fill in the Ip address or URL of your server. ( if shoutcast is running on your same pc, use 127.0.0.1, if that doesn't work, use your Local / LAN IP ) 
9. Fill in a name for your server (any name, this is not checked, it's just the way it will be "listed")
10. Fill in the password from your sc_serv.ini file. ( not the admin one, this is only for the webpage).
11. You can set any genre, i mainly use "various". Hit Ok once done. 
12. It is important you first start a song now, before you hit the broadcast button. ( Else you will just receive a server error, as there is no incoming audio). 
13. Drag a song on deck 1, and hit play. Go back to record, broadcast and hit start recording. VDJ will now connect to shoutcasts and send the stream. 
14. open http://127.0.0.1:8000 ( will in your public IP address preferably ) to see if all is up and running. 
15. put the url in audio url of media tab in about land, and you're live. 

Troubleshooting :

We know only 2 kinds of potential issues with Shoutcast :

Connection issues : Like stated earlier, if you have your port forwarding setup properly, and no conflicting ports or firewall in use, you should be good. If it doesn't seem to work, typically this is either routing failing (Double NAT ? hardware firewall in your router, port already in use ?), you having your stream not set to public, or misconfigured (wrong IP or password), or a firewall blocking you.

If the server seems up, but people have no or Bad audio :

The first thing you have them check is their volume. really. You'd be amazed how much people "hear nothing" because their sound is muted / volume is off. If they suffer cuts or buffering, make sure your line is not "loaded". Also make sure you have configured appropriate amount of users and bitrate for the bandwidth you have available, as per above instructions. Shut down any server / service on your machine that uses "upload". You want this available for your stream. If you have a connection with less than 0,5 M/bit upload, you can better consider a hosted server. Your line is unlikely to cope with decent enough connectivity to keep a stream alive. Very often your stream works fine, and 1 user starts reporting an issue. Typically that's "their issue" (Malware infested PC's don't tend to stream well, or their kid is just streaming netflix on the same line). Sometimes (can configure stuff on this in the ini) when a user logs in, he kicks out the oldest listener. This happens if there is a max set in your INI, or if the connected line cant handle more users. So if you see a round robin complaint, might want to restart the stream on a slightly lower bitrate.

DJ-ing in the metaverse. Will people like my music ?

Obviously there is a big social aspect on being a DJ. Unfortunately it is not something you can "learn". It's a bit the same as with lessons on how to operate a viewer. One can teach you how to build, but not "what" to build. Creativity is within a person, its more of a talent than a "educated" thing. DJ-ing is a bit more than playing the top 100 of all times every week. You listen to music a lot, and have to remember titles / artists and if music is slow, uptempo, depressing, cheerful, etc. Now despite having played MP3's for over 10 years, i do not consider myself 'worthy' of the title DJ very much. I Play MP3's and sometimes mix the ends of songs into each other, or press a button that plays a pre-recorded WAV file, or puts in a pre-set echo / reverb or flanger. That's nowhere near what an actual DJ / producer can do. (trust me, i know some. They create sounds, mix records, and actually make new things with what exists on the fly). And sure i learnt some things along the way, but i'm not some pro, not even an amateur at best really. Meaning you don't have to be either. To play an MP3, you need little to no skills. To be social, play music your general audience likes, create an atmosphere, well. You get more feeling for it over time. It grows on you, you don't learn it. Experiment with your crowd, enjoy what you do. Just mind it is impossible to be friends with everyone, and also impossible to satisfy everyone (constantly). Giving people the option to requests songs is a good way of interacting, but mind they can also request Gmoork. Up to you if you want to play such / it fits your 'set'. Also if you allow requests, be prepared to be more busy, and aware they can impact on your crowd.

The main goal i think, is that you should have fun. In what you do, and enjoy, even what you play for others. I tend to play music I like, but i do mind that there is a public at my events ranging age 20-75. Now you can imagine that the 23 year old doesn't care for Cosby or Sinatra all that much, but that the 75 year old doesn't handle boom-boom-boom Tiesto for more than 5 minutes in a row very well. Meaning it's extremely difficult to find a balance, and make everyone happy. (You cannot, but you can consider them both). My argument here is, know your public. It helps when you play peoples favorite tunes. They will like you for it. This music brings back a good feeling or memory. And each "time" has it's own memories. Mind that even if you don't like AC/DC, others might. And in the end, you DJ for a public, not for yourself. Just mind to keep having fun in what you do. If you do not enjoy, quit it, and do something else. As when the DJ doesn't have a good time, your party generally won't either.

Playlist or Dynamic

If you prepare and make a playlist, you can "theme" your party. All rock songs. Or Blues. Or Country. Or a mix of songs from a certain timezone, 70's, 80's 90's 10's. You will have the same issue as above, not everyone will like it. But you can announce upfront, and make a certain "atmosphere" with the music you play, possibly even theme your environment, and this can give really nice results. Mind that if you have a special cq out of the ordinary taste of music, to name some examples, Gothic Rock, Hardcore, punk, New age, or whatever you will need themed events. Such music is too"non mainstream" to be appreciated by most people, and thus not very suited for a varied public. Some "DJ's" throw all their 25.000 songs in a folder, throw it in winamp and hit play, or use VirtualDJ's auto DJ function. They actually might not even be around, or have audio on. IMO you can just as well put on the radio than.

Personally i don't make playlists, i just browse my library during playing, read along with chat, and pick certain words, on which i play tunes. Some people notice, most don't. But a good DJ can tell you what he thinks/feels with his music. Or "respond" with it in some form or way. Or change the atmosphere in a party. (Play a couple of ballads / slow songs followed by the upbeat one which is n1 at the charts at this moment, and you will see people wake up). It makes the event more dynamical, but this can also work for you or against you. And with all things you do, the public will respond if they like it, will not barely or not respond if it's just soso, and downright tell you it sucks or leave, if they don't like it. Such is life. Be happy we don't all like the exact same stuff, it would be boring no ?

If you become a Metaverse DJ, it is handy to have a name & own group, preferably with one or two friends that can act as host on the events you run. If you have some "core group" of friends that like your music, and attend often, it's much easier to have successful parties. Hosts are invaluable, as they greet your visitors and welcome them, keep your crowd verbally entertained, make them feel welcome and at home, and keep order, whilst you keep an eye on your stream, playlist, webpage with connected users, chat and IM's. (NB: Mind that if people don't like your choice of music, this does not mean implicitly they don't like you. But with all jobs as performer, keep in mind the if you can't stand the heat, stay out of the kitchen thing ). Generally, most "DJ's" do fine, as people appreciate the same music, and people love variety as well.

How do I become a DJ / Play at events ?

Having your own stream works for one. Having your own team works even better. But to get name & fame, you will need to work events. DJ at clubs. Put in your profile you DJ, and what Genre. Come play at the OSgrid Friday event. You might have a lot of fun entertaining others ! With all you do, keep in mind : Fun is one of the few things which never decreases or devalues by being shared. Now go out there and Party. And if there is none, you can now make your own. Have FUN !