Monday, April 13, 2015

Raspberry Pi 2 as Plex Media Player with RasPlex - Complete Guide and Setup


Background

       Currently I am using a custom windows HTPC for main media player and whs 2011 server hosting Plex Media Server. It plays everything I throw at it flawlessly and you can see previous posts on that setup. I do have a few issues with display and sleep/wake issues where it doesn't all show up on screen. This isn't a big issue for me as I know a couple of buttons to try that will wake it up, but the wife gets confused sometimes and complains. I will probably work on that in the future, but with the new raspberry pi 2 I decided to give it a go and see how well it works. We are moving shortly and will add second tv in bedroom so this would be perfect device to add to second tv.

What parts to order

Buy a preconfigured Kit

    

Or

    

Optional Remote

        

Optional for initial Setup (USB Keyboard)




  • You can choose to stick with the bare Raspberry Pi 2 (make sure its the newer 2 version). To be honest, for all you get with the kit its worth it even if you don't end up using all the parts they give you. I went with Canakit because of the black case. 
  • Of the optionals I added the FLIRC so I could use it with the Logitech Harmony Smart Remote. This is optional based on your setup because some people will be able to use CEC with their TV's. The CEC path was just too laggy for me, however the power management would have been nice that comes with CEC. I will discuss how to setup with FLIRC to work with Harmony remote below. Some people go with a Windows MCE Remote USB dongle which would work as well. I already have one connected to my HTPC so I didn't want interference of signal and difficulty of setting up 2 MCE remotes in harmony software. 
  • You will need basic usb keyboard for the initial setup, but won't need it again after that
  • The Canakit comes with a cheap class 6 8GB microsd card that seems to be working fine with my setup, but I am planning on upgrading to a class 10 16GB/32GB card
  • It also comes with a cheap wifi usb dongle. If you want a faster/better dongle than you can upgrade to Panda 300Mbps here

--------------------------------------------------------------------------------------------------------------------------

1. Go to this website and download RasPlex for whatever you operating system you will be using to install Rasplex. I have a mac so chose OSX.

2. Open up GetRasPlex program



3. Enter your computer's password into the terminal window that opens up. This will open up a graphical interface of RasPlex



4. Insert your microSD card into an adaptor and plug it in to your computer

5. Under 'Select Your Device' choose Raspberry Pi 2

6. Under 'Select Version' choose 0.5.1 (currently the most current build)

7. Under 'Select Device to Flash' choose your memory card that you inserted

8. Click Download (this will download the version you selected)

9. Once its done downloading you should be able to select 'Write SD Card'

10. Once its done you can remove the SD card and put it in the Raspberry Pi memory card slot

--------------------------------------------------------------------------------------------------------------------------

11. Go to this FLIRC website to download the software to program remote

12. Open up FLIRC



13. Now you need to choose how complex you want your remote to be. The basic standard setup would be useful is you want to use an Apple Remote (from Apple TV). I chose to use Kodi as it is similar to Plex. Go to Controllers at the top of the screen from menu bar and select which device you want to use.

NOTE: Before you continue you should have already programed your harmony remote to use with Plex and have that activity working and active when setting up FLIRC remote. Harmony has a special device for plex so when setting it up choose Plex as the manufacturer as well as the model.



14. Grab your harmony remote (make sure the plex activity is active on the remote) and program the remote by selecting the button with the software and then pressing the corresponding button on the remote. Their should be feedback from the software that says pairing complete.

        - I paired Up, Down, Left, Right, Enter/Select, Fast Forward, Rewind, Info, Back, Home (Exit)

15. Unplug FLIRC from computer and plug it into USB port of Raspberry Pi

--------------------------------------------------------------------------------------------------------------------------

16. Use Plex app instead of remote control




  • The Plex app is available for iOS, Android and even Windows Phone. It is both a Plex client (so you can stream movies to your mobile if you wish) and a remote control for other Plex clients. 
  • Tap the Choose Player button — it’s the rectangle with the WiFi symbol in one corner — and select the player you want to control; in my case it’s plexhometheatre on rasplex. If I had Plex running on any other device it’d also appear on this list.
  • Once you’re connected, if you select a movie or TV show in the Plex app on your mobile, it will play on your Raspberry Pi. You’re also able to pause, fast forward, rewind or change what you’re watching from the app.

--------------------------------------------------------------------------------------------------------------------------


17. Network - You can plug in Wifi adaptor that comes with canakit or use ethernet for better performance. Note-I have read of usb issues when using wifi adaptor and other usb devices at same time

--------------------------------------------------------------------------------------------------------------------------

18. Power on raspberry pi by plugging the power cord in



19. Go through initial RasPlex Setup


  • Select your regional settings (most likely ‘English’ if you are reading this!)
  • Setup networking – you will need to select you wireless network and login. Wired networks should not need any configuration. If all is working well, you should be assigned an IP address by your router or DHCP server
  • Calibrate your screen – You will be asked to setup the corners, subtitle location, etc.
  • Login to your ‘My Plex’. You will be asked to use your computer (or any device with a web browser really) to navigate to plex.tv/pin and input you pin and connect.
  • Pre-caching – you will be asked to ‘pre-cache’ much of the meta data from your Plex server to improve performance. You will need to reboot after install is complete for this to take effect.
20. Optional - Overclock Raspberry Pi to speed things up. 
         There are two ways to do this. Locally with microSD card attached to computer or through ssh. 
  • SSH
    • Make note of your Raspberry Pi IP address which can be found in “System Settings – > Connections”
    • Use your choice of program to ssh into your raspberry pi (I prefer terminal in OSX)
    • type 'ssh root@(ip address of raspberry pi)' without quotes 
      • ex. ssh root @192.168.1.12
    • Enter your RasPlex password (default is rasplex)
    • type  mount -o remount,rw /flash
    • edit /flash/config.txt using nano: nano /flash/config.txt
    • I chose to go with High settings (don't mess with turbo). Look for the image below and replace with what level you choose
    • Hit 'control + X' on keyboard
    • Type 'Y' to save file
    • Hit 'Enter' on keyboard to confirm overwrite
    • Type reboot and hit enter in terminal to reboot raspberry pi

overclock
  • Local
    • With the MicroSD card still connected to your computer, navigate to it using Windows Explorer or Finder.
    • Change the arm_freq, core_freq, sdram_freq and over_voltage to match the recommend values you want (see image below).
    • Open the file config.txt in a text editor. Under Overclock mode settings you’ll see the recommended overclock configurations. Beneath them is where you change the settings. I set mine to High.
    • Eject the MicroSD card and insert it in the Raspberry Pi.
overclock

21. For some reason the CEC adaptor and my FLIRC were being interfered and the responsiveness of the remote just wasn't up to par. So if you are having remote issues and you see a CEC adaptor enabled when loading RasPlex I recommend going disabling CEC.
  • Go to Preferences of RasPlex
  • Go to input devices
  • Select the CEC adaptor
  • Turn off all functions of CEC by unchecking all items
22. Other options for speeding up RasPlex

  • Precaching - HIGHLY RECOMMENDED
    • Precaching is recommended by RasPlex. It copies a cache of images, thumbnails, and metadata to the client side in order to speed up menu browsing. To ensure that all the images, thumbnails and meta data is copied to your Raspberry Pi, you can force ‘precaching’.
    • To do this browse to the left to access the settings menu. There will be an option to ‘control precaching’ then select yes to begin the global precaching. Note that if you are connected to Plex servers with large libraries or to remote Plex servers, it will take sometime to download all of the images and metadata. Once this is complete, you should notice browsing your libraries to be quite a bit faster.
rasplex performance
  • Disable Background Slide Show
    • I’ve find that while all the media displayed in the background looks pretty good, it does tend to slow browsing the menus and your media down. To disable the slide show go to: “Preferences -> Appearance -> Advanced -> Settings -> Disable All Slide Shows”.
rasplex performance
    • It is also possible that you can switch to a lighter weight skin, but this is not something I’ve explored. 
  • Disable Unwanted/Unused Services
    • Many users have reported that disabling some of the services you are not using, like samba, SSH, cron, etc can speed up RasPlex. I’m not sure I noticed much difference, but if you aren’t using these services anyway it certainly can’t hurt to disable them. You can review the services running by navigating to the left and then selecting “System Settings – > Services”. There are also some other services such as AirPay and UPnP which can be disabled if you are not using them under “Preferences -> System -> Services”.
rasplex performance
    • It has also been reported that disabling sending anonymous performance data might help performance. Again, there wasn’t a perceptible difference for me. You can disable by clicking left and going to: “Preferences – > System – > Advanced – > Allow Plex collect anonymous data to improve your experience”. But if you don’t see an improvement and don’t mind sending some data back to Plex you may contribute to the project by leaving it on.
24. Install Media Codecs (If needed to play some content on Plex)
  • What You will Need 
    • An MPEG-2 (~$4)and/or VC-1 license(~$2) purchased from the Raspberry Pi store.
    • Access to the command prompt on the Raspberry Pi 
  • First, I will walk you through getting the serial number off the board and purchasing the licenses you need. After that, I’ll show you how to manually add the licenses to your Pi.
  • Purchasing the Licenses
    • In order to purchase the licenses you need, you will have to retrieve the unique serial number for your Raspberry Pi board. This number is not printed anywhere on the circuit board but is instead stored in the hardware; it must be retrieved using the command prompt.
    • Retrieving the Serial Number: First, visit the command prompt via an SSH tool such as Terminal. 
    • The default password for RasPlex is rasplex.
    • Once at the command prompt enter the following command: cat /proc/cpuinfo
    • Your Pi will spit back 11 lines of text, but the only one of interest to us is the last line labeled Serial. Copy the unique 16 digital serial number (partially obfuscated in the screenshot here).
    • Because the license is granted to each specific Raspberry Pi board, repeat the above process for all Raspberry Pi boards you wish to purchase a license for.
    • Once you have the the serial number for each individual unit, it’s time to purchase the licenses from the Raspberry Pi foundation.
  • Purchasing the License: Visit the Raspberry Pi foundation’s purchase page for the MPEG-2 license and/or VC-1 license.  Enter your Raspberry Pi serial number in the appropriate blank beneath the price. Add the license to your cart. Repeat this process for all the licenses on all the units you wish to add the codecs to.
  • Although the foundation indicates that it could take up to 72 hours for your license to arrive via email, we received ours in about 24 hours. When your email arrives it will include a code for each license formatted like such:
    • decode_MPG2=0000000000
    • decode_WVC1=0000000000
    • The 0000000000 portion of the license is your unique 10-digit alphanumeric license code.
  • Installing the Licenses
    • Now that we have the license codes, it’s time to add them to your Raspberry Pi and get to enjoying enhanced media playback.
    • type  mount -o remount,rw /flash
    • edit /flash/config.txt using nano: nano /flash/config.txt
    • Cut and paste the formatted license entries you received in your email below the lines that include the # (This denotes a note in computer code so the OS knows to ignore anything after this point. Therefore when you copy the licenses make sure there is no # before them.)
    • Hit 'control + X' on keyboard
    • Type 'Y' to save file
    • Hit 'Enter' on keyboard to confirm overwrite
    • Type reboot and hit enter in terminal to reboot raspberry pi
    • You can verify that the licenses are installed correctly by ssh into your pi and type the following
      • vcgencmd codec_enabled MPG2 
      • vcgencmd codec_enabled WVC1 
    • Should say license is enabled