Thursday, July 24, 2014

Amazon Fire TV as Media Center

Fire TV and included remote

I know you have all been wondering where I have been and why I haven't posted something seemingly random and super geeky.  I've actually had some good projects since my last geeky post. In addition to the one covered here, I have built a pfSense router/firewall and a cryptocurrency mining rig, neither of which I have blogged about. Good news! Your wait is over. I'm going to tell you a little about my Fire TV experience.

My Home Screen

The Reasoning

I have been using the Raspberry Pi Model B (the original version with 256 MB of RAM) running RaspBMC as a media center for the last couple years and overall have been very happy. Because my kids don't have move DVD discs to watch movies we haven't had any problem with lost or damaged disks, which was really the point. Of course, the fact that is a cool, fun, geeky project did't hurt either. (You can read about my initial setup again here if you want.)  Other than the fact that I like tinkering with technology I do have a few reasons for the subject of this post, upgrading the pi in favor of an Amazon Fire TV.

Goodbye RaspBMC. Hello Amazon Fire TV


1. Unified content access - Using our previous RaspBMC based setup local media was streamed to the Pi via smb, Netflix online streaming through the Wii, and alternate video streams such as from lds.org required connecting the laptop to the TV. The Fire TV allows me to do all 3 with one device.

2. Local 1080p streaming - Whether I like it or not all content is shifting away from standard definition of 480 to high definition of 720 or 1080 with 4k on the horizon. We have been getting more HD content including Michelle getting me both Star Wars Trilogies for my birthday and the kids getting Frozen. Like all the other movies we get encoded them as mkv files and stored them on my computer. For the movies listed above I did 1080p as they were Blu-ray. Likely because I have 256 MB of RAM in my Pi, increasing RaspBMC requirements, and SMB overhead, I am unable to stream any 1080p content through the Pi, even over Ethernet, without repeated pauses and buffering throughout the movie. The Fire TV overcomes this problem. It made Brooklyn very unhappy to try to watch Frozen with hiccups every minute

3. Retro gaming using emulators - Due to the relatively anemic specs of the Raspberry Pi it can really only do one thing at a time. I know they have been used to build dedicated emulators but I would have to buy another to use as an emulator requiring yet one more device. To date I have used my laptop hooked to the TV for some retro-gaming through emulation and as per number 1 would like to consolidate that to a single device which is always connected to the TV.

4. Light internet browsing - Browsing the internet through RaspBMC just isn't realistic and again connecting a separate computer i.e. my laptop is one more device.

I could go into detail about why I chose the Fire TV, but I'll just give a quick summary. Obviously, it fulfills all the requirements above, but here's my thought process.

I am unaware of any inexpensive streaming boxes which fulfill the above requirements. (Roku, Ouya, Chromecast, and Apple TV all fall short in one area or another, but that is a whole separate discussion / blog post.) Because of those requirements I was thinking that an x86 based home theater PC would be the best solution., but was put off by cost, size, power use, and fan noise. Also because of the cost I was hoping to use Linux Mint rather than Windows 7 for the operating system. Unfortunately, both emulation and Netflix compatibility are more complicated with Linux than Windows. Recently I had been impressed with some of the Intel Celeron based NUC and BRIX products like this fanless Gigabyte, but was not convinced enough to allocate the funds.  Ultimately, the main reasons I went with the Fire TV was it fulfilled my requirements above and cost $99, which is less than an x86 HTPC. Plus, it has a more powerful CPU and GPU than the other set top boxes (see above). The best reason of all is the ability to side-load other android apps like XBMC, so it is super customizable.

The Setup

There are a ton of Fire TV resources on the web. I've listed several below. Here is a link for the XBMC Amazon Fire TV wiki which is a great place to start

1. Buy Fire TV from Amazon.com. Setup and connect to network as per package instructions. (I downloaded the Netflix and Pandora apps from Amazon at this point.)

On a network connected computer
3. Download and setup the ADB utility for your operating system (Windows, OS X) or install the Android SDK
(Follow the guide in XBMC wiki link above as you have to add a path for the ADB to your operating system)

On the Fire TV
4. Enable debugging on the FireTV (System - Developer Options - ADB Debugging: On)
5. Find out your Fire TV's local IP address (System - About - Network)
  I played on my router and gave my a static IP

On a network connected computer
6. From a command prompt (Windows) or terminal (OS X and Linux) do the following after navigating the the folder with the XBMC adk previously downloaded.
   adb kill-server
   adb start-server
   adb connect (insert Fire TV IP address)
(you should see that the connection was successful)
   adb install (insert XBMC apk file name)
(this may take a few minutes and will give you a message of success when complete)

Congratulations! XBMC is installed on your Amazon Fire TV

XBMC Customizations

1. Launch XBMC (Settings - Applications - Manage Installed Applications - XBMC - Launch)
Because XBMC is not an official Amazon app it will not appear on the home screen.

xbmc-gotham-13_1-splash

The home screen is great if you have a lot of Amazon content, a subscription to Amazon Prime, or buy a lot of online content. Because I don't meet any of those requirements I was planning to stay in XBMC except for Netflix and Pandora. I was excited to learn that I could launch android applications from inside XBMC by default. (Of course, the Advanced Launcher add-on could have facilitated that. download)

Home Screen of Aeon Nox Skin

Launching Apps from inside XBMC

Under the programs menu there is a section for Android applications. For me this only appears with the default Confluence skin not in Amber or Aeon Nox. I added Netfix, Pandora, and Firefox (see below) to my favorites so that I can launch them from inside XBMC. I tried Amber but so far I like Aeon Nox better. Because of the limited processing power of the Pi I'd only used Confluence on it.

Favorites Menu setup with links to Netflix, Pandora, and Firefox
I setup  my movie and TV show libraries as previously through the smb share and was very pleased how much faster the scaper (Universal Movie Scraper and TVDB respectively) updated the library. I actually used one of these for the setup after plugging the receiver into the USB port because it is way faster for typing than an on-screen keyboard.

I added the USTV VoD Addon from Bluecop, which finds the videos posted online from various TV channels and allows me to stream them through XBMC. The included link is for the XBMC Plus repository containing USTV VodD.

Video Add-ons Menu with USTV VoD highlighted

Configuring Alternate Keymap

While I did use the wireless keyboard/touchpad for some of the setup, I prefer a remote for everyday navigation. The default keymap works pretty well, but I was very frustrated by not being able to stop a movie. You can pause and then go back to the menu but not stop playback

Default keymap
ButtonGlobal actionFullscreen video actionAmazon Fire TV remote.jpg
3Directional pad:
  • Up
  • Down
  • Right
  • Left
Directional pad:
  • Up: Next chapter or go forward 10 minutes
  • Down: Previous chapter or go back 10 minutes
  • Right: +30 seconds
  • Left: -30 seconds
4SelectOn-screen-display menu
6Context menuPlaylist
8Play/pausePlay/pause
9BackBack out of fullscreen video (does not stop playback)
Link to original image

I found the keymap below by following this link It is keymap 3 of the ones listed
ButtonGlobal actionHome screen actionFullscreen video actionAmazon Fire TV remote.jpg
3Directional pad:
  • Up
  • Down
  • Right
  • Left
Directional pad:
  • Up
  • Down
  • Right
  • Left
Directional pad:
  • Up: Next chapter or go forward 10 minutes
  • Down: Previous chapter or go back 10 minutes
  • Right: +30 seconds
  • Left: -30 seconds
4SelectSelectOn-screen-display menu
6Context menuShow FavouritesToggle subtitles on/off
7Page DownPage DownFast forward
8Play/pausePlay/pausePlay/pause
9BackBackStop
10Page UpPage UpRewind

To install an alternate keymap you can reportedly use elmerohueso's "XBMC Tweaks for FTV" program addon, but I chose to just push the file using adb. 

First, of course, you have to create a file to push. Using a text editor such as Notepad or Notepad++ copy the keymap of your choice to a file and save it as keyboard.xml.

I did use the adb shell to confirm the location of the userdata folder and I believe I had to create a keymaps folder but I don't recall the folder creation for sure. Here's the shell commands I used to navigate to the userdata folder and create the keymaps folder
   adb connect (insert Fire TV's IP address)
   adb shell
(some sources say you have to confirm shell access on your Fire TV, but this should give you access)
Navigate to xbmc userdata/keymap directory
   cd /sdcard/Android/data/org.xbmc.xbmc/files/.xbmc/userdata/
   mkdir keymaps
   exit
(to ext the shell)
   adb push keyboard.xml /sdcard/Android/data/org.xbmc.xbmc/files/.xbmc/userdata

Adding other Android Apps

I used the same process to sideload Firefox after downloading it to my computer form the Google Play store and then Adobe Flash for Android. Flash can be easily downloaded directly to your computer for sideloading but you will have to use one of the links below to download apks from to your computer from the Google Play Store.

Alternate Fire TV Home screen / Launcher

I haven't tried it yet, mostly because I am happy launching everything from inside XBMC, but there is a 3rd party launcher app which displays all apps not just the amazon approved ones. A screenshot is below. I haven't tried it.

FiredTV Launcher

Emulation

I have not not setup this up yet.  I have read multiple places that this is working. The goal is to use advanced launcher to access ROMs over the network as 8 GB internal storage can't hold many games

Conclusion

The FireTV was a great investment. It runs better, more complex skins, than RaspBMC without difficulty and rapid menu navigation. It has no issues streaming 1080p as well as skipping, fast forwarding etc. during playback. I love the ability to play my local library and access Netflix, and stream from Pandora on a single device. We will see how emulation goes in the future.

Resources

Fire TV News - good website for rooting and other hacks

Websites for downloading apks from Google Play directly to PC for sideloading

What to do with my Raspberry Pi now?

1. Streaming video from Raspberry Pi camera over wifi accessible using any web browser - I have found while doing OB anesthesia that women strain and try to look through everything including me and my anesthesia machine to see their newborn while pediatrics is taking care of him or her under the warmer. Solution a camera that can serve as a wireless access point for streaming video of the baby for mom to watch on a smartphone or tablet. Maybe I can write a blog post about that.
2. MySQL server - I use XBMC on my Fire TV, desktop PC, and laptop PC. This makes it so I can sync my XBMC libraries. I could stop a video on one device and pickup right where I left off on another. This would also facilitate me not having to manually update the libraries on 3 different devices.
3. XMPP server - Skype is great for IM and video chat, but in light of expansive NSA surveillance, government requests for access to Microsoft's servers and data, I don't think a private chat server sounds like such a bad idea. Plan is to use Prosody and pair that with Jitsi clients on PC. I don't have a good iOS client yet.

Sunday, July 6, 2014