最近のスマートデバイスは語りかけるだけで、
CATT:Cast All The Things
CATTはローカル・
主に指定のYouTube動画や公開されたプレイリストを再生するためのツールとして作成されているものの、
PyPIで公開されているため、
まずはpipxでインストールする方法です。
$ sudo apt install pipx $ pipx install catt
次にpip3でインストールする方法です。
$ sudo apt install python3-pip $ pip3 install catt
pipx/~/.local/
」~/.local/
」~/.local/
」~/.local/
」~/.local/
」
まずはコマンドのヘルプを表示してみます。
$ catt --help Usage: catt [OPTIONS] COMMAND [ARGS]... Options: -d, --device NAME_OR_IP Select Chromecast device. --version Show the version and exit. -h, --help Show this message and exit. Commands: add Add a video to the queue (YouTube only). cast Send a video to a Chromecast for playing. cast_site Cast any website to a Chromecast. clear Clear the queue (YouTube only). del_alias Delete the alias name of the selected device. del_default Delete the default device. ffwd Fastforward a video by TIME duration. info Show complete information about the currently-playing video. pause Pause a video. play Resume a video after it has been paused. play_toggle Toggle between playing and paused state. remove Remove a video from the queue (YouTube only). restore Return Chromecast to saved state. rewind Rewind a video by TIME duration. save Save the current state of the Chromecast for later use. scan Scan the local network and show all Chromecasts and their IPs. seek Seek the video to TIME position. set_alias Set an alias name for the selected device. set_default Set the selected device as default. skip Skip to end of content. status Show some information about the currently-playing video. stop Stop playing. volume Set the volume to LVL [0-100]. volumedown Turn down volume by a DELTA increment. volumeup Turn up volume by a DELTA increment. write_config DEPRECATED: Please use "set_default".
いろいろなコマンドが存在するものの、
- コンテンツおよびウェブページのキャスト
-
cast/
cast_ site - Castデバイスの管理
-
scan/
save/ restore - Castデバイスのラベルと優先順位
-
set_
alias/ set_ default/ del_ alias/ del_ default -
再生・
停止コントロール -
ffwd/
rewind/ pause/ play/ play_ toggle/ seek/ skip/ stop - 音量コントロール
-
volume/
volumedown/ volumeup - 再生中の状態表示
-
info/
status - YouTube用の再生キューの操作
-
add/
clear/ remove
コマンド名だけで何をするかはイメージできると思います。オプション等の詳細が知りたい場合はcatt COMMAND -h
」
さて、
$ catt scan Scanning Chromecasts... 192.168.0.10 - キッチン - Google Inc. Google Nest Hub 192.168.0.11 - テレビ - Google Inc. Chromecast Ultra
上記の例だと
もし英語名が良ければ、cast -s 名前 set_
」~/.config/
」
試しにYouTubeの適当な動画を再生してみましょう。Castデバイスは家族がいるスペースにあることも多いのと、
ここでは第500回の
$ catt -d テレビ cast https://www.youtube.com/watch?v=kTh-_1mNhPs Casting remote file https://www.youtube.com/watch?v=kTh-_1mNhPs... Playing "PCの電源に車用ヘッドライトバルブをつないだら危険すぎた" on "テレビ"...
無事に再生できたでしょうか。音量を調整したい場合は、volumedown/
で上下させるか、volume
で0から100の間の数字を指定します。
$ catt -d テレビ volume 50
同様に早送り・ffwd/
です。一時停止・pause/
となります。また再生を終了したい場合は、stop
を呼び出してください。
$ catt -d テレビ stop
cast
の代わりにcast_
でウェブページを表示できます。とはいえスクロールなどはCastデバイス次第な部分もあるため、
ローカルのファイルを再生する
CATTを用いてキャストする際の最大の利点が、~/ミュージック/
」
$ catt -d キッチン cast ~/ミュージック/music.m4a Casting local file ~/ミュージック/music.m4a... Playing "Music" on "キッチン"... Serving local file(s). 192.168.0.10 - - [22/May/2021 23:23:33] "GET /?loaded_from_catt HTTP/1.1" 206 - audio/mp4 - 12.60 MB
Castデバイスによってサポートしているメディアフォーマットは異なるので注意してください。たとえばMPEG-2 Videoは現時点でどのデバイスもサポートしていないため、
ローカルファイルの再生の際はYouTubeと異なり、
再生キューやプレイリストといった機能もありません。ただしCLIなのでちょっとしたスクリプトでプレイリスト相当の操作ができます。たとえば単純な例だと、
$ find . -name '*.m4a' -exec catt -d キッチン cast {} \;
Ubuntuの場合、
たとえばNextcloudにコンテンツを保存している場合、
WebDAV用のアドレスは、
ファイルブラウザーの場合は、
マウントがうまくいけば、
$ ls $XDG_RUNTIME_DIR/gvfs/ 'dav:host=(サーバーアドレス),ssl=true,prefix=%2Fremote.php%2Fdav%2Ffiles%2F(ユーザー名)'
上記のdev:
」
DLNA経由のファイルを再生する
ネットワーク上にDLNAサーバーが存在する場合、
結局のところUPnPをサポートするライブラリを利用して、
依存関係が少ない方法だと、
$ sudo apt install socat $ wget https://raw.githubusercontent.com/javier-lopez/learn/master/sh/tools/simple-dlna-browser $ chmod +x simple-dlna-browser
まずはDLNAサーバーをリストアップします。
$ ./simple-dlna-browser -L http://192.168.0.27:8200/rootDesc.xml (CuBox)
今回応答したのは、urn:schemas-upnp-org:device:MediaServer:1
」
このツールの便利なところは、
$ ./simple-dlna-browser -s 192.168.0.27 -v ファイル http://192.168.0.27:8200/MediaItems/345.mp4 - ファイル1 http://192.168.0.27:8200/MediaItems/346.mp4 - ファイル2 http://192.168.0.27:8200/MediaItems/347.mp4 - ファイル3 http://192.168.0.27:8200/MediaItems/348.mp4 - ファイル4
「-v
」
あとはこのURLをcattコマンドに渡すだけです。
$ catt -d テレビ cast http://192.168.0.27:8200/MediaItems/348.mp4 Casting remote file http://192.168.0.27:8200/MediaItems/348.mp4... Playing "348" on "テレビ"...
これでDLNA上のコンテンツもCLIからCastデバイスにキャストできました。
在宅勤務においては、