「Kodi」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(en:Kodiへの転送ページ)
 
1行目: 1行目:
  +
[[Category:プレイヤー]]
#redirect[[en:Kodi]]
 
  +
[[en:Kodi]]
  +
{{Note|バージョン14のリリースから XBMC は Kodi に名前が変更されました。}}
  +
  +
Kodi はフリーで、[http://www.gnu.org/copyleft/gpl.html オープンソース (GPL)] のマルチメディアプレイヤーであり、もともとは初代の [[Wikipedia:ja:Microsoft Xbox|XBox]] 上で動作していました (最近の Xbox 360 ではありません)。現在では Linux, Mac OS X, Windows, Android, iOS などのデバイスで動作します。Kodi を使うことでよく使われているフォーマットの動画、音声、画像や、あまり有名でないフォーマットを再生・表示することができます:
  +
  +
* 動画 - DVD-Video, VCD/SVCD, MPEG-1/2/4, DivX, XviD, Matroska。
  +
* 音声 - MP3, AAC。
  +
* 画像 - JPG, GIF, PNG。
  +
  +
以上のフォーマットはどれも CD/DVD から直接再生したり、ハードドライブから再生することが可能です。また、Kodi はローカルネットワーク (LAN) 上のコンピュータからマルチメディアを再生したり、インターネットから直接メディアストリームを再生することもできます。詳細な情報は、[http://kodi.wiki/index.php?title=Kodi_FAQ Kodi FAQ] を見て下さい。
  +
  +
バージョン12から、チューナーとバックエンドサーバー、PVR プラグインを使って TV 放送を再生したり録画することもできるようになりました。TV 放送の表示方法に関する情報は [http://kodi.wiki/?title=PVR Kodi wiki] にあります。
  +
  +
== インストール ==
  +
[[公式リポジトリ]]から {{Pkg|kodi}} パッケージを[[pacman|インストール]]してください。あなたの使い道にあわせて、pacman によって表示される任意の依存パッケージもインストールするようにします。
  +
  +
== 設定 ==
  +
=== ブート時や必要なときに自動で起動 ===
  +
{{Pkg|kodi}} パッケージにはスタンドアロンのラッパースクリプト {{ic|/usr/bin/kodi-standalone}} が入っており、完全な DE がなくとも最低限のシステムでアプリケーションを実行できるようになっています。以下で記述しているように、ラッパースクリプトを有効にする方法は複数存在します。
  +
  +
{{Warning|この機能を有効にするときは以下の方法の'''どれか一つだけ'''を選んでください。}}
  +
  +
==== Kodi-standalone-service ====
  +
[[AUR]] の {{AUR|kodi-standalone-service}} パッケージは {{ic|kodi.service}} を提供して、スタンドアロンモードで Kodi を動かすのに必要なユーザーを作成します。Xorg パッケージが 1.16-1 にアップデートされた時に Arch の開発者が削除した、レガシーな systemd サービスと post install スクリプトの代わりになるものです ([https://projects.archlinux.org/svntogit/community.git/commit/trunk?h=packages/xbmc&id=9763c6d32678f3a3f45c195bfae92eee209d504f このコミット] を参照)。機能的には、違いはありません。
  +
  +
{{ic|kodi.service}} を起動して、ブート時に起動するように[[有効化]]してください。
  +
  +
==== Xsession と LightDM ====
  +
{{Note|以下の設定は、システム上に kodi ユーザーを既に作成していることを前提としています。}}
  +
  +
LightDM で自動ログインを使用する方法は [[LightDM#自動ログインを有効にする]] を見て下さい。''Kodi'' には [[xsession]] として {{ic|kodi.desktop}} が含まれています。
  +
  +
{{hc|/etc/lightdm/lightdm.conf|2=
  +
[LightDM]
  +
minimum-vt=1
  +
run-directory=/run/lightdm
  +
  +
[SeatDefaults]
  +
session-wrapper=/etc/lightdm/Xsession
  +
pam-service=lightdm-autologin
  +
autologin-user=kodi
  +
autologin-user-timeout=0
  +
user-session=kodi
  +
}}
  +
  +
==== ソケットアクティベーション ====
  +
  +
ソケットアクティベーションを使うことで、ユーザーがリモートコントロールアプリを起動したり、Kodi の html コントロールポートに接続したときに、Kodi を起動するように設定することができます。{{ic|systemctl start kodi@user.socket}} でアクティベーションを起動してください (''user'' は Kodi を起動するユーザーに置き換えて下さい)。セットアップ次第では、''kodi@.socket'' のポートは変える必要があります。
  +
  +
{{hc|/etc/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|/etc/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>}}
  +
  +
=== 複数のノード間でデータベースを共有する ===
  +
一つのメディアライブラリ (動画や音楽) を共有するように Kodi を設定するのは簡単です。共有することの利点として、一つの場所にキーメタデータが保存されることで、ネットワーク上の全てのノードでメタデータを共有・更新することができます。例えば、この設定によってユーザーは以下のことが可能になります:
  +
* 個室で映画を視聴するのを止めて、リビングに移動して自動的に映画の続きを見る。
  +
* メディアを既に視聴したかどうかという情報を全てのノードで共有する。
  +
* 管理するべきライブラリはたった一つだけですむので設定が楽になる。
  +
  +
セットアップをするために必要な重要事項:
  +
* ネットワークを介して見れるメディア (Kodi が読み込めるプロトコル、NFS や Samba などを使う)。
  +
* MySQL サーバー。
  +
  +
{{Note|以下のガイドはあくまで一つの設定例であり、何かを制限したりはしません。参考として読んでください。主要な設定手順は示しますが、細かい解説まではしません。}}
  +
このガイドでは例として以下の仮定を使います。あなたのセットアップに合わせて置き換えるようにしてください:
  +
* メディアは次のマウントポイント上に存在している状態です: {{ic|/mnt/tv-shows}} {{ic|/mnt/movies}} {{ic|/mnt/music}}。
  +
* 全てのノードのネットワークアドレスは 192.168.0.* のサブネットに収まっているとします。
  +
* NFSv4 エクスポートを使用することとします。
  +
* NFS エクスポートと MySQL データベースを動かすマシンの IP アドレスは 192.168.0.105 です。
  +
* Kodi を使用する個々のコンピュータはノードと表記します。
  +
* Kodi を実行する Linux ユーザーは全てのノードで 'kodi' です。
  +
  +
詳しい情報は、[http://kodi.wiki/index.php?title=HOW-TO:Share_libraries_using_MySQL/Setting_up_MySQL#tab=Arch_Linux 公式の Kodi wiki] を参照してください。
  +
  +
==== NFS サーバーのセットアップ ====
  +
このセクションでは NFS エクスポート (NFSv4) を使用する例を挙げます。ただし、上で説明したように、Kodi は様々なプロトコルを読み込むことが可能です。
  +
{{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.}}
  +
  +
NFS サーバーは {{Pkg|nfs-utils}} によってインストールすることができ、コンテンツを供給するコンピュータにインストールするだけで十分です。
  +
  +
共有のセットアップ:
  +
# 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
  +
  +
{{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
  +
  +
{{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|この例では読み取り専用のエクスポートを設定しています。他のオプションや設定については {{ic|man exports}} を見て下さい。}}
  +
  +
{{ic|/etc/exports}} に変更を加えた時は、エクスポートを更新するようにします:
  +
# exportfs -rav
  +
  +
{{ic|nfs-common.service}} を[[起動]]して、ブート時に動作するように[[有効化]]してください。
  +
  +
任意で、次のコマンドを使って確認をします:
  +
# 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|コンピュータがファイアウォールを使っている場合は、接続がブロックされないことを確認してください。この記事ではファイアウォールの設定については扱いません。}}
  +
  +
==== MySQL サーバーのインストールとセットアップ ====
  +
ライブラリを動かすコンピュータは24時間ずっと動作している必要があり、通常は、メディアを保存するコンピュータと同じコンピュータを使います。
  +
{{Note|以下の例では Arch Linux を使っていますが、MySQL サーバーが動作するなら、どの Linux や BSD でもかまいません。}}
  +
  +
MySQL サーバーは {{Pkg|mariadb}} でインストールすることができ、全てのノードがアクセスするコンピュータにインストールするだけで十分です。
  +
  +
{{ic|mysqld.service}} を[[起動]]して、ブート時に動作するように[[有効化]]してください。
  +
  +
初期設定:
  +
# 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' IDENTIFIED BY 'kodi';
  +
MariaDB [(none)]> GRANT ALL ON *.* TO 'kodi';
  +
MariaDB [(none)]> \q
  +
  +
MySQL サーバーに他の設定をする必要はありません。
  +
{{Note|コンピュータがファイアウォールを使っている場合は、接続がブロックされないことを確認してください。この記事ではファイアウォールの設定については扱いません。}}
  +
  +
==== MySQL ライブラリと NFS エクスポートを使うように Kodi を設定 ====
  +
この例では NFS の共有を使用するので、共有にアクセスするための Kodi の任意の依存パッケージが必要になります。全ての Kodi ノードに {{Pkg|libnfs}} をインストールするようにしてください。
  +
  +
===== 共通の MySQL データベースを使うように Kodi を設定 =====
  +
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}}}}
  +
  +
===== ネットワーク共有の設定 =====
  +
{{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.
  +
  +
==== ネットワーク上の他のノードに設定をコピー ====
  +
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.}}
  +
  +
=== リモートコントロールの使用 ===
  +
  +
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>
  +
<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 {{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://kodi.wiki/index.php?title=Keymap.xml keymap.xml].
  +
  +
* '''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.
  +
  +
* 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.
  +
  +
==== Lirc と Systemd で MCE リモート ====
  +
  +
Install {{Pkg|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.
  +
  +
{{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'"}}
  +
  +
Finally, enable and start the lirc service. As of lirc 0.9.1 the appropriate service is lircd.socket, not lircd.service:
  +
  +
# systemctl enable lircd.socket
  +
# systemctl start lircd.socket
  +
  +
This should give a fully working mce remote.
  +
  +
==== HDMI-CEC と Pulse Eight USB-CEC ====
  +
  +
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.
  +
  +
Install {{ic|libcec}}.
  +
  +
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
  +
  +
# 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 {{ic|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 ==
  +
=== 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='
  +
  +
=== フルスクリーンモードで Kodi が複数のディスプレイにまたがってしまう ===
  +
  +
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]]:
  +
  +
SDL_VIDEO_FULLSCREEN_HEAD=0
  +
  +
{{Note|Mouse cursor will be held inside screen with Kodi.}}
  +
  +
=== Intel HD Graphics で動画にちらつきが発生する ===
  +
Users observing tearing when watching a movie try this:
  +
https://bbs.archlinux.org/viewtopic.php?id=176651
  +
  +
=== CD/DVD ドライブの速度のスローダウン ===
  +
  +
The {{ic|eject}} program from the {{ic|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:
  +
  +
{{hc|/etc/udev/rules.d/dvd-speed.rules|2=
  +
KERNEL=="sr0", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1", RUN+="/usr/bin/eject -x 2 /dev/sr0"
  +
}}
  +
  +
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
  +
# udevadm control --reload
  +
  +
=== ウェブサーバーにポート 80 を使う ===
  +
  +
Kodi にはウェブインターフェイスを使って操作をすることができるウェブサービスが付いています。デフォルトでは、このサービスはポート {{ic|8080}} を使います。{{ic|80}} を使うには root 権限が必要なためです。以下を実行することで数字の低いポート番号を使えるようにできます:
  +
# setcap 'cap_net_bind_service=+ep' /usr/lib/kodi/kodi.bin
  +
  +
{{ic|kodi.service}} を[[再起動]]して設定メニューでポートを {{ic|80}} に設定してください (''Services->Webserver->Port'')。
  +
  +
=== ALSA を使う ===
  +
  +
[[PulseAudio]] が正しく動作しない場合、{{ic|1=AE_SINK=ALSA}} 環境変数を使って Kodi を起動することで ALSA を直接使用するようにしてみてください。
  +
  +
=== ソフト字幕が表示されない ===
  +
  +
字幕を抽出するのには {{Pkg|ffmpeg}} パッケージが使われています。
  +
  +
== 参照 ==
  +
  +
* [http://kodi.wiki/index.php?title=Main_Page Kodi Wiki] - Excellent resource with much information about Arch Linux specifically

2015年2月11日 (水) 15:34時点における版

ノート: バージョン14のリリースから XBMC は Kodi に名前が変更されました。

Kodi はフリーで、オープンソース (GPL) のマルチメディアプレイヤーであり、もともとは初代の XBox 上で動作していました (最近の Xbox 360 ではありません)。現在では Linux, Mac OS X, Windows, Android, iOS などのデバイスで動作します。Kodi を使うことでよく使われているフォーマットの動画、音声、画像や、あまり有名でないフォーマットを再生・表示することができます:

  • 動画 - DVD-Video, VCD/SVCD, MPEG-1/2/4, DivX, XviD, Matroska。
  • 音声 - MP3, AAC。
  • 画像 - JPG, GIF, PNG。

以上のフォーマットはどれも CD/DVD から直接再生したり、ハードドライブから再生することが可能です。また、Kodi はローカルネットワーク (LAN) 上のコンピュータからマルチメディアを再生したり、インターネットから直接メディアストリームを再生することもできます。詳細な情報は、Kodi FAQ を見て下さい。

バージョン12から、チューナーとバックエンドサーバー、PVR プラグインを使って TV 放送を再生したり録画することもできるようになりました。TV 放送の表示方法に関する情報は Kodi wiki にあります。

インストール

公式リポジトリから kodi パッケージをインストールしてください。あなたの使い道にあわせて、pacman によって表示される任意の依存パッケージもインストールするようにします。

設定

ブート時や必要なときに自動で起動

kodi パッケージにはスタンドアロンのラッパースクリプト /usr/bin/kodi-standalone が入っており、完全な DE がなくとも最低限のシステムでアプリケーションを実行できるようになっています。以下で記述しているように、ラッパースクリプトを有効にする方法は複数存在します。

警告: この機能を有効にするときは以下の方法のどれか一つだけを選んでください。

Kodi-standalone-service

AURkodi-standalone-serviceAUR パッケージは kodi.service を提供して、スタンドアロンモードで Kodi を動かすのに必要なユーザーを作成します。Xorg パッケージが 1.16-1 にアップデートされた時に Arch の開発者が削除した、レガシーな systemd サービスと post install スクリプトの代わりになるものです (このコミット を参照)。機能的には、違いはありません。

kodi.service を起動して、ブート時に起動するように有効化してください。

Xsession と LightDM

ノート: 以下の設定は、システム上に kodi ユーザーを既に作成していることを前提としています。

LightDM で自動ログインを使用する方法は LightDM#自動ログインを有効にする を見て下さい。Kodi には xsession として kodi.desktop が含まれています。

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

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

ソケットアクティベーション

ソケットアクティベーションを使うことで、ユーザーがリモートコントロールアプリを起動したり、Kodi の html コントロールポートに接続したときに、Kodi を起動するように設定することができます。systemctl start kodi@user.socket でアクティベーションを起動してください (user は Kodi を起動するユーザーに置き換えて下さい)。セットアップ次第では、kodi@.socket のポートは変える必要があります。

/etc/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
/etc/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

複数のノード間でデータベースを共有する

一つのメディアライブラリ (動画や音楽) を共有するように Kodi を設定するのは簡単です。共有することの利点として、一つの場所にキーメタデータが保存されることで、ネットワーク上の全てのノードでメタデータを共有・更新することができます。例えば、この設定によってユーザーは以下のことが可能になります:

  • 個室で映画を視聴するのを止めて、リビングに移動して自動的に映画の続きを見る。
  • メディアを既に視聴したかどうかという情報を全てのノードで共有する。
  • 管理するべきライブラリはたった一つだけですむので設定が楽になる。

セットアップをするために必要な重要事項:

  • ネットワークを介して見れるメディア (Kodi が読み込めるプロトコル、NFS や Samba などを使う)。
  • MySQL サーバー。
ノート: 以下のガイドはあくまで一つの設定例であり、何かを制限したりはしません。参考として読んでください。主要な設定手順は示しますが、細かい解説まではしません。

このガイドでは例として以下の仮定を使います。あなたのセットアップに合わせて置き換えるようにしてください:

  • メディアは次のマウントポイント上に存在している状態です: /mnt/tv-shows /mnt/movies /mnt/music
  • 全てのノードのネットワークアドレスは 192.168.0.* のサブネットに収まっているとします。
  • NFSv4 エクスポートを使用することとします。
  • NFS エクスポートと MySQL データベースを動かすマシンの IP アドレスは 192.168.0.105 です。
  • Kodi を使用する個々のコンピュータはノードと表記します。
  • Kodi を実行する Linux ユーザーは全てのノードで 'kodi' です。

詳しい情報は、公式の Kodi wiki を参照してください。

NFS サーバーのセットアップ

このセクションでは NFS エクスポート (NFSv4) を使用する例を挙げます。ただし、上で説明したように、Kodi は様々なプロトコルを読み込むことが可能です。

ノート: 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.

NFS サーバーは nfs-utils によってインストールすることができ、コンテンツを供給するコンピュータにインストールするだけで十分です。

共有のセットアップ:

# 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

/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

/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)
ヒント: この例では読み取り専用のエクスポートを設定しています。他のオプションや設定については man exports を見て下さい。

/etc/exports に変更を加えた時は、エクスポートを更新するようにします:

# exportfs -rav

nfs-common.service起動して、ブート時に動作するように有効化してください。

任意で、次のコマンドを使って確認をします:

# 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
ノート: コンピュータがファイアウォールを使っている場合は、接続がブロックされないことを確認してください。この記事ではファイアウォールの設定については扱いません。

MySQL サーバーのインストールとセットアップ

ライブラリを動かすコンピュータは24時間ずっと動作している必要があり、通常は、メディアを保存するコンピュータと同じコンピュータを使います。

ノート: 以下の例では Arch Linux を使っていますが、MySQL サーバーが動作するなら、どの Linux や BSD でもかまいません。

MySQL サーバーは mariadb でインストールすることができ、全てのノードがアクセスするコンピュータにインストールするだけで十分です。

mysqld.service起動して、ブート時に動作するように有効化してください。

初期設定:

# 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' IDENTIFIED BY 'kodi';
MariaDB [(none)]> GRANT ALL ON *.* TO 'kodi';
MariaDB [(none)]> \q

MySQL サーバーに他の設定をする必要はありません。

ノート: コンピュータがファイアウォールを使っている場合は、接続がブロックされないことを確認してください。この記事ではファイアウォールの設定については扱いません。

MySQL ライブラリと NFS エクスポートを使うように Kodi を設定

この例では NFS の共有を使用するので、共有にアクセスするための Kodi の任意の依存パッケージが必要になります。全ての Kodi ノードに libnfs をインストールするようにしてください。

共通の MySQL データベースを使うように Kodi を設定

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>
ヒント: 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
ネットワーク共有の設定
警告: 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!
ノート: 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.

ネットワーク上の他のノードに設定をコピー

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.

ノート: 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.

リモートコントロールの使用

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').

ノート: 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.

Lirc と Systemd で MCE リモート

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 the lirc service. As of lirc 0.9.1 the appropriate service is lircd.socket, not lircd.service:

# systemctl enable lircd.socket
# systemctl start lircd.socket

This should give a fully working mce remote.

HDMI-CEC と 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.

ノート: 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

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='

フルスクリーンモードで Kodi が複数のディスプレイにまたがってしまう

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:

SDL_VIDEO_FULLSCREEN_HEAD=0
ノート: Mouse cursor will be held inside screen with Kodi.

Intel HD Graphics で動画にちらつきが発生する

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

CD/DVD ドライブの速度のスローダウン

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

ウェブサーバーにポート 80 を使う

Kodi にはウェブインターフェイスを使って操作をすることができるウェブサービスが付いています。デフォルトでは、このサービスはポート 8080 を使います。80 を使うには root 権限が必要なためです。以下を実行することで数字の低いポート番号を使えるようにできます:

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

kodi.service再起動して設定メニューでポートを 80 に設定してください (Services->Webserver->Port)。

ALSA を使う

PulseAudio が正しく動作しない場合、AE_SINK=ALSA 環境変数を使って Kodi を起動することで ALSA を直接使用するようにしてみてください。

ソフト字幕が表示されない

字幕を抽出するのには ffmpeg パッケージが使われています。

参照

  • Kodi Wiki - Excellent resource with much information about Arch Linux specifically