Wednesday, September 16, 2015

XBMC / KODI to create a private Netflix (Media center) on your Mac

Lately I have researched how to manage and archive digital content.
While looking at the data sizes, video of TV shows and DVDs / Youtube etc. make a large percentage of the data to manage. I wanted to be able to archive them but also manage their metadata so it was easy to find them. With all the choices in digital online viewing, I got interested in how to transition the content I had at home to a similar experience.

The goals of this project.


  • Organize all the video content that I have lying around.
  • The content should be stored on an external hard disk.
  • Netflix / Apple TV like experience.
  • Manually add metadata if it does not exist.
  • Metadata of the content should be available (Title, Plot, Cast etc.) online preferably.
  • Backup the metadata once downloaded so I have it incase the online provider goes bust. (or worse starts getting commercial.)
  • An option to use a low power PC (Raspberry etc.)
  • Easy to setup and maintain.
  • Download Youtube movies and store them in this archive.
  • Playback on my TV (wired with HDMI or wireless with UPnP).
  • (Update 1/16) - Control playback from Kodi to my TV using ArkMC app on my iPhone.

Software and hardware used for the project.

  1. Hardware - Macbook Pro (Retina, 15 inch, Late 2013, 2.6Ghz i7, 16GB) with Mac OS X Yosemite (v10.10.5)
  2. Kodi (called XBMC in the past) Isengard v15. (site and wiki pages) (Alternatives in Linux - MiniDLNA and Rygel)
  3. Youtube DL - a Mac terminal script to download Youtube. (Github site youtube-dl)
  4. Handbrake - a GUI for converting DVDs to MP4 and converting video formats. (site ) 
  5. Optionally - Filebot (site) to get information to rename files using information from TheMovieDB, The TVDB etc. 

Installing Kodi and preparing your files for Kodi.

Download the Mac installer from the Kodi download site.

Launch the DMG and drag / drop the Kodi app to your Mac's application folder.
Before you start Kodi, organize and rename the digital video files.(Links - Naming videos;    link). 

I used the default Movies folder. I created subfolders for Movies ; TV Shows DE ; TV Shows EN. Each of these subfolders will be created as a Library source in Kodi after setup. (The DE / EN split is so that descriptions pulled by the scraper from TVDB are in DE or in EN. The language settings are in the advanced settings when you select a scraper.) I searched TheTVDB to find the exact name of the TV show. In the TV Shows folder, create a subfolder with that name and put all video files for the show in the folder.

Rename your TV show video files so it has a "s0xe0x" e.g. avatar_s01e01.m4v.
Multi episode video files should have "s01e12.s01e13.s03e02" in the file name. If the season is the same, it can be "s01e12e13e14" instead. Use the TVDB to get the correct episode and season numbers. When you are ripping from TV show DVD collections, in some cases (e.g. Firefly) the order of shows on the DVD and the order when they were aired can differ. You can select which order in the advanced settings of a video library source.

Starting with Kodi

Kodi / XBMC user interface is not as intuitive as the Netflix or Apple TV experience. You have to get used to the mouse scrolling and fiddly changes to menus. Remember to click the "X" to close new panels or windows. Furthermore, the look and feel (skin) can be completely changed. I settled on the default skin (Confluence) until I get more familiar.

Get acquainted with Kodi - Their wiki page is quite extensive but you don't have to read all of it.
Select the menu Video > Library and add the folders you created above as new video sources (by clicking the Add Videos icon or link). The Wiki instructions are quite clear. I selected the TVDB scraper for TV Shows. Select the Advanced settings to change the language from EN to DE for the TV Shows DE video source. You can correct / change the video source by right clicking and selecting "change content".
Tip: If you mess up your library - remove the video sources - and select Clean Library in video settings. This will remove missing videos and related media information. Add the video source back in again.
Tip: You can change the scraper settings in a folder inside the source. Use Video>Files and select the folder and then right click to "Change Content".
Tip: When searching TVDB for non-English; the description can be different for different languages. For example the German text may be more accurate than the English description for a German TV show.

NFO files - are used to provide information for files that do not have metadata. (Link - NFO filesNFO files for TV). I did not create any NFO files during this first try. NFO files will override any online service.

Adding public content from Germany

Video sources do not have to only be files on your hard disk. When you add a video source, select "Add Ons". I found add ons for ARD videos , BayernFunk TV videos, Apple iTunes trailers.

Bookmarks for episodes - in a multi episode file.

One nice feature in Kodi is the bookmarks for video files. It will automatically read any chapter marks in your M4V and display them in the bookmark browser. (while playing, select the bookmark button from the player controls). 
In a file with multiple episodes, you can set special episode bookmarks - which link an episode starting point to that point in the video. 
However, the "watched" settings is for the entire file. So if you select "watched", it will mark all episodes in the file as "watched".

UPnP server in Kodi

UPnP and DLNA have been around for a while but never really captured mainstream wow like AirPlay. I tried them in 2012 and found them to be clunky to get working. The situation seems better now. It was fairly straightforward for me to send video to my TV from Kodi.

To clear up some terms, Kodi can be a UPnP client (which streams videos stored another server or accepts videos sent by a UPNP control point) or a UPNP server (to provide a video library and stream videos to your UPNP client / TV) or a UPNP control point (which lets you beam video to your TV like AirPlay ). (link to the wiki for UPNP )

I set up Kodi as a UPNP server so I can browse the video library from the TV. 
Go to System>Settings>Services>UPNP.
Enable "Share video and music libraries through UPnP".
Go to the Samsung TV - and click the "sources" button. You should see Kodi as one of the sources that you can select. Otherwise use the AllShare app to select the Kodi UPnP server.

UPNP control point in Kodi

The Samsung video library browser sucks. Rather than struggle with that I decided to stick with the Kodi UI for browsing and start the video from Kodi to play on my TV. This requires a UPNP control point to be turned on.

Go to System>Settings>Services>UPnP.
Enable "Look for remote UPnP clients". 
This tells Kodi to scan for TVs in your network (make sure you are on the same wireless network and subnet). To avoid waiting, I switch on the TV and wait for 30 seconds before restarting Kodi.

To use the beam to feature - right click the video or tv show - and select "Play To....". You should see "default (DVD player)" which is the local player and "TVXXXXXX" which is your TV's UPnP identifier.  The first time you do this on a Samsung - the AllShare popup will ask you to authorize Kodi - select OK by clicking the "enter" button on your remote (usually in the center of the arrow keys).

Update 1/2016 - ArkMC Pro - has an excellent app that can act as a control point for Kodi. So you can stream from Kodi to your TV and use the app to control it. Far easier than Kodi or the Samsung app.



Handbrake tips

  • Install Handbrake.
  • When ripping the DVDs with multiple subtitles tracks and multiple audio tracks; you should select the "Audio" and "Subtitle" tabs. Use the drop-downs to select multiple audio tracks and multiple subtitle tracks. 
  • UPNP caveats - For subtitles, I did not select "force burn-in" which burns in the subtitles into the main video stream. Currently (Sep-2015) Kodi does not send the subtitles (link to forum thread about this) to my Samsung TV. Also there is no control / button in the Kodi UI to select subtitles or alternate audio streams; when you are playing to a UPNP device.

Creating NFO files manually (incomplete - to do)

NFO files - are used to provide information for files that do not have metadata. (Link - NFO filesNFO files for TV). I did not create any NFO files during this first try. I installed Filebot to get metadata about movies and TV shows. Filbert is a very nice tool to rename files to a standard format. Once renamed I was able to see the show data for each show. Hint - make sure you have a subfolder for each show - or have selected the folder has only one show.


Missing features (removable hard disks)

I would like to store all these videos on external hard disks. However Kodi does not have any means to indicate whether a movie is local or external hard disk. There is some support for removable optical disks but none for removable hard disks. You can hack the skin to display the file path in the video browser - but that is not clean enough. Will have to revisit again.