A mirror of my blog that I host. Mirroring it here just to provide an additional backup. Check out the real deal at http://www.justinandrewfincher.com/

Friday, September 21, 2012

Building my own media server

First, I'm going to go ahead an apologize for the sheer text in this post. I was so focused on getting everything together that I didn't really take any build pics so this will be mostly text.  Sorry about that! Continue at your own risk ;-) Background I have a growing media collection on my home computer and I have been looking at better ways to disseminate it to other devices in my home. Since I have a PS3 and my DVR can access DLNA servers, I spent a little time trying to get a server running on my old mac mini using TVMOBiLi.  It seemed to work ok for a bit (though the way files were organized was sub-par), but then I started having issues.  They likely stemmed from my mac mini dying, but I had reservations about TVMOBiLi anyhow since the free version actually had a data cap for streaming. Since I don't usually need to watch movies immediately, I just set up a script to generate a web page of links to movie files then accessed the webpage through the PS3 browser.  Then I would just download the file beforehand, watch it locally on the PS3, then delete the file.  While it only took 20-30 minutes to download a ~2 hour movie, the playback if I tried to watch while downloading was abysmal. So that was pretty much the way things worked for a while. Then my iMac started filling up!  I figured it was just about time to set up a separate media server, preferably DLNA-compatible so that I could more easily stream to our TVs. The Build I started with the small but more costly from this guide on Lifehacker. I really wanted a small form factor box, but wanted to put at least 2 drives in it so I could have a primary and a backup since I'd be moving a lot of the media off my iMac, and it is never good to have anything you want to keep stored in only one place. So the basic breakdown of what I got was as follows:
  • ARK ITX/CS-CI03 Black Mini ITX Server Chassis
  • ASRock A75M-ITX FM1 AMD A75 Motherboard
  • AMD A4-3400 Liano 2.7GHz Dual Core Processor
  • 4 GB DDR3 RAM
  • 2 Western Digital Caviar Green WD20EARX 2TB hard drives
It had been a while since I built a computer myself (probably since the one I built while I was at Auburn in 2003), but I managed to get everything packed in to the tiny little case and it booted up on the first try! If I had really been thinking about it, I would have taken build pics, but I was too focused on trying not to break anything, :-). Now the truly tricky part was finding a software configuration that was (hopefully) free, yet gave me all the functionality that I want. [caption id="attachment_1506" align="aligncenter" width="600"] 4 Hot-swappable drive bays are handy[/caption] [caption id="attachment_1507" align="aligncenter" width="600"] One might call me a cable management guru[/caption] The Setup I had previously read about several programs that ran on linux so I figured I would start out with a basic linux installation and go from there.  Since I don't have an optical drive, I had to install via usb flash drive. I thought this would be pretty simple, but it didn't go as smoothly as I had hoped. I downloaded the Ubuntu Server iso and tried to load it following this guide. I never got the result of that to boot, so I looked around some more and switched to using UNetbootin to make it and had much better luck.  I got Ubuntu server installed, then was playing around with it some and decided I'd rather have a little more than a command line while I was first getting things set up so I switched to the standard Ubuntu install. The first program that I had read about was PS3MediaServer. I actually got it up and running fairly easily. I copied a few movie files over then tested it out through the PS3. At first, I thought the files weren't appearing, but further inspection turned them up a few directories below where I thought they'd be. A lot of the videos I have are .m4v files, which are playable on the PS3 and shouldn't cause any issues.  For some reason, PS3MediaServer had them in a subdirectory labeled "transcode" as though it was having to convert them on the fly. That, plus the fact that the basic organization was pretty crappy (lots of different folders and subfolders to look through to access any of the movies) spurned me to evaluate some other options. The next thing I looked at was GeexBox. Instead of just a program that you run, GeexBox is a full mini-OS to run. I obviously didn't read all the documentation because I tried for a while (to no avail) to install the OS over my Ubuntu install when, it turns out, GeexBox is meant to be run from the usb drive. They are working on the ability to actually install it like a typical linux distribution, but that is only in the development build (though I couldn't get it to actually install). Since that was coming, I decided to try it out as it is currently meant to run and it was ok. It looked like running XBMC on linux and the organization was ok from what I could tell, but ultimately I wanted a little more freedom and definitely didn't want to have to keep a usb drive plugged in all the time. If I had been setting this box up to be directly connected to the TV, I think I would have given GeexBox a little more testing, but for the goal I had in mind it didn't quite handle my needs. Thus I decided to revert back to Ubuntu to try more application-based options. The next one that I tried was MiniDLNA. This sounded appealing because it is a pretty bare-bones DLNA compliant server so it seemed like organization would be up to me and, therefore, I would have more freedom to set things up like I wanted. Unfortunately, I could never get it to share the actual media. I changed the config file, shutdown and restarted the server, shut down and restarted the computer, and it would still just display basic "Music,Video, Photos" folders (that were empty) when the config only had one directory where my movies were stored. As you have probably guessed, I wasn't in the mood for posting in forums and waiting for an answer. I DID look in forums and documentation for issues I had with each server, but none were helpful and I wanted something that came much closer to working right off the bat. The next option turned out to be the one I am sticking with for the time being, Serviio. It is free, though you start with a 15 day trial of the $25 Pro version, after which you just revert back to the free version. From looking over the list of features, I believe that the free version will suit all my needs (though the MediaBrowser web-based player and API for access over the internet could come in handy). It started up without fuss and had a nice GUI console to modify settings and such. It actually listened when I added folders to be included and seemed to keep things fairly organized.  One of my favorite features of Serviio was that it queries a database for metadata based on the name of the file. This is handy because it means that I can browse content by information that I would never take the time to input (year released, director, etc.). I've encountered a couple of glitches, but for the most part my test files were found without much incident. The first glitch was with the movie X-Men.  Now if you have a file named X-MEN.m4v, you would think the logical match would be for the movie X-Men, but the database kept identifying it as X-Men:First Class. I tried multiple variations and the only thing that worked was to rename it to X-MEN(2000).m4v so it would use the release date. Some of the misnamings are super random. For example, I had a file name PATCH_ADAMS.m4v and when Serviio tried to automatically determine what movie it was, it chose 101 Dalmations II- Patch's London Adventure.  That's not even close! The other glitch was with season 1 of Star Trek: The Next Generation (as if this post didn't sound geeky enough). I  tried numerous different naming schemes, but was never able to find one that enables it to find the appropriate entry in the database at first. I decided to go ahead and transfer all my regular movies over and, unfortunately, it did a pretty abysmal job in automatically finding the metadata.  One thing that really irks me is that underscores seem to trip it up and it likes spaces instead. SPACES!? I am on a linux box, not some stupid windows POS. I don't put damn spaces or parentheses in my file names.  If I have to escape characters to reference a file, THAT FILE IS NAMED INCORRECTLY! How annoying. I found a file renamer called FileBot that queries the online databases then provides options. It has it's own issues, but it let me get a lot of my files in a different naming state which seemed to help Serviio get a lot more of them correct. It also seemed to fix the issue I was having with Star Trek TNG, so that's pretty awesome. Luckily, I found a forum post where a user manually updated the derby database storing the file information for the files. I haven't tried it yet, but I'm hoping that allows me to correct all the errors in movie identification that I have left.  It got enough of them done that I think I'm just going to gradually repair everything and be more cognizant of my naming scheme for future movies. Other than the movie misidentifications, the only other thing I have found with Serviio that I don't like is that my Moxi doesn't seem to be able to view it. I am not sure why, and it doesn't really matter since the PS3 and Moxi are connected to the same TV. I just found it odd because I thought the Moxi looked for DLNA servers, but perhaps TVMOBiLi that I used initially actually offers more protocols and that is why it was accessible. I have enough going on that I don't really care to try to find out. If I make any significant changes to my setup, I will put together another post about it. :-) Final Tweaks After I got the server in a (mostly) working state, there were a few things I wanted to go to make its use run a little more smoothly. The first couple were the obvious things like set up Serviio to run upon boot and set up my iMac so it can communicate back and forth with the media server without a password (useful since the iMac will still be my primary ripping computer and I can set them up to automatically sync). Then I found this guide to using avahi to allow me to use an actual name for the media server. I may end up setting it up for more general file hosting and it will be nice to not have to deal with ip addresses for access from various devices. While I will probably do most administrative stuff through ssh, I went ahead and set up a VNC server so I could pull up a remote desktop if I felt like it. Pretty simple to set up. I also set up a new directory for DVD rips and set up a cron job on the media-server to check that directory daily and grab any new files. For now I will just deal with clearing them out on my own once I'm sure everything else is working well. One tweak that I thought would be minor but turned out to be a pain the ass was getting the media server to shut down when I shut down my iMac.  Whenever I am out of town, I always power down my computer and, especially since I'll be running the server headless, I wanted to save me the step of trying to remember to shut it down before I shut down my iMac. I knew that I could send the shutdown command remotely from my iMac, so I figured it should be pretty simple to call a script on shutdown/logout.  Turns out that isn't simple at all. I tried using rc.local.shutdown/rc.shutdown.local, adding a service to StartupItems, and played around with launchd. None of these would call the script upon shutting down.  After wrestling with it for a bit, I decided to approach it from the other side and actually got it running fairly quickly. While the ip can change because it uses DHCP, the name of my iMac (its .local address) seems to stay pretty consistent. So I set up a cronjob that calls a simple script that I wrote. The script simply pings my iMac and if the ping fails I assume the iMac is off so it shuts down the computer.  Hopefully my internal network is consistent enough that this won't be an issue, especially since it just checks once an hour, but my initial testing shows that it is working fine. [caption id="attachment_1508" align="aligncenter" width="600"] At home in the cubby[/caption] To Do List
  1. Clean up the metadata so all the videos are displayed with the proper information
  2. Transfer and organize the other videos I have on my computer
  3. Set up media server to back up all files onto 2nd drive
  4. Figure out why the fans on the case seem to be running constantly even though it isn't overheated
  5. See if I can have the iMac automatically boot the media server on startup (i.e. when I get back from out of town I only have to start the iMac)
  6. Work on organizing and ripping more of the TV seasons that I have
  7. Set up basic webserver so that any device on the network can at least access/download files


Wednesday, September 12, 2012

Sunset over Southwood

image

Saturday, September 8, 2012