use ffmpeg to encode/re-encode any local or remote media to mp3 and stream to shoutcast.

prerequisites:

ffmpeg with libmp3lame and openssl enabled
youtube-dl
shout-perl
libshout3
libmp3lame

usage:

$ ffmpeg -d -re -i "/path/to/local/media.wav" -vn -c:a mp3 -b:a 256k -f mp3 - | ./stream_stdin.pl

streaming to shoutcast is handled by piping audio data to a perl script (shout-perl)

here is the perl script that reads audio data from pipe or STDIN

shout_stdin.pl

#!/usr/bin/perl -w

use strict;
use Shout;
use bytes;

###############################################################################
###  C O N F I G U R A T I O N
###############################################################################

# shoutcast DNAS version 1 or 2
my $version = 1; 

# shoutcast v2 stream id
my $sid = 1; 

# hostname or ip address without http://
my $host = '123.123.123.123';

# port
my $port = 8000;

# password
my $password = 'password';

# stream name
my $name = 'ffmpeg';

# stream url
my $url = 'http://www.radioname.com';

# stream genre
my $genre = 'genre';

# 1 for public, 0 for private
my $public = 0;

# bitrate
my $bitrate = 256;

# samplerate
my $samplerate = 44100;

###############################################################################
###  M A I N   P R O G R A M
###############################################################################

my $streamer = new Shout
  host          => $host,
  port          => $port,
  password      => $password,
  name          => $name,
  url           => $url,
  bitrate  => $bitrate,
  genre         => $genre,
  format        => SHOUT_FORMAT_MP3,
  protocol      => SHOUT_PROTOCOL_ICY,
  public        => $public;

$streamer->set_audio_info(SHOUT_AI_BITRATE => $bitrate, SHOUT_AI_SAMPLERATE => $samplerate);

if ($streamer->open) {
  print "connected\n";
  print "host: $host\n";
  print "port: $port\n";
  print "password: $password\n";
  print "name: $name\n";
  print "url: $url\n";
  print "bitrate: $bitrate\n";
  print "genre: $genre\n";
  print "format: SHOUT_FORMAT_MP3\n";
  print "public: $public\n";
  print "Streaming from STDIN...\n";
  
  $streamer->set_metadata("song" => "Streaming from STDIN");
  
  my ($buff, $len);
    while (($len = sysread(STDIN, $buff, 4096)) > 0) {
  unless ($streamer->send($buff)) {
      print "Error while sending: " . $streamer->get_error . "\n";
      last;
  }
  $streamer->sync;
    }
    $streamer->close;
} else {
    print "failed... "  . $streamer->get_error . "\n";
}

remote sources are handled using youtube-dl by using backticks in the ffmpeg command. this will enable you to stream any media resource thats supported by youtube-dl and ffmpeg, such as soundcloud, mixcloud, youtube, vimeo, twitch.tv, etc.

usage:

$ ffmpeg -d -re -i "`youtube-dl -f bestaudio -g https://soundcloud.com/dubstepfm/dubstep-fm-archive-2014-11-09-all-widdler-vol-7-mixed-by-dopelabs`" -vn -c:a mp3 -b:a 256k -f mp3 - | ./shout_perl.pl

shout_perl.pl expects raw mp3 audio data via pip or STDIN. this means you can simply:

$ cat song.mp3 | ./shout_perl.pl

and it will stream a single mp3. a little bit of crafty scripting and you can easily create your own auto dj.