Difference between revisions of "Kodi"

From ArchWiki
Jump to: navigation, search
m (Enabling shutdown, restart, hibernate and suspend: typo corrected)
(Tips and Tricks)
 
(196 intermediate revisions by 51 users not shown)
Line 1: Line 1:
[[Category:Player]]
+
[[Category:Multimedia players]]
XBMC (formerly "Xbox Media Center") is a free, [http://www.gnu.org/copyleft/gpl.html open source (GPL)] multimedia player that originally ran on the first-generation [[Wikipedia:Microsoft Xbox|XBox]], (not the newer Xbox 360), and now runs on computers running Linux, Mac OS X, Windows, and iOS. XBMC can be used to play/view the most popular video, audio, and picture formats, and many more lesser-known formats, including:  
+
[[ja:Kodi]]
 +
[[zh-cn:Kodi]]
 +
Kodi (previously known as XBMC), is a free, [http://www.gnu.org/copyleft/gpl.html open source (GPL)] multimedia player that originally ran on the first-generation [[Wikipedia:Microsoft Xbox|XBox]], and now runs on Linux, OS X, Windows, Android and iOS. Kodi can be used to play/view the most popular video, audio, and picture formats, and many more lesser-known formats, including:  
  
 
* Video - DVD-Video, VCD/SVCD, MPEG-1/2/4, DivX, XviD, Matroska  
 
* Video - DVD-Video, VCD/SVCD, MPEG-1/2/4, DivX, XviD, Matroska  
Line 6: Line 8:
 
* Picture - JPG, GIF, PNG.  
 
* Picture - JPG, GIF, PNG.  
  
These can all be played directly from a CD/DVD, or from the hard-drive. XBMC can also play multimedia from a computer over a local network (LAN), or play media streams directly from the Internet. For more information, see the [http://wiki.xbmc.org/index.php?title=XBMC_FAQ XBMC FAQ].
+
These can all be played directly from a CD/DVD, or from the hard-drive. Kodi can also play multimedia from a computer over a local network (LAN), or play media streams directly from the Internet. For more information, see the [http://kodi.wiki/index.php?title=Kodi_FAQ Kodi FAQ].
 +
 
 +
As of version 12, it can also be used to play and record live TV using a tuner, a backend server and a PVR plugin; more information about this can be found on the [http://kodi.wiki/?title=PVR Kodi wiki].  
  
 
== Installation ==
 
== Installation ==
 +
{{Note|There are device specific packages on Arch Linux ARM. While they should work out of the box on the specific device, they are NOT necessarily compatible with the kodi package!}}
 +
[[Install]] the {{Pkg|kodi}} package. Be sure to install the optional dependencies listed by pacman that apply to your specific use-case.
  
{{Note|These instructions assume you have a working X installation. If you have not done this yet, please consult [[Beginners_Guide#Graphical_User_Interface]].}}
+
== Configuration ==
 +
=== Autostarting at boot or ondemand ===
 +
The {{Pkg|kodi}} package supplies a stand-alone wrapper script {{ic|/usr/bin/kodi-standalone}} that allows a minimal system to run the application without a full blown DE.  There are several methods to enable it described below.
  
[[pacman|Install]] {{Pkg|xbmc}} from the [[official repositories]].
+
{{Warning|Select '''only one''' of the methods listed below.}}
If you plan to use the pvr extensions of xbmc you will need to install {{Pkg|xbmc-pvr-addons}}.
+
  
== Configuration ==
+
==== Kodi-standalone-service ====
 +
The {{AUR|kodi-standalone-service}} package provides {{ic|kodi.service}} and creates the needed user to run Kodi in standalone mode.  This is a drop-in replacement of the package-legacy systemd service and post install script which Arch developers have removed from the package when the Xorg package updated to 1.16-1 (see [https://projects.archlinux.org/svntogit/community.git/commit/trunk?h=packages/xbmc&id=9763c6d32678f3a3f45c195bfae92eee209d504f this commit]).  Functionally, there is no difference.
  
=== Autostarting at boot ===
+
[[Start]] {{ic|kodi.service}} and [[enable]] it to run at boot time.
  
To use XBMC on HTPC you may want to start XBMC automatically on boot. Since version 11.0-11 '''xbmc''' package includes the xbmc group, user, and service file necessary to do this.
+
{{Note|
 +
* The Xorg video driver for your specific hardware is an assumed dependency.
 +
* No additional configuration is required.
 +
* If errors persist, add the suggested lines to /etc/X11/Xwrapper.config (as outlined in next section)
 +
}}
  
To make XBMC start at system boot you should simply enable the service:
+
==== Xsession with LightDM ====
 +
{{Note|This assumes that the user has created an kodi user named kodiuser on the system and that the following file is present as described.}}
 +
{{Note|{{AUR|kodi-standalone-service}} creates a user named kodi, which is not permitted to login, thus autologin will fail with this user.}}
  
# systemctl enable xbmc
+
{{hc|/etc/X11/Xwrapper.config|2=
 +
needs_root_rights = yes}}
  
=== Enabling shutdown, restart, hibernate and suspend ===
+
To use LightDM with automatic login, see [[LightDM#Enabling autologin]] and [[LightDM#Enabling interactive passwordless login]]. ''Kodi'' includes {{ic|kodi.desktop}} as [[xsession]].
  
Since version 12 XBMC supports power management via systemd logind daemon. To enable it you should have {{Pkg|polkit}}, {{Pkg|upower}} and {{Pkg|udisks}} installed on your system.
+
{{hc|/etc/lightdm/lightdm.conf|2=
 +
[LightDM]
 +
minimum-vt=1
 +
run-directory=/run/lightdm
  
In case XBMC is started using the systemd service, the session might not get initialzed properly and therefore polkit may not allow the shutdown or reboot of the system. If this happens, adding the following rule file will allow users in the ''power'' and ''storage'' group to shutdown, restart, hibernate and suspend computer.
+
[SeatDefaults]
 +
session-wrapper=/etc/lightdm/Xsession
 +
pam-service=lightdm-autologin
 +
autologin-user=kodiuser
 +
autologin-user-timeout=0
 +
user-session=kodi
 +
}}
  
{{hc|/etc/polkit-1/rules.d/10-xbmc.rules|2=
+
==== Socket activation ====
polkit.addRule(function(action, subject) {
+
    if(action.id.match("org.freedesktop.login1.") && subject.isInGroup("power")) {
+
        return polkit.Result.YES;
+
    }
+
});
+
  
polkit.addRule(function(action, subject) {
+
Socket activation can be used to start Kodi when the user starts a remote control app or on a connection to Kodi's html control port. Start listening with ''systemctl start kodi@user.socket'' (replace ''user'' with the user running Kodi to be started as).
    if (action.id.indexOf("org.freedesktop.udisks") == 0 && subject.isInGroup("storage")) {
+
 
        return polkit.Result.YES;
+
The {{AUR|kodi-standalone-socket-activation}} package provides {{ic|kodi@.service}} and {{ic|kodi@.socket}} which can be used to run Kodi in standalone mode listening on port 8082.
    }
+
Depending on the setup, one may want to change the port in ''kodi@.socket''. This can be done by manually using the following systemd files.
});
+
 
 +
{{hc|/usr/lib/systemd/system/kodi@.service|
 +
<nowiki>[Unit]
 +
Description=Launch Kodi on main display
 +
 
 +
[Service]
 +
Type=oneshot
 +
Environment=DISPLAY=:0.0
 +
Nice=-1
 +
ExecStart=/usr/bin/su %i /usr/bin/kodi
 +
ExecStartPost=/usr/bin/bash -c "sleep 15 && systemctl start kodi@%i.socket"
 +
 
 +
[Install]
 +
WantedBy=multi-user.target</nowiki>}}
 +
 
 +
{{hc|/usr/lib/systemd/system/kodi@.socket|
 +
<nowiki>[Unit]
 +
Conflicts=kodi@%i.service
 +
 
 +
[Socket]
 +
# listen for WOL packets
 +
#ListenDatagram=9
 +
 
 +
# change this to Kodi's http control port
 +
ListenStream=8082
 +
 
 +
[Install]
 +
WantedBy=sockets.target</nowiki>}}
 +
 
 +
==== Start from remote control with LIRC / irexec ====
 +
With the help of the packages {{AUR|kodi-standalone-service}} and {{Pkg|lirc}} you can setup a configuration where you can start Kodi by pressing a key on your remote. This can be useful on a Raspberry Pi if you want to have it running 24/7 but do not want Kodi to be open 24/7, for instance if you use the Pi as Wifi-Access Point and PVR-Client. This way you can close Kodi and allow your PVR-Server to suspend/hibernate but still have your Wifi accessible - and start Kodi again without the need of a keyboard.
 +
 
 +
You need to have a working setup of [[LIRC]], the package {{AUR|kodi-standalone-service}} has to be installed.
 +
 
 +
Generate the file {{ic|/var/lib/kodi/.lircrc}} with the following content:
 +
{{hc|/var/lib/kodi/.lircrc|
 +
<nowiki>
 +
begin
 +
prog = irexec
 +
remote = devinput
 +
button = KEY_MEDIA
 +
config = pgrep kodi-standalone || /usr/bin/kodi-standalone -l /run/lirc/lircd
 +
repeat = 0
 +
end
 +
</nowiki>
 
}}
 
}}
 +
Adopt {{ic|button}} to whatever button on your remote you want to assign to start Kodi. You can use irw ([[LIRC#Testing the Remote]]) to find out the correct values for {{ic|remote}} and {{ic|button}}.
  
=== Using a remote controller ===
+
Next copy {{ic|kodi.service}} from {{ic|/usr/lib/systemd/system/}} to {{ic|/etc/systemd/system/}} and change the line
 +
ExecStart = /usr/bin/kodi-standalone -l /run/lirc/lircd
 +
to
 +
ExecStart = /usr/bin/irexec
  
As XBMC is geared toward being a remote-controlled media center, if your computer has an IR receiver, you will probably want to set up a remote using [[LIRC]]. Once you are sure your remote is working properly (tested with {{ic|$ irw}}), add '''lircd''' to your [[Daemons#Starting_on_Boot|DAEMONS Array]] and you'll be ready to create an Lircmap.xml file for it.
+
At last start and enable the service:
 +
{{bc|
 +
# systemctl enable kodi.service
 +
# systemctl start kodi.service
 +
}}
  
Using your favorite text editor, you'll need to go in and create an [[Wikipedia:XML|XML]] file at {{ic|~/.xbmc/userdata/Lircmap.xml}} (note the capital 'L'). Lircmap.xml format is as follows:  
+
=== Sharing a database across multiple nodes ===
 +
{{Warning|Updating from kodi 15x to 16x is currently broken due to some bugs within mariadb which as of 28-Feb-2016 are not yet in [community]/mariadb. For more, see the links in {{Bug|48364}}}}
 +
 
 +
One can easily configure Kodi to share a single media library (video and music).  The advantage of this is that key metadata are stored in one place, and are shared/updated by all nodes on the network.  For example, users of this setup can:
 +
* Stop watching a movie or show in one room then finish watching it in another room automatically.
 +
* Share watched and unwatched status for media on all nodes.
 +
* Simplify the setup with only a single library to maintain.
 +
 
 +
Several key things are needed for this to work:
 +
* Network exposed media (via protocols that Kodi can read, e.g. NFS or Samba).
 +
* A MySQL server.
 +
 
 +
{{Note|The following guide is only an example of one configuration and is not meant to be limiting but illustrative.  Key steps are shown but a detailed discussion is not offered.}}
 +
These assumptions are used for the guide, substitute to reflect your setup:
 +
* The media is located under following mount points: {{ic|/mnt/tv-shows}} {{ic|/mnt/movies}} {{ic|/mnt/music}}.
 +
* The network addresses of all nodes are within the 192.168.0.* subnet range.
 +
* The user wishes to use NFSv4 exports.
 +
* The IP address of the machine running both the NFS exports and the MySQL database is 192.168.0.105.
 +
* Each Kodi box is referred to as a node.
 +
* The Linux user running Kodi is 'kodi' on all nodes.
 +
 
 +
For additional info, refer to the [http://kodi.wiki/index.php?title=HOW-TO:Share_libraries_using_MySQL/Setting_up_MySQL#tab=Arch_Linux official Kodi wiki].
 +
 
 +
==== Setup an NFS server ====
 +
This section provides an example using NFS exports (NFSv4), but as mentioned above, any protocol that Kodi can read is acceptable.
 +
{{Warning|Kodi is using {{Pkg|libnfs}} to access NFS shares which only supports NFSv3 (see [https://github.com/sahlberg/libnfs/issues/37 this issue]). Therefore do not setup a NFSv4-only server or Kodi will only be able to list the shares but cannot access them.}}
 +
{{Note|Users only need one box on the LAN to serve the content, therefore, do not repeat this for each node.  The following example assumes the user is running Arch Linux, but any NFS server will work, be it Linux or BSD, etc.}}
 +
 
 +
The NFS server is provided by {{Pkg|nfs-utils}} and this only needs to be installed on the box serving up the content.
 +
 
 +
Setup the shares:
 +
# mkdir -p /srv/nfs/{tv-shows,movies,music}
 +
# mount --bind /mnt/tv-shows /srv/nfs/tv-shows
 +
# mount --bind /mnt/movies /srv/nfs/movies
 +
# mount --bind /mnt/music /srv/nfs/music
 +
 
 +
Add the corresponding entries for these bind mounts to {{ic|/etc/fstab}}:
 +
...
 +
 +
/mnt/tv-shows /srv/nfs/tv-shows none bind 0 0
 +
/mnt/movies /srv/nfs/movies none bind 0 0
 +
/mnt/music /srv/nfs/music none bind 0 0
 +
 
 +
Share the content in {{ic|/etc/exports}}:
 +
 
 +
/srv/nfs 192.168.0.0/24(ro,fsid=0,no_subtree_check)
 +
/srv/nfs/tv-shows 192.168.0.0/24(ro,no_subtree_check,insecure)
 +
/srv/nfs/movies 192.168.0.0/24(ro,no_subtree_check,insecure)
 +
/srv/nfs/music 192.168.0.0/24(ro,no_subtree_check,insecure)
 +
 
 +
{{Tip|This example sets-up read-only exports.  See {{ic|man exports}} for additional options and configurations.}}
 +
 
 +
Whenever changes are made to {{ic|/etc/exports}}, always refresh the exports:
 +
# exportfs -rav
 +
 
 +
[[Start]] {{ic|rpcbind.service}} and {{ic|nfs-server.service}} and [[enable]] them to start automatically.
 +
 
 +
Optionally check with:
 +
# showmount -e localhost
 +
Export list for localhost:
 +
/srv/nfs/tv-shows 192.168.0.0/24
 +
/srv/nfs/movies 192.168.0.0/24
 +
/srv/nfs/music 192.168.0.0/24
 +
 
 +
{{Note|If the box is using a firewall, ensure that it is not blocking connections.  This is beyond the scope of this article.}}
 +
 
 +
==== Install and setup the MySQL server ====
 +
The box running the library needs to be available 24/7 and is commonly the same box that holds the media.
 +
{{Note|The following example assumes the user is running Arch Linux, but any MySQL server will work, be it Linux or BSD, etc.}}
 +
 
 +
The MySQL server is provided by {{Pkg|mariadb}} and this only needs to be installed on one box that all nodes can access.
 +
 
 +
[[Start]] {{ic|mysqld.service}} and [[enable]] it to run at boot time.
 +
 
 +
First time setup:
 +
# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
 +
# mysql_secure_installation
 +
    <<follow the in-script prompts and answer "Y" to all the questions>>
 +
$ mysql -u root -p
 +
    <<enter the mysqld root password assigned in the first step>>
 +
MariaDB [(none)]> CREATE USER 'kodi'@'localhost' IDENTIFIED BY 'kodi';
 +
MariaDB [(none)]> GRANT ALL ON *.* TO 'kodi'@'localhost';
 +
MariaDB [(none)]> \q
 +
 
 +
No other setup to the MySQL server should be needed.
 +
{{Note|If the box is using a firewall, ensure that it is not blocking connections.  This is beyond the scope of this article.}}
 +
 
 +
==== Setup Kodi to use the MySQL library and the NFS exports ====
 +
Since this example makes use of NFS shares, an optional dependency of Kodi is now required to access them.  Ensure that each of the Kodi nodes has {{Pkg|libnfs}} installed.
 +
 
 +
===== Setup Kodi to use the common MySQL database =====
 +
To tell Kodi to use the common database, insure that Kodi is not running, then create the following file:
 +
{{hc|~/.kodi/userdata/advancedsettings.xml|
 +
<advancedsettings>
 +
  <videodatabase>
 +
    <type>mysql</type>
 +
    <host>192.168.0.105</host>
 +
    <port>3306</port>
 +
    <user>kodi</user>
 +
    <pass>kodi</pass>
 +
  </videodatabase>
 +
 
 +
  <musicdatabase>
 +
    <type>mysql</type>
 +
    <host>192.168.0.105</host>
 +
    <port>3306</port>
 +
    <user>kodi</user>
 +
    <pass>kodi</pass>
 +
  </musicdatabase>
 +
 
 +
  <videolibrary>
 +
    <importwatchedstate>true</importwatchedstate>
 +
    <importresumepoint>true</importresumepoint>
 +
  </videolibrary>
 +
</advancedsettings>
 +
}}
 +
 
 +
{{Tip|If using {{AUR|kodi-standalone-service}}, the default for the profile is /var/lib/kodi/.kodi and be sure to chown the newly created file to the kodi user and group, i.e. {{ic|# chown -R kodi:kodi /var/lib/kodi}}}}
 +
 
 +
===== Setup network shares =====
 +
{{Warning|This only needs to be done once, on only one of the nodes.  Once completed, configuration of subsequent nodes is a drop-in operation of ~/.kodi/userdata/advancedsettings.xml; no other configuration is needed!}}
 +
{{Note|Even if Kodi is running on the same box that is also running the NFS exports and MySQL server, one ''MUST'' setup the media using the nfs shares only!}}
 +
 
 +
Load Kodi and define the network shares that correspond to the exports by browsing to the following within the interface:
 +
Video>Files>Add Videos>Browse>Network Filesystem(NFS)
 +
 
 +
After a few seconds, the IP address corresponding to the NFS server should appear.
 +
 
 +
Select "/srv/nfs/tv-shows" from the list of share and then "OK" from the menu on the right.  Assign this share the category of "TV Shows" to setup the appropriate scraper and to populate the MySQL database with the correct metadata.
 +
 
 +
Repeat this browsing process for the "movies" and "music" and then exit Kodi once properly configured.  At this point, the MySQL tables should have been created.
 +
 
 +
==== Cloning the configuration to other nodes on the network ====
 +
Setting up another Kodi node on the network to use this library is trivial.  Simply copy {{ic|~/.kodi/userdata/advancedsettings.xml}} to that box and restart Kodi.
 +
 
 +
{{Note|There is NO need to do any other setup steps to define the sources since the nfs exports, the metadata for the programming, any stop/start times, view status, etc. are all stored in the MySQL tables.  If problems are encountered after this file is added to the profile directory and after Kodi is restarted, it is recommended to simply re-create the Kodi profile on that node, and again copy over the advancedsettings.xml file.  This way, only a trivial amount of configuration to the GUI itself is required which is often easier than troubleshooting conflicting local databases, sources, and the like.}}
 +
 
 +
=== Using a remote control ===
 +
 
 +
As Kodi is geared toward being a remote-controlled media center; any PC with a supported IR receiver/remote, can use remote using [[LIRC]] or using the native kernel supported modules.  To work properly with Kodi, a file will be required that maps the lirc events to Kodi keypresses.  Create an [[Wikipedia:XML|XML]] file at {{ic|~/.kodi/userdata/Lircmap.xml}} (note the capital 'L').  
 +
 
 +
{{Note|Users running Kodi from the included service file will find the kodi home (~) under {{ic|/var/lib/kodi}} and should substitute this in for the shortcut above.  Also make sure that if creating this file as the root user, it gets proper ownership as kodi:kodi when finished.}}
 +
Lircmap.xml format is as follows:  
  
 
{{bc|1=<lircmap>
 
{{bc|1=<lircmap>
Line 58: Line 271:
 
</lircmap>}}
 
</lircmap>}}
  
* '''Device Name''' is whatever LIRC calls your remote. This is set using the '''Name''' directive in lircd.conf and can be viewed by running {{ic|$ irw}} and pressing a few buttons on the remote. IRW will report the name of the button pressed and the name of the remote will appear on the end of the line.
+
* '''Device Name''' is whatever LIRC calls the remote. This is set using the '''Name''' directive in lircd.conf and can be viewed by running {{ic|$ irw}} and pressing a few buttons on the remote. IRW will report the name of the button pressed and the name of the remote will appear on the end of the line.
  
* '''XBMC_button''' is the name of the button as defined in [http://wiki.xbmc.org/index.php?title=Keymap.xml keymap.xml].
+
* '''XBMC_button''' is the name of the button as defined in [http://kodi.wiki/index.php?title=Keymap.xml keymap.xml].
  
* '''LIRC_button''' is the name as defined in {{ic|lircd.conf}}. If you automatically generated your lircd.conf using {{ic|# irrecord}}, these are the names you selected for your button then. Refer back to [[LIRC]] for more information.
+
* '''LIRC_button''' is the name as defined in {{ic|lircd.conf}}. If lircd.conf was autogenerated using {{ic|# irrecord}}, these are the names selected for the buttons. Refer back to [[LIRC]] for more information.
  
* You may want to check out the very thorough [http://wiki.xbmc.org/index.php?title=Lircmap.xml Lircmap.xml] page over at the [http://wiki.xbmc.org/index.php?title=Main_Page XBMC Wiki] for more help and information on this subject.
+
* A very thorough [http://kodi.wiki/index.php?title=Lircmap.xml Lircmap.xml] page over at the [http://kodi.wiki/index.php?title=Main_Page Kodi Wiki] should be consulted for more help and information on this subject as this is out of scope of this article.
  
 
==== MCE remote with Lirc and Systemd ====
 
==== MCE remote with Lirc and Systemd ====
  
Install {{Pkg|lirc-utils}} and link the mce config:
+
Install {{Pkg|lirc}} and link the mce config:
  
 
  # ln -s /usr/share/lirc/mceusb/lircd.conf.mceusb /etc/lirc/lircd.conf
 
  # ln -s /usr/share/lirc/mceusb/lircd.conf.mceusb /etc/lirc/lircd.conf
Line 77: Line 290:
 
  # echo lirc > /sys/class/rc/rc0/protocols
 
  # echo lirc > /sys/class/rc/rc0/protocols
  
A udev rule can be added to make lirc the default. A write rule doesn't seem to work, so a simple RUN command can be executed instead.
+
A udev rule can be added to make lirc the default. A write rule does not seem to work, so a simple RUN command can be executed instead.
  
 
{{hc|/etc/udev/rules.d/99-lirc.rules|2=
 
{{hc|/etc/udev/rules.d/99-lirc.rules|2=
 
KERNEL=="rc*", SUBSYSTEM=="rc", ATTR{protocols}=="*lirc*", RUN+="/bin/sh -c 'echo lirc > $sys$devpath/protocols'"}}
 
KERNEL=="rc*", SUBSYSTEM=="rc", ATTR{protocols}=="*lirc*", RUN+="/bin/sh -c 'echo lirc > $sys$devpath/protocols'"}}
  
Next, specify the lirc device. This varies with kernel version. As of 3.6.1 {{ic|/dev/lirc0}} should work with the default driver.
+
Finally, [[enable]] and start {{ic|lirc.socket}}.
  
{{hc|/etc/conf.d/lircd.conf|2=
+
This should give a fully working mce remote.
#
+
# Parameters for lirc daemon
+
#
+
  
LIRC_DEVICE="/dev/lirc0"
+
==== HDMI-CEC with Pulse Eight USB-CEC ====
LIRC_DRIVER="default"
+
LIRC_EXTRAOPTS=""
+
LIRC_CONFIGFILE=""}}
+
  
The default service file for lirc ignores this conf file. So we need to create a custom one.
+
An elegant way of getting remote functions in Kodi is using [[wikipedia:Consumer_Electronics_Control#CEC|CEC]], a protocol that is part of the HDMI specification. Most modern TVs support CEC, although some manufacturers advertise the feature under other names. Apart from a CEC-enabled TV some hardware that takes the CEC signals coming from the TV and present them in a way that Kodi can understand is also needed. One such device is the [http://www.pulse-eight.com/store/products/104-usb-hdmi-cec-adapter.aspx USB-CEC adapter] from Pulse Eight. Hooking up the USB-CEC is pretty simple, but in order for it to work in Arch we have to do a few things.
  
{{hc|/etc/systemd/system/lirc.service|2=
+
Install {{ic|libcec}}.
[Unit]
+
Description=Linux Infrared Remote Control
+
  
[Service]
+
When connected, the USB-CEC's {{ic|/dev}} entry (usually {{ic|/dev/ttyACM*}}) will default to being owned by the {{ic|uucp}} group, so in order to use the device the user running Kodi needs to belong to that group. The user also needs to belong to the {{ic|lock}} group, otherwise Kodi will be unable to connect to the device. To add a user to both groups, run
EnvironmentFile=/etc/conf.d/lircd.conf
+
ExecStartPre=/usr/bin/ln -sf /run/lirc/lircd /dev/lircd
+
ExecStartPre=/usr/bin/ln -sf /dev/lirc0 /dev/lirc
+
ExecStart=/usr/sbin/lircd --pidfile=/run/lirc/lircd.pid --device=${LIRC_DEVICE} --driver=${LIRC_DRIVER}
+
Type=forking
+
PIDFile=/run/lirc/lircd.pid
+
  
[Install]
+
# usermod -aG uucp,lock [username]
WantedBy=multi-user.target}}
+
  
Finally, enable and start the lirc service:
+
If more than one user uses Kodi, repeat the command for all those users. If, for example, one is using {{ic|kodi-standalone}}, the relevant command is
  
  # systemctl enable lirc
+
  # usermod -aG uucp,lock kodi
# systemctl start lirc
+
  
This should give a fully working mce remote.
+
Remember that modifying the groups of any logged in users means those users need to log out and login again in order for the changes to take effect.
  
=== Fullscreen mode stretches XBMC across multiple displays ===
+
{{Note|Trying to use the USB-CEC without belonging to above groups may lead to problems, including Kodi crashes, so make sure the correct user belongs to both groups.}}
  
If you have got a multi-monitor setup and don't want XBMC to stretch across all screens, you can restrict the fullscreen mode to one display, by setting the environment variable SDL_VIDEO_FULLSCREEN_HEAD to the number of the desired target display. For example if you want XBMC to show up on display 0 you can add the following line to your [[Bashrc]]:
+
==Tips and Tricks ==
 +
===Accessing kodi logs ===
 +
In case of an error the first point to start investigation can be {{ic|~/.kodi/temp/kodi.log}}.
 +
 
 +
=== CLI tool for kodi ===
 +
A powerful CLI tool for use with kodi is {{AUR|texturecache}}.  Users can accomplish many task from library management to querying what is currently playing.
 +
 
 +
=== Fixing the Wunderground Weather Add-on ===
 +
The wunderground now requires users to have an API key in order to receive weather data.  An API key is available free of charge for kodi users. To obtain a key, and to configure the add-on follow these steps:
 +
 
 +
# Sign up for an API key at [http://www.wunderground.com/weather/api/d/login.html wunderground]'s automated system.
 +
# Format the key for kodi's wunderground.py script (it expects the key to be reversed and base64 encoded, see below).
 +
# Enter the formatted key into '''WAIK''' variable in {{ic|~/.kodi/addons/weather.wunderground/resources/lib/wunderground.py}}
 +
 
 +
To reverse and base64 encode the API key, run this two-liner using your own API key in the "key" variable.
 +
 
 +
$ key=9cc49125b91eb85a
 +
$ echo $key|rev|base64
 +
YTU4YmUxOWI1MjE5NGNjOQo=
 +
 
 +
For this example key, the first few lines of {{ic|~/.kodi/addons/weather.wunderground/resources/lib/wunderground.py}} would look like this:
 +
# -*- coding: utf-8 -*-
 +
 +
import urllib2, gzip, base64
 +
from StringIO import StringIO
 +
 +
WAIK            = 'YTU4YmUxOWI1MjE5NGNjOQo='
 +
 
 +
=== Fullscreen mode stretches Kodi across multiple displays ===
 +
 
 +
For a multi-monitor setup, Kodi may default to stretching across all screens.  One can restrict the fullscreen mode to one display by setting the environment variable SDL_VIDEO_FULLSCREEN_HEAD to the number of the desired target display. For example, having Kodi show up on display 0, add the following line to the Kodi user's {{ic|~/.bashrc}} configuration:
  
 
  SDL_VIDEO_FULLSCREEN_HEAD=0
 
  SDL_VIDEO_FULLSCREEN_HEAD=0
  
{{Note|Mouse cursor will be held inside screen with XBMC.}}
+
{{Note|Mouse cursor will be held inside screen with Kodi.}}
 +
 
 +
=== Video tearing on Intel HD Graphics ===
 +
Users observing tearing when watching a movie try this:
 +
https://bbs.archlinux.org/viewtopic.php?id=176651
  
 
=== Slowing down CD/DVD drive speed ===
 
=== Slowing down CD/DVD drive speed ===
Line 136: Line 367:
 
}}
 
}}
  
Replace {{ic|sr0}} with the device name of your optical drive. Replace {{ic|-x 2}} with {{ic|-x 4}} if you prefer 4x-speed instead of 2x-speed.
+
Replace {{ic|sr0}} with the device name of the optical drive. Replace {{ic|-x 2}} with {{ic|-x 4}} if the preference is 4x-speed instead of 2x-speed.
  
 
After creating the file, reload the udev rules with
 
After creating the file, reload the udev rules with
 
  # udevadm control --reload
 
  # udevadm control --reload
 +
 +
=== Use port 80 for webserver ===
 +
 +
Kodi has a webservice that allows interaction through a web-interface. By default, it uses port {{ic|8080}} as {{ic|80}} requires root privileges. Use the following to permit it to use low port numbers:
 +
  # setcap 'cap_net_bind_service=+ep' /usr/lib/kodi/kodi.bin
 +
 +
[[Restart]] {{ic|kodi.service}} and set port {{ic|80}} in the configuration menu (''Services->Webserver->Port'').
 +
 +
=== Using ALSA ===
 +
 +
If [[PulseAudio]] does not work properly, try using ALSA directly by starting Kodi with the {{ic|1=AE_SINK=ALSA}} environment variable.
 +
 +
=== Soft subtitles not displaying ===
 +
 +
The {{Pkg|ffmpeg}} package is used to extract the subtitles.
 +
 +
=== H.264 playback is using only a single core ===
 +
 +
{{Tip|By default, press {{ic|O}} during playback to show codec information and CPU usage. More information about this overlay can be found [http://kodi.wiki/view/Codecinfo here].}}
 +
 +
If your setup does not or cannot make use of hardware acceleration, disable it and explicitly set video decoding to software.
 +
This is because [http://forum.kodi.tv/showthread.php?tid=170084&pid=1789661#pid1789661 H.264 decoding is only multithreaded when video decoding is set to software].
 +
To achieve this, go to {{ic|System Settings}} and then to {{ic|Video}}. Set the {{ic|settings level}} to {{ic|Advanced}} or {{ic|Expert}} and go to {{ic|Acceleration}}.
 +
There, set {{ic|Decoding method}} to {{ic|software}}.
 +
 +
=== Raspberry Pi ===
 +
 +
{{Accuracy|udev rule has anything but a statisfactory explanation for chmod 0666}}
 +
 +
Kodi runs smoothly on both the Raspberry Pi (RPi) and the RPi 2. Some helpful tips to consider:
 +
* [[Install]] the ''kodi-rbp'' package instead of ''kodi'' from the [http://archlinuxarm.org/packages Arch Linux ARM repository].
 +
* This package ships with a systemd service to run in standalone mode.
 +
* The memory reserved for GPU is 64 MB by default. This is insufficient for GPU accelerated HD video playback. Users can increase this value via a simple edit to the {{ic|gpu_mem}} tag in {{ic|/boot/config.txt}}.  A value of at least 128 MB is recommended.
 +
* Install ''omxplayer-git'', ''xorg-xrefresh'' and ''xorg-xset'' to get hardware acceleration working.
 +
* Add the udev rule {{ic|1=SUBSYSTEM=="tty", KERNEL=="tty0", GROUP="tty", MODE="0666"}} to {{ic|/etc/udev/rules.d/raspberrypi.rules}} to enable typing with a physical keyboard.
 +
 +
==== Run kodi in a window manager ====
 +
If you run kodi in a [[Window manager]] you may come across a black screen at exit, to fix you have to switch tty, a possible solution is to run kodi with this script (if you use [[sudo]]):
 +
{{hc|~/bin/kodi.sh|
 +
#!/bin/bash
 +
kodi-standalone
 +
sudo chvt 2
 +
sleep 1
 +
sudo chvt 1
 +
}}
 +
To make sure that [[sudo]] does not ask for password for {{ic|chvt}} add this line to {{ic|sudoers}} file:
 +
{{hc|/etc/sudoers|
 +
''UserNameHere'' ALL&#61;NOPASSWD: /usr/bin/chvt
 +
}}
  
 
== See also ==
 
== See also ==
  
* [http://wiki.xbmc.org/index.php?title=Main_Page XBMC Wiki] - Excellent resource with much information about Arch Linux specifically
+
* [http://kodi.wiki/index.php?title=Main_Page Kodi Wiki] - Excellent resource with much information about Arch Linux specifically
 +
* http://superrepo.org/ - xbmc Plug-in library
 +
* http://www.hdpfans.com/thread-329076-1-1.html - Kodi/xbmc Chinese plug-in library installation method
 +
* https://github.com/taxigps/xbmc-addons-chinese - xbmc-addons-chinese
 +
{{Note|xbmc-addons-chinese:Addon scripts, plugins, and skins for XBMC Media Center. Special for chinese laguage.}}

Latest revision as of 11:02, 24 April 2016

Kodi (previously known as XBMC), is a free, open source (GPL) multimedia player that originally ran on the first-generation XBox, and now runs on Linux, OS X, Windows, Android and iOS. Kodi can be used to play/view the most popular video, audio, and picture formats, and many more lesser-known formats, including:

  • Video - DVD-Video, VCD/SVCD, MPEG-1/2/4, DivX, XviD, Matroska
  • Audio - MP3, AAC.
  • Picture - JPG, GIF, PNG.

These can all be played directly from a CD/DVD, or from the hard-drive. Kodi can also play multimedia from a computer over a local network (LAN), or play media streams directly from the Internet. For more information, see the Kodi FAQ.

As of version 12, it can also be used to play and record live TV using a tuner, a backend server and a PVR plugin; more information about this can be found on the Kodi wiki.

Installation

Note: There are device specific packages on Arch Linux ARM. While they should work out of the box on the specific device, they are NOT necessarily compatible with the kodi package!

Install the kodi package. Be sure to install the optional dependencies listed by pacman that apply to your specific use-case.

Configuration

Autostarting at boot or ondemand

The kodi package supplies a stand-alone wrapper script /usr/bin/kodi-standalone that allows a minimal system to run the application without a full blown DE. There are several methods to enable it described below.

Warning: Select only one of the methods listed below.

Kodi-standalone-service

The kodi-standalone-serviceAUR package provides kodi.service and creates the needed user to run Kodi in standalone mode. This is a drop-in replacement of the package-legacy systemd service and post install script which Arch developers have removed from the package when the Xorg package updated to 1.16-1 (see this commit). Functionally, there is no difference.

Start kodi.service and enable it to run at boot time.

Note:
  • The Xorg video driver for your specific hardware is an assumed dependency.
  • No additional configuration is required.
  • If errors persist, add the suggested lines to /etc/X11/Xwrapper.config (as outlined in next section)

Xsession with LightDM

Note: This assumes that the user has created an kodi user named kodiuser on the system and that the following file is present as described.
Note: kodi-standalone-serviceAUR creates a user named kodi, which is not permitted to login, thus autologin will fail with this user.
/etc/X11/Xwrapper.config
needs_root_rights = yes

To use LightDM with automatic login, see LightDM#Enabling autologin and LightDM#Enabling interactive passwordless login. Kodi includes kodi.desktop as xsession.

/etc/lightdm/lightdm.conf
[LightDM]
minimum-vt=1
run-directory=/run/lightdm

[SeatDefaults]
session-wrapper=/etc/lightdm/Xsession
pam-service=lightdm-autologin
autologin-user=kodiuser
autologin-user-timeout=0
user-session=kodi

Socket activation

Socket activation can be used to start Kodi when the user starts a remote control app or on a connection to Kodi's html control port. Start listening with systemctl start kodi@user.socket (replace user with the user running Kodi to be started as).

The kodi-standalone-socket-activationAUR package provides kodi@.service and kodi@.socket which can be used to run Kodi in standalone mode listening on port 8082. Depending on the setup, one may want to change the port in kodi@.socket. This can be done by manually using the following systemd files.

/usr/lib/systemd/system/kodi@.service
[Unit]
Description=Launch Kodi on main display

[Service]
Type=oneshot
Environment=DISPLAY=:0.0
Nice=-1
ExecStart=/usr/bin/su %i /usr/bin/kodi
ExecStartPost=/usr/bin/bash -c "sleep 15 && systemctl start kodi@%i.socket"

[Install]
WantedBy=multi-user.target
/usr/lib/systemd/system/kodi@.socket
[Unit]
Conflicts=kodi@%i.service

[Socket]
# listen for WOL packets
#ListenDatagram=9

# change this to Kodi's http control port
ListenStream=8082

[Install]
WantedBy=sockets.target

Start from remote control with LIRC / irexec

With the help of the packages kodi-standalone-serviceAUR and lirc you can setup a configuration where you can start Kodi by pressing a key on your remote. This can be useful on a Raspberry Pi if you want to have it running 24/7 but do not want Kodi to be open 24/7, for instance if you use the Pi as Wifi-Access Point and PVR-Client. This way you can close Kodi and allow your PVR-Server to suspend/hibernate but still have your Wifi accessible - and start Kodi again without the need of a keyboard.

You need to have a working setup of LIRC, the package kodi-standalone-serviceAUR has to be installed.

Generate the file /var/lib/kodi/.lircrc with the following content:

/var/lib/kodi/.lircrc

begin
prog = irexec
remote = devinput
button = KEY_MEDIA
config = pgrep kodi-standalone || /usr/bin/kodi-standalone -l /run/lirc/lircd
repeat = 0
end

Adopt button to whatever button on your remote you want to assign to start Kodi. You can use irw (LIRC#Testing the Remote) to find out the correct values for remote and button.

Next copy kodi.service from /usr/lib/systemd/system/ to /etc/systemd/system/ and change the line

ExecStart = /usr/bin/kodi-standalone -l /run/lirc/lircd

to

ExecStart = /usr/bin/irexec

At last start and enable the service:

# systemctl enable kodi.service
# systemctl start kodi.service

Sharing a database across multiple nodes

Warning: Updating from kodi 15x to 16x is currently broken due to some bugs within mariadb which as of 28-Feb-2016 are not yet in [community]/mariadb. For more, see the links in FS#48364

One can easily configure Kodi to share a single media library (video and music). The advantage of this is that key metadata are stored in one place, and are shared/updated by all nodes on the network. For example, users of this setup can:

  • Stop watching a movie or show in one room then finish watching it in another room automatically.
  • Share watched and unwatched status for media on all nodes.
  • Simplify the setup with only a single library to maintain.

Several key things are needed for this to work:

  • Network exposed media (via protocols that Kodi can read, e.g. NFS or Samba).
  • A MySQL server.
Note: The following guide is only an example of one configuration and is not meant to be limiting but illustrative. Key steps are shown but a detailed discussion is not offered.

These assumptions are used for the guide, substitute to reflect your setup:

  • The media is located under following mount points: /mnt/tv-shows /mnt/movies /mnt/music.
  • The network addresses of all nodes are within the 192.168.0.* subnet range.
  • The user wishes to use NFSv4 exports.
  • The IP address of the machine running both the NFS exports and the MySQL database is 192.168.0.105.
  • Each Kodi box is referred to as a node.
  • The Linux user running Kodi is 'kodi' on all nodes.

For additional info, refer to the official Kodi wiki.

Setup an NFS server

This section provides an example using NFS exports (NFSv4), but as mentioned above, any protocol that Kodi can read is acceptable.

Warning: Kodi is using libnfs to access NFS shares which only supports NFSv3 (see this issue). Therefore do not setup a NFSv4-only server or Kodi will only be able to list the shares but cannot access them.
Note: Users only need one box on the LAN to serve the content, therefore, do not repeat this for each node. The following example assumes the user is running Arch Linux, but any NFS server will work, be it Linux or BSD, etc.

The NFS server is provided by nfs-utils and this only needs to be installed on the box serving up the content.

Setup the shares:

# mkdir -p /srv/nfs/{tv-shows,movies,music}
# mount --bind /mnt/tv-shows /srv/nfs/tv-shows
# mount --bind /mnt/movies /srv/nfs/movies
# mount --bind /mnt/music /srv/nfs/music

Add the corresponding entries for these bind mounts to /etc/fstab:

...

/mnt/tv-shows /srv/nfs/tv-shows none bind 0 0
/mnt/movies /srv/nfs/movies none bind 0 0
/mnt/music /srv/nfs/music none bind 0 0

Share the content in /etc/exports:

/srv/nfs 192.168.0.0/24(ro,fsid=0,no_subtree_check)
/srv/nfs/tv-shows 192.168.0.0/24(ro,no_subtree_check,insecure)
/srv/nfs/movies 192.168.0.0/24(ro,no_subtree_check,insecure)
/srv/nfs/music 192.168.0.0/24(ro,no_subtree_check,insecure)
Tip: This example sets-up read-only exports. See man exports for additional options and configurations.

Whenever changes are made to /etc/exports, always refresh the exports:

# exportfs -rav

Start rpcbind.service and nfs-server.service and enable them to start automatically.

Optionally check with:

# showmount -e localhost
Export list for localhost:
/srv/nfs/tv-shows 192.168.0.0/24
/srv/nfs/movies 192.168.0.0/24
/srv/nfs/music 192.168.0.0/24
Note: If the box is using a firewall, ensure that it is not blocking connections. This is beyond the scope of this article.

Install and setup the MySQL server

The box running the library needs to be available 24/7 and is commonly the same box that holds the media.

Note: The following example assumes the user is running Arch Linux, but any MySQL server will work, be it Linux or BSD, etc.

The MySQL server is provided by mariadb and this only needs to be installed on one box that all nodes can access.

Start mysqld.service and enable it to run at boot time.

First time setup:

# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
# mysql_secure_installation
   <<follow the in-script prompts and answer "Y" to all the questions>>
$ mysql -u root -p
   <<enter the mysqld root password assigned in the first step>>
MariaDB [(none)]> CREATE USER 'kodi'@'localhost' IDENTIFIED BY 'kodi';
MariaDB [(none)]> GRANT ALL ON *.* TO 'kodi'@'localhost';
MariaDB [(none)]> \q

No other setup to the MySQL server should be needed.

Note: If the box is using a firewall, ensure that it is not blocking connections. This is beyond the scope of this article.

Setup Kodi to use the MySQL library and the NFS exports

Since this example makes use of NFS shares, an optional dependency of Kodi is now required to access them. Ensure that each of the Kodi nodes has libnfs installed.

Setup Kodi to use the common MySQL database

To tell Kodi to use the common database, insure that Kodi is not running, then create the following file:

~/.kodi/userdata/advancedsettings.xml
<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>192.168.0.105</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </videodatabase>

  <musicdatabase>
    <type>mysql</type>
    <host>192.168.0.105</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </musicdatabase>

  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>
Tip: If using kodi-standalone-serviceAUR, the default for the profile is /var/lib/kodi/.kodi and be sure to chown the newly created file to the kodi user and group, i.e. # chown -R kodi:kodi /var/lib/kodi
Setup network shares
Warning: This only needs to be done once, on only one of the nodes. Once completed, configuration of subsequent nodes is a drop-in operation of ~/.kodi/userdata/advancedsettings.xml; no other configuration is needed!
Note: Even if Kodi is running on the same box that is also running the NFS exports and MySQL server, one MUST setup the media using the nfs shares only!

Load Kodi and define the network shares that correspond to the exports by browsing to the following within the interface:

Video>Files>Add Videos>Browse>Network Filesystem(NFS)

After a few seconds, the IP address corresponding to the NFS server should appear.

Select "/srv/nfs/tv-shows" from the list of share and then "OK" from the menu on the right. Assign this share the category of "TV Shows" to setup the appropriate scraper and to populate the MySQL database with the correct metadata.

Repeat this browsing process for the "movies" and "music" and then exit Kodi once properly configured. At this point, the MySQL tables should have been created.

Cloning the configuration to other nodes on the network

Setting up another Kodi node on the network to use this library is trivial. Simply copy ~/.kodi/userdata/advancedsettings.xml to that box and restart Kodi.

Note: There is NO need to do any other setup steps to define the sources since the nfs exports, the metadata for the programming, any stop/start times, view status, etc. are all stored in the MySQL tables. If problems are encountered after this file is added to the profile directory and after Kodi is restarted, it is recommended to simply re-create the Kodi profile on that node, and again copy over the advancedsettings.xml file. This way, only a trivial amount of configuration to the GUI itself is required which is often easier than troubleshooting conflicting local databases, sources, and the like.

Using a remote control

As Kodi is geared toward being a remote-controlled media center; any PC with a supported IR receiver/remote, can use remote using LIRC or using the native kernel supported modules. To work properly with Kodi, a file will be required that maps the lirc events to Kodi keypresses. Create an XML file at ~/.kodi/userdata/Lircmap.xml (note the capital 'L').

Note: Users running Kodi from the included service file will find the kodi home (~) under /var/lib/kodi and should substitute this in for the shortcut above. Also make sure that if creating this file as the root user, it gets proper ownership as kodi:kodi when finished.

Lircmap.xml format is as follows:

<lircmap>
  <remote device="devicename">
      <XBMC_button>LIRC_button</XBMC_button>
      ...
  </remote>
</lircmap>
  • Device Name is whatever LIRC calls the remote. This is set using the Name directive in lircd.conf and can be viewed by running $ irw and pressing a few buttons on the remote. IRW will report the name of the button pressed and the name of the remote will appear on the end of the line.
  • XBMC_button is the name of the button as defined in keymap.xml.
  • LIRC_button is the name as defined in lircd.conf. If lircd.conf was autogenerated using # irrecord, these are the names selected for the buttons. Refer back to LIRC for more information.
  • A very thorough Lircmap.xml page over at the Kodi Wiki should be consulted for more help and information on this subject as this is out of scope of this article.

MCE remote with Lirc and Systemd

Install lirc and link the mce config:

# ln -s /usr/share/lirc/mceusb/lircd.conf.mceusb /etc/lirc/lircd.conf

Then, make sure the remote is using the lirc protocol:

$ cat /sys/class/rc/rc0/protocols

If not, issue:

# echo lirc > /sys/class/rc/rc0/protocols

A udev rule can be added to make lirc the default. A write rule does not seem to work, so a simple RUN command can be executed instead.

/etc/udev/rules.d/99-lirc.rules
KERNEL=="rc*", SUBSYSTEM=="rc", ATTR{protocols}=="*lirc*", RUN+="/bin/sh -c 'echo lirc > $sys$devpath/protocols'"

Finally, enable and start lirc.socket.

This should give a fully working mce remote.

HDMI-CEC with Pulse Eight USB-CEC

An elegant way of getting remote functions in Kodi is using CEC, a protocol that is part of the HDMI specification. Most modern TVs support CEC, although some manufacturers advertise the feature under other names. Apart from a CEC-enabled TV some hardware that takes the CEC signals coming from the TV and present them in a way that Kodi can understand is also needed. One such device is the USB-CEC adapter from Pulse Eight. Hooking up the USB-CEC is pretty simple, but in order for it to work in Arch we have to do a few things.

Install libcec.

When connected, the USB-CEC's /dev entry (usually /dev/ttyACM*) will default to being owned by the uucp group, so in order to use the device the user running Kodi needs to belong to that group. The user also needs to belong to the lock group, otherwise Kodi will be unable to connect to the device. To add a user to both groups, run

# usermod -aG uucp,lock [username]

If more than one user uses Kodi, repeat the command for all those users. If, for example, one is using kodi-standalone, the relevant command is

# usermod -aG uucp,lock kodi

Remember that modifying the groups of any logged in users means those users need to log out and login again in order for the changes to take effect.

Note: Trying to use the USB-CEC without belonging to above groups may lead to problems, including Kodi crashes, so make sure the correct user belongs to both groups.

Tips and Tricks

Accessing kodi logs

In case of an error the first point to start investigation can be ~/.kodi/temp/kodi.log.

CLI tool for kodi

A powerful CLI tool for use with kodi is texturecacheAUR. Users can accomplish many task from library management to querying what is currently playing.

Fixing the Wunderground Weather Add-on

The wunderground now requires users to have an API key in order to receive weather data. An API key is available free of charge for kodi users. To obtain a key, and to configure the add-on follow these steps:

  1. Sign up for an API key at wunderground's automated system.
  2. Format the key for kodi's wunderground.py script (it expects the key to be reversed and base64 encoded, see below).
  3. Enter the formatted key into WAIK variable in ~/.kodi/addons/weather.wunderground/resources/lib/wunderground.py

To reverse and base64 encode the API key, run this two-liner using your own API key in the "key" variable.

$ key=9cc49125b91eb85a
$ echo $key|rev|base64
YTU4YmUxOWI1MjE5NGNjOQo=

For this example key, the first few lines of ~/.kodi/addons/weather.wunderground/resources/lib/wunderground.py would look like this:

# -*- coding: utf-8 -*-

import urllib2, gzip, base64
from StringIO import StringIO

WAIK             = 'YTU4YmUxOWI1MjE5NGNjOQo='

Fullscreen mode stretches Kodi across multiple displays

For a multi-monitor setup, Kodi may default to stretching across all screens. One can restrict the fullscreen mode to one display by setting the environment variable SDL_VIDEO_FULLSCREEN_HEAD to the number of the desired target display. For example, having Kodi show up on display 0, add the following line to the Kodi user's ~/.bashrc configuration:

SDL_VIDEO_FULLSCREEN_HEAD=0
Note: Mouse cursor will be held inside screen with Kodi.

Video tearing on Intel HD Graphics

Users observing tearing when watching a movie try this: https://bbs.archlinux.org/viewtopic.php?id=176651

Slowing down CD/DVD drive speed

The eject program from the util-linux package does a nice job for this, but its setting is cleared as soon as the media is changed.

This udev-rule reduces the speed permanently:

/etc/udev/rules.d/dvd-speed.rules
KERNEL=="sr0", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1", RUN+="/usr/bin/eject -x 2 /dev/sr0"

Replace sr0 with the device name of the optical drive. Replace -x 2 with -x 4 if the preference is 4x-speed instead of 2x-speed.

After creating the file, reload the udev rules with

# udevadm control --reload

Use port 80 for webserver

Kodi has a webservice that allows interaction through a web-interface. By default, it uses port 8080 as 80 requires root privileges. Use the following to permit it to use low port numbers:

 # setcap 'cap_net_bind_service=+ep' /usr/lib/kodi/kodi.bin

Restart kodi.service and set port 80 in the configuration menu (Services->Webserver->Port).

Using ALSA

If PulseAudio does not work properly, try using ALSA directly by starting Kodi with the AE_SINK=ALSA environment variable.

Soft subtitles not displaying

The ffmpeg package is used to extract the subtitles.

H.264 playback is using only a single core

Tip: By default, press O during playback to show codec information and CPU usage. More information about this overlay can be found here.

If your setup does not or cannot make use of hardware acceleration, disable it and explicitly set video decoding to software. This is because H.264 decoding is only multithreaded when video decoding is set to software. To achieve this, go to System Settings and then to Video. Set the settings level to Advanced or Expert and go to Acceleration. There, set Decoding method to software.

Raspberry Pi

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: udev rule has anything but a statisfactory explanation for chmod 0666 (Discuss in Talk:Kodi#)

Kodi runs smoothly on both the Raspberry Pi (RPi) and the RPi 2. Some helpful tips to consider:

  • Install the kodi-rbp package instead of kodi from the Arch Linux ARM repository.
  • This package ships with a systemd service to run in standalone mode.
  • The memory reserved for GPU is 64 MB by default. This is insufficient for GPU accelerated HD video playback. Users can increase this value via a simple edit to the gpu_mem tag in /boot/config.txt. A value of at least 128 MB is recommended.
  • Install omxplayer-git, xorg-xrefresh and xorg-xset to get hardware acceleration working.
  • Add the udev rule SUBSYSTEM=="tty", KERNEL=="tty0", GROUP="tty", MODE="0666" to /etc/udev/rules.d/raspberrypi.rules to enable typing with a physical keyboard.

Run kodi in a window manager

If you run kodi in a Window manager you may come across a black screen at exit, to fix you have to switch tty, a possible solution is to run kodi with this script (if you use sudo):

~/bin/kodi.sh
#!/bin/bash
kodi-standalone
sudo chvt 2 
sleep 1
sudo chvt 1

To make sure that sudo does not ask for password for chvt add this line to sudoers file:

/etc/sudoers
UserNameHere ALL=NOPASSWD: /usr/bin/chvt

See also

Note: xbmc-addons-chinese:Addon scripts, plugins, and skins for XBMC Media Center. Special for chinese laguage.