epgstation とりあえず版
https://github.com/l3tnun/EPGStation
https://github.com/Chinachu/Mirakurun
Chianchu の調子が悪くなったのでEPGStation に乗り換えてみました。
EPGStation とMirakurun をWSL 上に構築しました。

環境

  • ソフトウェア構成

    • Windows 10 Insider Preview build 20161
      • WSL (Ubuntu 20.04 LTS)
        • node v14.4.0
          • EPGStation 1.7.0
          • Mirakurun 3.2.0
        • npm 6.14.5
        • pm2 4.4.0
        • ffmpeg 4.2.2
        • python 2.7.18rc1
        • gcc 9.3.0
      • BonRecTest 1.0.0
      • Kodi 18.6
        • PVR IPTV Simple Client 3.9.8
  • ディレクトリ配置

Mirakurun の構築 (WSL)

  1. Mirakurun のインストール
$ sudo npm install mirakurun@latest -g  --unsafe --production
$ sudo mirakurun init
  1. チューナの設定
$ sudo mirakurun config tuners
- name: PT3-T1
types:
- GR
command: /mnt/c/Windows/System32/lxss/tools/init /mnt/c/tools/PT3/BonRecTest.exe --decoder B25Decoder.dll --driver BonDriver_PT3-T0.dll --output - --channel <channel>
decoder: ~
isDisabled: false

- name: PT3-T2
types:
- GR
command: /mnt/c/Windows/System32/lxss/tools/init /mnt/c/tools/PT3/BonRecTest.exe --decoder B25Decoder.dll --driver BonDriver_PT3-T1.dll --output - --channel <channel>
decoder: ~
isDisabled: false

💡 WSL からWindows のコマンドを/mnt/c/Windows/System32/lxss/tools/initで起動
3. チャンネルの設定

$ sudo mirakurun config channels

- name: TOKYO MX
type: GR
channel: '3'

- name: フジテレビ
type: GR
channel: '8'

- name: TBS
type: GR
channel: '9

- name: テレビ東京
type: GR
channel: '10'

- name: テレビ朝日
type: GR
channel: '11'

- name: 日テレ
type: GR
channel: '12'

- name: NHKEテレ・東京
type: GR
channel: '13'

- name: NHK総合・東京
type: GR
channel: '14'

4. ログローテーションの設定
$ sudo pm2 install pm2-logrotate

/etc/logrotate.d/mirakurun
/usr/local/var/log/mirakurun.stdout.log
/usr/local/var/log/mirakurun.stderr.log
/{
daily
compress
rotate 7
missingok
notifempty
}

EPGStation の構築 (WSL)

  1. 前提パッケージの確認
$ node --version
$ ffmpeg -version
$ which ffmpeg
$ python --version
$ gcc --version
  1. EPGStation のインストール
$ git clone https://github.com/l3tnun/EPGStation.git
$ cd EPGStation
$ npm install --no-save
$ npm run build
  1. EPGStation の設定ファイルの作成
$ cp config/config.sample.json config/config.json
$ cp config/operatorLogConfig.sample.json config/operatorLogConfig.json
$ cp config/serviceLogConfig.sample.json config/serviceLogConfig.json
  1. EPGStation の設定
    💡 https://github.com/l3tnun/EPGStation/blob/master/doc/conf-manual.md
$HOME/EPGStation/config/config.json
"ffmpeg": "/usr/bin/ffmpeg",
"ffprobe": "/usr/bin/ffprobe",
$HOME/EPGStation/config/config.json
"recorded": "/mnt/j/home/epgstation",
"recordedTemp": "/mnt/j/home/epgstation/temp",
  1. PM2 ecosystem.config.js ファイルの作成
$HOME/EPGStation/ecosystem.config.js
module.exports = {
apps : [{
name: "epgstation",
script: 'dist/server/index.js',
cwd: "/home/ubuntu/EPGStation"
}]
};

ポートフォワード設定の追加 (WSL)

  1. 8888 (EPGStation), 40772 (Mirakurun) をWSL に転送
$HOME/bin/wsl-portforward.sh
#!/bin/bash

IP=$(ip -f inet -o addr show eth0 | cut -d\ -f 7 | cut -d/ -f 1)

for PORT in 22 4000 8000 8888 9000 40772; do
/mnt/c/Windows/system32/netsh.exe interface portproxy delete v4tov4 listenport=$PORT
/mnt/c/Windows/system32/netsh.exe interface portproxy add v4tov4 listenport=$PORT connectaddress=$IP
done

起動処理 (Windows 10)

  1. 非表示で実行するためのランチャの作成
C:\tools\launcher\silentLauncher.vbs
ReDim arr(WScript.Arguments.Count-1) 
For i = 0 To WScript.Arguments.Count-1
arr(i) = WScript.Arguments(i)
Next

CreateObject("WScript.Shell").Run Join(arr) , 0
  1. タスクスケジューラ(taskschd.msc)で自動起動するように設定
cscript C:\tools\launcher\silentLauncher.vbs wsl -u root bash /home/ubuntu/bin/wsl-portforward.sh
cscript C:\tools\launcher\silentLauncher.vbs wsl -u root mirakurun init
cscript C:\tools\launcher\silentLauncher.vbs wsl -u ubuntu pm2 start /home/ubuntu/EPGStation/ecosystem.config.js

Windows ファイアウォールの設定 (Windows 10)

  1. ポート開放
  • 8888 (EPGStation)
  • 40772 (Mirakurun) オプション

利用

  1. Mirakurun の動作確認
    http://192.168.11.2:40772
  2. EPGStation にアクセス
    http://192.168.11.2:8888
  3. ライブ視聴は「GR」→ 局名 →「視聴」を選択して、VLC やMX Player MX Player 等で開く

Kodi でライブ視聴

https://github.com/l3tnun/EPGStation/blob/master/doc/kodi.md

  1. アドオンをインストール
    「アドオン」→「ダウンロード」→「PVRクライアント」→「PVR IPTV Simple Client」
  2. インストールが完了したら「C」キーを押下して、コンテキストメニューから「設定」を選択
  3. 一般 / M3U プレイリストのURL
    http://host:port/api/iptv/channel.m3u8?mode=2
  4. EPG 設定 / M3U プレイリストのURL
    http://host:port/api/iptv/epg.xml?days=3
  5. Kodi を再起動
  6. 「TV」メニューから視聴