Setting up Kodi

Another often-desired use case for Banana Pi is a media center. Kodi—formerly known as XBMC—and is the de facto standard for media centers. Therefore, people want to get Kodi on their devices.

The bad news is that to date, for several reasons, it is not possible to get hardware-accelerated video playback within the default player of Kodi on Banana Pi. It is also meaningless to just install the Kodi package from the Raspbian repository as it is compiled for the Raspberry Pi (just like VLC). Therefore, it does not work on the Banana Pi hardware.

However, we can compile Kodi from source and configure an external player to play 1080p content. Like in the previous recipe, this is also quite a complex and time-consuming task.

In this recipe, we are going to build a Kodi setup with working accelerated video playback by an external video player. To do this, it is necessary that you have configured at least one working hardware-accelerated video player (MPlayer or VLC) from the previous recipe.

Getting ready

The following ingredients are required to get Kodi working on Banana Pi:

  • A Linux system on Banana Pi
  • Access to the shell
  • An HDMI connection to your TV
  • A keyboard and mouse connected to your Banana Pi
  • A configured video player with hardware acceleration (see the previous recipe, Getting accelerated video playback)

How to do it…

The building of Kodi itself is relatively simple if you have completed the steps of the previous recipe. Let's do it:

Note

Just like in the previous recipe, you will need to have a lot of free space to build the Kodi media center.

  1. Open a shell on your Banana Pi.
  2. You will need to install a lot of new packages to be able to build Kodi. To copy and paste the following packages, you can go to the Packt Publishing website or the Compile Kodi for Linux link mentioned in the See also section of this recipe.

    Install the following packages:

    $ sudo apt-get install automake autopoint bison 
        build-essential ccache cmake curl cvs default-jre 
        gawk gdc gettext git-core gperf libasound2-dev 
        libass-dev libavcodec-dev libavfilter-dev 
        libavformat-dev libavutil-dev libbluetooth-dev libbluray-dev libbluray1 libboost-dev 
        libboost-thread-dev libbz2-dev libcap-dev 
        libcdio-dev libcec-dev libcec1 libcurl3 
        libcurl4-gnutls-dev libcwiid-dev libcwiid1 
        libdbus-1-dev libenca-dev libflac-dev 
        libfontconfig-dev libfreetype6-dev libfribidi-dev 
        libglew-dev libiso9660-dev libjasper-dev 
        libjpeg-dev libltdl-dev liblzo2-dev libmad0-dev 
        libmicrohttpd-dev libmodplug-dev libmp3lame-dev 
        libmpeg2-4-dev libmpeg3-dev libmysqlclient-dev 
        libnfs-dev libogg-dev libpcre3-dev libplist-dev 
        libpng-dev libpostproc-dev libpulse-dev 
        libsamplerate-dev libsdl-dev libsdl-gfx1.2-dev 
        libsdl-image1.2-dev libsdl-mixer1.2-dev 
        libshairport-dev libsmbclient-dev libsqlite3-dev 
        libssh-dev libssl-dev libswscale-dev libtiff-dev 
        libtinyxml-dev libtool libudev-dev libusb-dev 
        libva-dev libva-egl1 libva-tpi1 libvdpau-dev 
        libvorbisenc2 libxml2-dev libxmu-dev libxrandr-dev 
        libxrender-dev libxslt1-dev libxt-dev libyajl-dev 
        mesa-utils nasm pmount python-dev python-imaging 
        python-sqlite swig unzip yasm zip zlib1g-dev gcc-4.8 
        libtag1-dev
    
  3. Enter Y to continue the installation of the dependencies.
  4. When the packages are installed, you can download the source code of Kodi:
    $ git clone -b Helix https://github.com/xbmc/xbmc.git
    
  5. Change to the downloaded source directory:
    $ cd xbmc
    
  6. Start the bootstrap script:
    $ ./bootstrap
    
  7. Export the following environment variables:
    $ export CC=gcc-4.8
    $ export CFLAGS='-march=armv7-a -mfloat-abi=hard'
    
  8. Initiate the configuration script:
    $ ./configure --disable-debug --disable-vdpau --disable-vaapi
    

    While configuring, various essential components for Kodi are built from source. The configuration will take up to one hour to complete.

  9. Build and install Kodi:
    $ make
    

    The building process of Kodi takes a lot of time (a few hours). Eventually the shell will output the following message:

    -----------------------
    Kodi built successfully
    -----------------------
    
  10. Finally, you are ready to install Kodi:
    $ sudo make install
    

    Once Kodi is installed successfully, we can configure Kodi to use a video player as an external player.

  11. Edit or create a playercorefactory.xml file within your Kodi configuration directory:
    $ nano ~/.kodi/userdata/playercorefactory.xml
    
  12. Add the following external player configuration to let Kodi open MKV files with SMPlayer:
    <playercorefactory>
     <players>
       <player name="smplayer" type="ExternalPlayer" audio="true" video="true">
         <filename>/usr/bin/smplayer</filename>
         <args>-minigui -close-at-end -fullscreen "{1}"</args>
         <hidexbmc>false</hidexbmc>
       </player>
     </players>
     <rules action="prepend">
       <rule filetypes="mkv" filename="*.*" player="smplayer"/>
     </rules>
    </playercorefactory>

    The following screenshot shows the external player configuration of Kodi within the nano editor:

    How to do it…
  13. Exit and save nano by pressing Ctrl + X, followed by Y and Enter.
  14. If necessary, switch to your desktop and open the LXTerminal application.
  15. Within the terminal, start the Kodi media center:
    $ kodi
    

    The following screenshot shows the Kodi logo while loading the media center on Banana Pi:

    How to do it…
  16. When Kodi is started for the first time, it will update some components from the Internet. After a few seconds or minutes, it will be ready to use.
  17. Navigate to Videos | Files | Add Videos… | Browse and choose a directory containing video files (for example, the Sintel movie).
  18. Close the dialogs by clicking on OK. The directory containing the video files will be added to the video library.
  19. Enter the added video directory and play a movie file.
  20. If the video is an MKV file, Kodi will open the hardware-accelerated SMPlayer and let it play the MKV file.

You have successfully installed Kodi on Banana Pi and configured an external player to bypass the hardware acceleration problem.

How it works…

Just like in the previous recipe, we build the Kodi media center from the source code. As Kodi has a huge number of features, it requires a lot of packages pre-installed before we can build it along with its components.

Once these dependency packages are installed, we are ready to clone the source codes and initiate the building. The bootstrap script sets up the upcoming configuration script. The configuration script makes sure that all the required dependencies are met and begins the building of helper components that are needed for Kodi (for example, the multimedia solution FFmpeg). The building of Kodi itself is a time-consuming task on Banana Pi, since it is such a comprehensive media center solution.

Unfortunately, to date, it is not possible to use the internal player of Kodi for hardware-accelerated video playback on Banana Pi. The chances that this will be solved in the future are good, but until then, we need to work around the problem. Luckily, Kodi offers the concept of external players. By using an external player that is configured in the playercorefactory.xml file, we instruct Kodi to open specific multimedia files with external programs. In our case, we make use of SMPlayer we built in the previous recipe to play 1080p videos hardware accelerated while still having the functionalities of Kodi.

Consequently, the interface of the SMPlayer is not really integrated into Kodi. This means that you cannot use the features of Kodi while playing videos via SMPlayer. In my opinion however, the method used in this recipe offers the best possible solution to get a stable media center experience on Banana Pi.

There's more…

If you prefer to run your Banana Pi as a media center only, you may start Kodi automatically after booting your device.

To start Kodi on boot, do the following:

  1. Open a shell on your Banana Pi.
  2. Create the ~/.config/lxsession/LXDE directories if not existent:
    $ mkdir -p ~/.config/lxsession/LXDE
    
  3. Create or edit the ~/.config/lxsession/LXDE/autostart file:
    $ nano ~/.config/lxsession/LXDE/autostart
    
  4. Add the following line:
    @kodi-standalone
    There's more…
  5. Exit and save nano by pressing Ctrl + X, followed by Y and Enter.
  6. Reboot Banana Pi to test the autostart of Kodi on boot:
    $ sudo shutdown -r now
    

Kodi should start automatically on boot from now on. To disable Kodi on boot, simply remove the @kodi-standalone line in the autostart file or delete that file.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.221.17