Results 1 to 10 of 18

Thread: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)

Threaded View

  1. #1
    Join Date
    Mar 2007
    Cambridge, UK
    Ubuntu Development Release

    Guide to setting up a media server which streams to most media capable hardware (including PS3 and Xbox 360) with automatic Podcast downloading and scheduled BitTorrenting. This creates a perfect setup where you can get to all your media via any computer on your network, start torrents from any computer on the network and use all your untapped bandwidth during the night!

    Equipment List:

    • Computer with at least:
    • 500mhz CPU
    • 256mb of RAM
    • CD-Rom Drive
    • Harddrive with at least 2gb free. (More storage the better for media and downloads)
    • Network card (Wireless will do, cables are better)
    • PC-Monitor and Keyboard (For installing server, everything else can be done remotely)
    • One Ubuntu Server 8.04 32bit Edition CD.
    • An internet connection (For downloading podcasts and BitTorrent)


    I do not take any responsibility for any damages to hardware made by this guide! All software used is open-source and free with the exception of TwonkyMedia server. This is a proprietary piece of Linux software which I could not find such a feature rich, open-source alternative. TwonkyMedia can be installed as a free 30 day trial, which at the end of you, can purchase via their website for only $30. Its worth it! All code in this guide has been fully tested to be working with Ubuntu server 8.04 32bit LTS (Aka. Hardy Heron).

    This may not be the best way to do any of this, but its the way I know works! If you have any suggestions of changes, please let me know by PM'ing me or reply to this post. If you do not have a second computer at home and wish to do all this on the server as a client machine, or perform this guide on a desktop installation (Untested), just ignore all the parts about logging in via SSH, and just login locally and follow the exact same steps.

    This guide only works with the 32bit version of Ubuntu Server 8.04 because there are no versions of TwonkyMedia in 64bit. The rest of the guide will in 64bit work absolutely fine except steps 7 and 8. So, if you do not need media streaming, are using the 64bit version of Ubuntu Server and only wish for the automated downloads part of this guide, read on!

    Step One:
    Installing Ubuntu-Server 8.04 from CD.

    Notes: This is by no means a comprehensive guide to installing Ubuntu-Server 8.04. For full instructions please visit

    Ill assume at this point you already know how to download the Ubuntu-Server 8.04 ISO file and have burnt it to a blank CD-R – or you have used Ubuntu's handy “Ship-It” service and have had a disk sent to you. If not, there are plenty of guides on about how to do this.

    Drop the disk into the drive of the server and see if it boots into the Ubuntu install screen. If it doesn't you may have to change the boot order of your BIOS to make it do so. This varies from motherboard to motherboard so I cannot help too much here.

    Once you have booted into the the menu, choose your language of choice and hit “Install”.

    Follow all of the instructions on the screen. The trickiest part is how to partition your drive. If you are unsure when you get to the partition section, just choose “Completely remove partitions and use all available space”.

    When the installer asks you for a hostname, type “media-server” or a name for your computer on the network. This will appear to any computer viewing this server remotely.

    When it asks you for a username, I used “sysadmin”. I shall assume you have done the same for this entire guide and as the configuration files included in this guide use this username inside them, I suggest you do the same too. If for any reason you decide not to use “sysadmin”, please substitute it inside all of the configuration files where ever you may see it.

    Give this username any password you wish!

    When you get near the end of the installation it will ask you what packages you wish to install. I only choose the OpenSSHd server option. This will allow you to access the server remotely via SSH once you have setup the network address on the server.

    Once all this is complete, remove the CD, flip it over and put it back in your CD-Drive for safe keeping (or put it somewhere safe) and reboot the server. If it starts up ok, then onto step two! If not, you may wish to check out “Ubuntu.Com” for a full fledged guide on installing the Server Edition.

    Step Two:
    Updating Software and Setting Up The Network Address On The Server

    Before you remove the monitor and keyboard from the server, your going to want to update all the packages on the server and give it a static IP address. Firstly login by typing your username (“sysadmin” if you following this guide exactly) and type your chosen password. Once logged in, run the following commands and type your password when you get asked for it.

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install ntp
    This will automatically update all your packages with the latest version of all the software currently installed on the system. The final comand installs NTP, which keeps your system clock in sync with a remote server. Depending on where you chose your location to be in the server install stage, it will keep your clock accurate. This is useful due to files being accessed over a network where file modification dates might need to be monitored. It is also useful for logging and security.

    Once this is finished, its time to setup the network address of this machine. All network card settings are stored inside a simple text file in Linux, which can be edited with your favorite Linux text editor. I use 'nano' as its a little simpler, but you can use 'vim' if you prefer.

    sudo nano /etc/network/interfaces
    This will open up 'nano' with your current network settings. Look to the bottom and change the settings to the following.

    # The primary network interface
    auto eth0
    iface eth0 inet static
    Change the address and gateway settings to suite your current network settings. The ones I provided worked with my network happily as I knew my router was, and that the IP address was available for my server to use. You may have to check what IPs are available on your network. Once this has been done and you are using 'nano', you can save the file by press “Ctrl + O”. This writes the file (“out”) back to the hard drive. Then press “Crtl + X” to quit the program.

    Once saved, type this command at the terminal to restart the network.

    sudo /etc/init.d/networking restart
    This should bring the network card back up with your new settings. Once this is done your all set to remove all your devices from the server, such as the keyboard and monitor. Hit the reset button and make sure the server boots up with nothing plugged into it. If you hear any beeping you may wish to plug the monitor back in and see whats going on. Otherwise, your ready to crack on!

    Step Three:
    Logging In Remotely

    One of the luscious things about Linux is the ability to administrate everything remotely from any SSH terminal, which thankfully, Linux has built in and Windows has the awesome Putty software. In this guide I will assume you have a Linux variant installed on a client machine somewhere else on the network. If you are running Windows of some variety, then download Putty and perform all the commands using that.

    In a Linux terminal, type the following to login remotely to your server:

    ssh sysadmin@
    If you didn't use “sysadmin” as your username, change it above. You will then be prompted for the password for your username. Type it and press enter. You will now be logged in and residing in your home folder. On the filesystem, the location will be “/home/sysadmin/”. From here, you can do anything you like to your server. Including installing new software and various other tasks – all of which will be covered in the next few steps.

    The default folder you are now in we will only use to download a few installable files and keep our configuration files. All data will be stored in some new folders we shall make in the next steps.

    Step Four:
    Create Media and Storage Directories and Share Them Via Samba

    Now were going to create some folders to put all your music, videos and torrents inside. Then were going to share them via Samba so Windows, Mac and Linux clients can see them on the network.

    Firstly, you need to create the directories to put all your new data into. You can change these locations, but I chose the following setup as its clean and tidy.

    Login via SSH (or perform this locally), then do the following.

    cd /
    sudo mkdir mediaserver
    cd mediaserver
    sudo mkdir -m 777 music
    sudo mkdir -m 777 video
    sudo mkdir -m 777 torrents
    cd torrents
    sudo mkdir -m 777 Finished
    sudo mkdir -m 777 Unfinished
    sudo mkdir -m 777 Torrents
    sudo mkdir -m 777 Session
    This will make the following directory tree at the root of your filesystem:


    The reason for the “-m 777” is so that Samba can read and write to these folders, which is necessary for copying files to these folders over a network. You don't need the original “/mediaserver” folder to have this access though, as you wont be sharing that folder explicitly.

    Now you have this tree in place, you can install Samba and set it up to share these folders.

    sudo apt-get install samba smbfs
    This installs Samba along with any dependencies. To configure these shares we must do the following. First we backup the configuration in case something goes wrong (always good practice) and then we open 'nano' to edit the file.

    sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
    sudo nano /etc/samba/smb.conf
    Find this line:

    ;  security = user
    And replace it with:

    security = share
    Then scroll to the bottom of the file and append the following:

      comment = Music Folder
      path = /mediaserver/music
      public = yes
      writable = yes
      create mask = 0777
      directory mask = 0777
      force user = nobody
      force group = nogroup
      comment = Video Folder
      path = /mediaserver/video
      public = yes
      writable = yes
      create mask = 0777
      directory mask = 0777
      force user = nobody
      force group = nogroup
      comment = BitTorrent Folder (Put .torrent files inside the 'Torrents' folder)
      path = /mediaserver/torrents
      public = yes
      writable = yes
      create mask = 0777
      directory mask = 0777
      force user = nobody
      force group = nogroup
    To make any of the folders “read-only” simple change the “writeable” variable to “no”. This will lock anyone from putting and files inside that folder. Now we need to restart Samba.

    sudo testparm
    sudo /etc/init.d/samba restart
    This should all go smoothly. If you are at your client machine, go to the network folder and you should find a computer called “media-server” (or whatever hostname you gave it) and it should now have the 3 shares available. Feel free to put anything you wish inside the Music and Video folders, but ignore the Torrents share for the time being. Onto setting up automatic Podcast automatic downloading!

    Step Five:
    Installing and Configuring Podget for Automatic Podcast Downloading

    Install Podget via:

    sudo apt-get install podget
    This will install Podget with some base settings. However, we're going to change them to suit our new setup!

    sudo nano /home/sysadmin/.podget/podgetrc
    Now copy and paste the following into this file, erasing first anything that was there:

    # Name of Server List configuration file 
    # Directory where to store downloaded files 
    # Directory to store logs in 
    # Set logging files 
    # Wget base options 
    wget_baseopts=-c -nH 
    # Most Recent 
    # 0  == download all new items. 
    # 1+ == download only the <count> most recent 
    # Force 
    # 0 == Only download new material. 
    # 1 == Force download all items even those you've downloaded before. 
    # Autocleanup. 
    # 0 == disabled 
    # 1 == delete any old content 
    # Number of days to keep files.   Cleanup will remove anything 
    # older than this. 
    # Filename Cleanup: For FAT32 filename compatability (Feature Request #1378956) 
    # Tested with the following characters: !@#$%^&*()_-+=||{[}]:;"'<,>.?/ 
    # filename_badchars=!#$^&=+{}[]:;"'<>?|\ 
    # Filename Cleanup: For FAT32 filename compatability (Feature Request #1378956) 
    # Tested with the following characters: !@#$%^&*()_-+=||{[}]:;"'<,>.?/ 
    # filename_badchars=!#$^&=+{}[]:;"'<>?|\ 
    # Filename Replace Character: Character to use to replace any/all 
    # bad characters found. 
    # Filename Cleanup 2:  Some RSS Feeds (like the BBC World News Bulletin) download files with names like filename.mp3?1234567. 
    # Enable this mode to fix the format to filename1234567.mp3. 
    # 0 == disabled 
    # 1 == enabled (default) 
    # Stop downloading if available space on the partition drops below value (in KB) 
    # default:  1843200 (1800MB) 
    # ASX Playlists for Windows Media Player 
    # 0 == do not create 
    # 1 == create 
    “Ctrl + O” again to write the file and “Ctrl + X” to quit 'nano'. You don't really need to know what most of this does. Just make note of the directory at the top. If you changed this directory in the previous step, change it here. You may also want to fiddle with the AutoClean settings and how much space should be left before stopping downloading.

    Now lets configure some servers.

    sudo nano /home/sysadmin/.podget/serverlist
    This will open up the list of servers to download from. PodGet automatically downloads any RSS or XML feeds with Encapsulated tags. I have included some basic feed URLs in my server list. Copy the following into this file, erasing anything that was once there.

    # Default Server List for podget 
    # FORMAT:    <url> <category> <name> 
    # NOTES: 
    #    1. The Category must be one word without spaces.  You may use underscores. 
    #    2. Any spaces in the urls needs to be converted to %20 
    #    3. Disable the downloading of any feed by commenting it out with a #. 
    #    4. If you are creating ASX playlists, make sure the feed name does not 
    #       have any spaces in it. 
    # Find more servers at: video DL.TV video HD Film Trailers music Xbox Live Podcast music Linux Basement Podcasts
    As you can see, this file has a few instructions inside it already. I have also included some feeds for your pleasure and set them up for you. You can include new feeds with Encapsulated media by using this syntax. Take this example below:

    Code: video HD Film Trailers 
    The bit in black is the feed URL itself. Copy this from anywhere you can find podcast addresses. A few good places to look are:

    Digital Podcast
    Download Radio
    Podcast Alley
    The Podcast Bunker
    The Podcast Network
    Podcasting News Podcast Directory

    The bit in blue is the folder name to put the content into. If your feed contains video, type “video”, if its music, type “music”. These names are the folders you created earlier inside /mediaserver. If you called them anything different, make the changes here.

    The part in red is the folder name to create to put the content inside from that feed. So, for the example above. Because its a feed containing HD Movie Trailers, ive put it inside the Video directory inside its own folder called HD Film Trailers. Simple as that! Tailor this list to your needs!

    Now the fun part! You can make 'Podget' run by simply typing “Podget” at the terminal. Its not a bad idea to run it quickly to make sure your servers are working correctly and its all setup properly. However, what you really want is for it to run in the night or at a time you arn't using your connection very much. To do this you want to setup a “cron job”. This is done via the following command.

    crontab -e
    Paste this inside. This will make 'Podget' run at 3am every day of the week. Change this to your needs. The -s option makes 'Podget' run in silent mode which simply suppresses all the output which you don't really need!

    # m h  dom mon dow   command 
    0 3 * * * /usr/bin/podget -s
    That's all setup and done! You'll now have podcasts automatically downloading every night at 3am to your shared folders. You can see all the data if you view the shares from any client machine over the network.

    Step Six:
    Install Rtorrent and Schedule It For Overnight Downloads

    'Rtorrent' is a command line based BitTorrent client. Its nice and small and has some neat features, such as folder watching so you can start and stop torrents by simply dropping .torrent files into a folder of your choosing. If you made the directory tree as suggested in step 3, those folders should now become apparent in their usage!

    Firstly, install Rtorrent via this command:

    sudo apt-get install rtorrent
    Now you need to create a configuration file for 'Rtorrent'. 'Rtorrent' does not make this automatically so I will supply one for you pre-set up for all the previous configuration in this guide.

    sudo nano /home/sysadmin/.rtorrent.rc
    Now copy and paste the following into the file:

    # Default directory to save the downloaded torrents. 
    directory = /mediaserver/torrents/Unfinished 
    # Default session directory. Make sure you don't run multiple instance 
    # of rtorrent using the same session directory. Perhaps using a 
    # relative path? 
    session = /mediaserver/torrents/Session
    # Watch a directory for new torrents, and stop those that have been deleted
    schedule = watch_directory,10,10,load_start=/mediaserver/torrents/Torrents/*.torrent 
    schedule = tied_directory,10,10,start_tied= 
    schedule = untied_directory,10,10,close_untied= 
    # Move completed downloads 
    on_finished = rm_torrent,"execute=rm,$d.get_tied_to_file=" 
    on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/mediaserver/torrents/Finished/ ;d.set_directory=/mediaserver/torrents/Finished/" 
    # Close torrents when diskspace is low. 
    schedule = low_diskspace,5,60,close_low_diskspace=1024M 
    # Stop torrents when reaching upload ratio in percent.
    schedule = ratio,60,60,"stop_on_ratio=100" 
    # Check hash for finished torrents.
    check_hash = yes 
    # Encryption options. This can be useful when using an ISP that uses traffic shaping.
    This will setup 'Rtorrent' so that any .torrent files moved into the “Torrents” folder of the “Torrents” share will automatically begin downloading. It will automatically stop downloading if your disk space goes below 1gb. It will stop and remove .torrent files once a download is complete and move the file to the Finished folder. It will also use encrypted traffic where possible to stop ISP traffic shaping.

    All currently downloading torrents can be found inside the “Unfinished” folder. Generally you want to leave everything alone except the “Torrents” folder which should only contain .torrent files and the Finished folder, which you can copy your finished torrents from when they are complete.

    Now, to make this only run at certain times you will need to install Screen. I wont go into what this does, but its a useful app for running this sort of program without you being there (as 'Rtorrent' uses a front-end inside a CLI, it inst appropriate to run as a 'cron job' by itself, this is what Screen is for!).

    sudo apt-get install screen
    Now to make it run and stop at certain times do the following. Open up cron again.

    crontab -e
    And append this underneath the previous 'Podget' entry:

    # Start rtorrent at 4am every day 
    0 4 * * * screen -d -m rtorrent 
    # Stop rtorrent at 4pm every day
    0 16 * * * screen -r -X quit
    As the comments suggest, it will only run 'Rtorrent' at 4am when your connection might be quiet and stop it at 4pm when you may want to use your connection for other things. Simply change the values to whatever you need!

    Step Seven:
    Install TwonkyMedia to Stream Media to Various Devices

    Now lets go ahead and install TwonkyMedia.

    TwonkyMedia server is the software that allows you to share various folders containing music, videos and pictures and have them stream to different media enabled devices. Specifically I use it to stream music and video to my Xbox 360 on the network.

    To download it, make sure your in the default directory that you started in after logging in via SSH then type the following command.
    This invokes the “Web Get” command which downloads the address after the “wget” bit. This should only take a second. There may be a new version of the software available at a later date. To check this visit Then copy and paste the link for the “Linux Setup Script” and “wget” that instead.

    Now to install the server itself.

    sudo chmod 777
    sudo ./
    Ignore any errors about not starting properly or permissions denied – we'll fix this ourselves. This will automatically install the software to '/usr/lib/TwonkyMedia' and attempt to make it start at boot time. However, because TwonkyMedia hasn't been correctly setup to install to Ubuntu or Debian properly we shall have to do some fiddling to fix this.

    cd /etc/init.d/
    sudo chmod 755 twonkyserver
    sudo nano twonkyserver
    Look for this line inside the file:

    echo -n "Starting $TWONKYSRV ... "
    $TWONKYSRV -D -inifile "${INIFILE}"
    rc_status -v
    And replace it with:

    echo -n "Starting $TWONKYSRV ... "
    $TWONKYSRV -D -ip -inifile "${INIFILE}"
    rc_status -v
    Changing the IP according to the setup you did in step two.

    Then you need to run the following command.

    sudo update-rc.d twonkyserver defaults
    Now you can restart the server via:

    sudo reboot
    And once it has restarted you should be able to visit and see your new media server running! Onto the next step to configure it!

    Step Eight:
    Configure TwonkyMedia Server

    Now we can finally configure TwonkyMedia to periodically scan your newly made media directories full of automatically downloaded podcasts so you can stream it all to media devices like the Xbox 360 and PS3.

    In an internet browser, on a machine on your network, go to:

    Now click on “First Steps”.

    Rename the media server to anything you want to. This will be the name displayed on your media devices.

    Now click on “Sharing”.

    From here you can setup any shares you like. The top one I set as:

    And set the type to:

    “Audio Only”
    And a second one as:
    And set the type to:

    “Video Only”
    Set the re-scan time to anything you like. I have mine set to 60 which means once an hour. You can set it to anything you wish in minutes. Then hit “Save”, wait a moment, then hit “Restart Server” at the top.

    You can also setup “Internet Radio” streams. Just follow the links on the right and enjoy tweaking it to your desire. As I say in my notes at the top of this guide though, this is only a trail version of the software and purchasing it after the 30 day trial is a must if you wish to keep using it.

    Every things now setup! Go ahead and test everything just incase, but it should all work smoothly!

    Let me know if you have any problems or if you would like more information on any of the software used above.


    Note: I have also attached a .zip to this post with the guide in a nice PDF format for easy printing and reading. Its difficult setting up a server whilst looking at this forum sometimes, so, printing this guide could be useful to some. Hope it helps!
    Attached Files Attached Files
    Last edited by HornedBeast; April 30th, 2008 at 06:16 PM. Reason: Tiny Amendments


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts