v4l2loopbackモジュールで作られるビデオデバイスへの名前の付け方

v4l2loopback moduleを利用して仮想カメラなどを利用しています.

このモジュールを呼び出すときにオプションを指定して複数のデバイスにしたり,それぞれにデバイスに名前をつけたり出来ます.

If you need several independent loopback devices, you can pass the “devices” option, when loading the module; e.g.

# modprobe v4l2loopback devices=4
Will give you 4 loopback devices (e.g. /dev/video1 …​ /dev/video5)

You can also specify the device IDs manually; e.g.

# modprobe v4l2loopback video_nr=3,4,7
Will create 3 devices (/dev/video3, /dev/video4 & /dev/video7)

# modprobe v4l2loopback video_nr=3,4,7 card_label=”device number 3″,”the number four”,”the last one”
Will create 3 devices with the card names passed as the second parameter:

/dev/video3 → device number 3
/dev/video4 → the number four
/dev/video7 → the last one

お手本通りモジュールを呼び出すと,

$ sudo modprobe v4l2loopback video_nr=3,4,7 card_label="device number 3","the number four","the last
one"

想定通りに設定されました.(最後のIntegrated Cameraは内蔵カメラでこのモジュールとは無関係)

$ v4l2-ctl --list-devices
device number 3" (platform:v4l2loopback-000):
        /dev/video3

"the number four" (platform:v4l2loopback-001):
        /dev/video4

"the last one (platform:v4l2loopback-002):
        /dev/video7

Integrated Camera: Integrated C (usb-0000:00:1a.0-1.6):
        /dev/video0
        /dev/video1
        /dev/media0

しかしこの設定を永続化しようと,
/etc/modprobe.d/v4l2loopback.conf
というファイルを用意してこの設定を書いて呼び出すとおかしなことになります.

$ sudo rmmod v4l2loopback (1)
$ echo 'options v4l2loopback video_nr=3,4,7 card_label="device number 3","the number four","the last one"' | sudo tee /etc/modprobe.d/v4l2loopback.conf (2)
options v4l2loopback video_nr=3,4,7 card_label="device number 3","the number four","the last one"
$ sudo modprobe -v v4l2loopback (3)
insmod /lib/modules/5.10.0-1-amd64/updates/dkms/v4l2loopback.ko video_nr=3,4,7 card_label="device number 3","the number four","the last one"
$ v4l2-ctl --list-devices | grep v4l2loopback -A1 (4)
device number 3" (platform:v4l2loopback-000):
        /dev/video3
--
"the number four" (platform:v4l2loopback-001):
        /dev/video4
--
"the last one (platform:v4l2loopback-002):
        /dev/video7
  1. モジュールのアンロード
  2. 設定ファイルへ書き込み
  3. モジュールの再読込
  4. デバイス名の確認

ダブルクオーテーションの扱いが変わってしまうようです.更に名前自体にダブルクオーテーションが含まれてしまいます.

とりあえず全体を1セットのダブルクオーテーションで囲むと大丈夫なようです.

$ echo 'options v4l2loopback video_nr=3,4,7 card_label="device number 3,the number four,the last one"' | sudo tee /etc/modprobe.d/v4l2loopback.conf
options v4l2loopback video_nr=3,4,7 card_label="device number 3,the number four,the last one"
$ sudo modprobe -v v4l2loopback
insmod /lib/modules/5.10.0-1-amd64/updates/dkms/v4l2loopback.ko video_nr=3,4,7 card_label="device number 3,the number four,the last one"
$ v4l2-ctl --list-devices | grep v4l2loopback -A1
device number 3 (platform:v4l2loopback-000):
        /dev/video3
--
the number four (platform:v4l2loopback-001):
        /dev/video4
--
the last one (platform:v4l2loopback-002):
        /dev/video7

ちなみにダブルクオーテーションなしだとこうなりました.

$ sudo modprobe -v v4l2loopback
insmod /lib/modules/5.10.0-1-amd64/updates/dkms/v4l2loopback.ko video_nr=3,4,7 card_label=device number 3,the number four,the last one
$ v4l2-ctl --list-devices | grep v4l2loopback -A1
device (platform:v4l2loopback-000):
        /dev/video3
--
Dummy video device (0x0001) (platform:v4l2loopback-001):
        /dev/video4
--
Dummy video device (0x0002) (platform:v4l2loopback-002):
        /dev/video7

最近リリースされた OBS Studio 26.1でLinux版, macOS版にも仮想カメラ機能が入りました.
これも v4l2loopback を利用しているのですが,ダブルクオーテーションが含まれる場合うまく動かないようです.

環境
$ dpkg-query -W v4l2loopback-* v4l-utils
v4l-utils       1.20.0-2
v4l2loopback-dkms       0.12.5-1
v4l2loopback-modules
v4l2loopback-utils      0.12.5-1
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -mv
#1 SMP Debian 5.10.4-1 (2020-12-31) x86_64

Byobu tmuxでファンクションキーを無効にする

アドホックに切り替える

Ctrl+b shift + F12 でトルグ

設定ファイルに設定する

~/.byobu/keybindings.tmux の1行目に
source /usr/share/byobu/keybindings/f-keys.tmux.disable を追記.

Byobu tmuxを起動し直すか,Ctrl+b : :source-file ~/.byobu/keybindings.tmux で反映する.

Byobu GNU screenの場合はこちら

環境
$ dpkg-query -W byobu tmux
byobu   5.133-1
tmux    3.1b-1
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

SteamのOSごとのアプリケーション数を確認してみる

あるPodcastでSteamのLinuxアプリは1割位ではという話があったのですが,そんなに少なくないだろうでもどのくらいだろう?と実際のところ知らなかったので確認してみました.

確認にはSteam検索の検索結果を使いました.
https://store.steampowered.com/search/

こんな感じのscriptを用意して,

steamcount.bash
#!/bin/bash

# Steam検索
# https://store.steampowered.com/search/
# ignore_preferences=1 個人設定に基づいたタイトルの除外の無効化
# https://store.steampowered.com/search/?ignore_preferences=1
# Windowsの検索
# https://store.steampowered.com/search/?ignore_preferences=1&os=win
# Mac OS Xの検索
# https://store.steampowered.com/search/?ignore_preferences=1&os=mac
# SteamOS + Linuxの検索
# https://store.steampowered.com/search/?ignore_preferences=1&os=linux

SERCH="https://store.steampowered.com/search/?ignore_preferences=1&os="
OSTYPE=("all" "win" "mac" "linux")
MATCH="results match your search."
declare -A COUNT

for OS in "${OSTYPE[@]}"
do
  COUNT[$OS]=$(LC_ALL=en_US.UTF-8 w3m -dump "$SERCH$OS" | grep "$MATCH" | cut -f1 -d' ' | tr -d ,)
  echo $OS,${COUNT[$OS]},$(awk "BEGIN { print ${COUNT[$OS]}/${COUNT[all]}*100 }")%
done

実行します.

$ bash ~/src/steamcount.bash
all,79831,100%
win,79654,99.7783%
mac,25443,31.8711%
linux,15673,19.6327%

Linuxの検索結果は15673本で,全体の19.6%でした.もっと多いと思いましたが案外少ないですね.
恐らく検索する範囲を近年にしたり,Windows用のアプリケーションをLinux環境で動かすProtonに対応したアプリケーションも入れるともっと多くなるのではないかと思うのですが,Steam検索ではその検索方法がわかりませんでした.

ちなみに以下は2015年3月の記事ですが,この記事によると2013年には50本,2014年に500本,(恐らく)2015年3月には1004本.このときに比べると現在の15673本というのはすごく増えている感じです.

SteamがこのLinuxベースのゲームOSをローンチしたのは2013年で、そのときはわずか50のゲームがあり、1年後には500タイトルに達した。今現在、ゲーム数は1004で、DLCなどのダウンロードするコンテンツや拡張パックも含めると1835になる。

新しいゲームならLinux対応が多いと思いリリースが新しい順にソートしてみるとWindowsのみ対応のアプリが多いですね.今見ると最新から14本はWindowsのみ対応.15本目にやっとWindows/Mac/Linuxに対応したゲームがでてきました.

Windows専用アプリケーションでもLinux版SteamのProtonで動かせたり,Protonで動かないのもでも別途Wine経由で動かせるものもあります(Lutrisを使うと便利).

関連記事

Speaker Deckのスライドが全て非公開になって困る

Speaker Deckというスライド共有サービスがあります.日本ではSlideShareの次くらいによく使われていそうなサービスです.ここでトラブルがあったので健忘録としてメモしておきます.

このサービスにスライドを登録しようとアップロードしたところ変換に失敗してしまいます.スライドのデータが悪いのかな?と他のものも試すとやはり駄目です.
よく見ると5月以降に登録したスライドはアクセスが0です.なにかおかしい.

ログアウトした状態で見るとスライドが1つも見えなくなってしまっています.

speakerdeck 20200625 07:06:04 766282.resized

既存のスライドを公開(publish)し直しても公開されません.

全てのスライドが非公開になっている,ログインしたら見えるけど公開できない,新しいスライドの登録は失敗する……という状態です.

DMCAとか著作権違反とかが報告されてロックされていそうな感じがします(心当たりはないけど他のサービスもそれでBANされた前科あり).メールを探しますが特にそれらしいものは見当たりません.

ちょっと自分ではどうしようもなさそうだとSpeaker Deckの「Feedback」リンクからメールで問い合わせてみました.しかし反応がありません.
ダメ元でTwitterのSpeaker Deckアカウントである@speakerdeckにmentionを投げてみると数時間で復旧していました.

スライドはちゃんと公開され,新しいスライドのアップロードも出来ました.ということでよくわかりませんがシステムの不具合だったのかな?

やっぱり人任せにするのは怖いですね.自分でコントロールできるところでもまとめておこうと思います.

Lutrisを使ってLinuxでもEpic Gamesで遊ぶ

Epic Games というゲームプラットホームがあります.定期的にゲームを無料配布してくれるのでたまに貰っています.

しかしこのプラットホームは Stream や itch などと違い PC/Mac のみの対応で Linux には対応していません.

Epic Games Storeはどのプラットフォームに対応していますか?
Epic Games Storeは、現在PCとMacに対応しています。各タイトルのプラットフォームとの互換性については、製品ページの「ゲームについて」で確認することができます。

無料で貰っても遊ばないと意味がないです.
そういえば Lutris 経由で動かないかな?と思いつきました.Lutris はLinux 環境で各種プラットホームのゲーム環境を管理できて,複数のWine 環境を簡単に導入設定できたりして便利です.ここで貰ったゲームが出てきたらお手軽に遊べそうです.

Lutris についての詳細は以下のスライドもどうぞ.

ゲームの前に Lutris で Epic Games で検索すると Epic Games が出てきました.「Install」ボタンを押してウィザードに従うだけで簡単に導入できました.

lutris epic 20200606 03:06:59 18609

後は Epic Games でゲームをインストールしてみると起動しました :)

lutris epic 20200606 08:06:45 150593

lutris epic 20200606 08:06:24 148344
lutris epic 20200606 08:06:15 147780

思ったより手軽に遊べそうです.
しかし暖かくなって排熱が追いつかない感じでちょっと辛い今日この頃です.

//

環境
$ apt show lutris
Package: lutris
Version: 0.5.6
Priority: optional
Section: games
Maintainer: Mathieu Comandon <strider@strycore.com>
Installed-Size: 4,035 kB
Depends: python3-evdev, python3-gi, python3-requests, python3-yaml, python3:any, python3-pil, python3-setproctitle, python3-distro, gir1.2-gtk-3.0, gir1.2-gnomedesktop-3.0, gir1
.2-webkit2-4.0, gir1.2-notify-0.7, psmisc, cabextract, unzip, p7zip, curl, fluid-soundfont-gs, x11-xserver-utils, mesa-utils
Recommends: gvfs-backends, libwine-development, winetricks, libc6-i386, lib32gcc1
Suggests: gamemode
Homepage: https://lutris.net
Download-Size: 1,690 kB
APT-Manual-Installed: yes
APT-Sources: http://download.opensuse.org/repositories/home:/strycore/Debian_Unstable  Packages
Description: open source gaming platform
 Lutris goal is to make gaming on Linux as easy as possible by taking care of
 installing and setting up the game for the user. The only thing you have to do
 is play the game. It aims to support every game that is playable on Linux.

$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

Devuan Ascii から Beowulf にアップグレード

Devuan3

祝Devuan Beowulf 3.0.0 released.

ということで,Debian BusterベースのDevuan Beowulf がリリースされました.
Devuan はDebian ベースの脱Systemd なディストリビューションです.Debianでも今の所Systemd を避けることは出来ると思いますが既定値はSystemd です.

手元のi686マシンにDevuan 1 JessieからDevuan 2 Ascii にしたマシンがあるのでこれをBeowulf にアップグレードしてみました.
アップグレードにはDebianの以下の文章を参考にしました.以下はi386版の文章なので自分のArchtecture の文章を見るといいと思います.

先ずはパッケージを最新にします.
こんな感じで apt update で最新になったのを確認します. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

$ sudo apt update
$ sudo apt upgrade

あとで何をしたのか何が起こったのか確認出来るようログを撮っておきます.もし,sshなどのリモート経由で実行するのであればGNU screen やtmux などのターミナルマルチプレクサも起動してそこで作業を行うと回線が切断されてしまっても復帰できるのでおすすめです.

$ script -t 2>~/upgrade-beowulfstep.time -a ~/upgrade-beowulfstep.script

/etc/apt/sources.list を書き換えます.
/etc/apt/sources.list.d/* もある場合はそちらも書き換えます.

$ sudo apt edit-sources

パッケージ情報を更新します.

$ sudo apt update

アップグレードに必要な容量があるか確認します.2GB程容量が増えるようです.

$ sudo apt -o APT::Get::Trivial-Only=true full-upgrade
  :
1636 upgraded, 556 newly installed, 34 to remove and 3 not upgraded.
Need to get 1,613 MB of archives.
After this operation, 2,071 MB of additional disk space will be used.
E: Trivial Only specified but this is not a trivial operation.

最小アップグレードを行います.……しばらく掛かるので何か他のことでもして待ちます.
apt-listchanges をざっくり流し見してパッケージの展開に移ります.1.8インチHDDなのでこれも時間がかかります.

$ sudo apt-get upgrade

システムのアップグレードを行います.しばらく待ちます…….しばらく待ちます…….apt-listchanges が表示されて確認後展開.いくつかの確認メッセージが出たります.
Directory not empty な警告もいくつか.設定ファイルの修正も出てきますがダウンタイムが発生してよければ後回しにしても大丈夫.例えば既存の設定を残すよう指示すると, 設定ファイル名.ucf-dist というファイルが作成されるのであとでゆっくり比較しながら設定できます.本番環境だったら前もって新環境の設定を用意しておくといいですね.

$ sudo apt full-upgrade

どうにか終わったのですが,使われていないパッケージが大量に残っているのでこれを削除します.沢山あるのでこれも時間がかかりました.

$ sudo apt autoremove

ここで再起動.アイコンや壁紙が名前変わったらしくブランクになったりしています.それを置き換えたりしてとりあえずOKそうになりました.

標準壁紙は /usr/share/images/desktop-base/ にありました.赤い.

起動時のメモリ利用量が100MB程増えているようです.100MBだとそう大きく感じませんが1.5倍と考えるとかなりの増加量.プロセスをメモリ利用順に並べてみるとデスクトップに使っているLxQt 関連が消費しているようです.しばらく使って問題なようなら別のものに変えるかもしれません.

$ lsb_release -dr
Description:    Devuan GNU/Linux 3 (beowulf)
Release:        3
$ uname -m
i686

LibreOffice Hackfest Online #2 に参加して LibreOffice をbuildした

最近毎週水曜日に開催されている「LibreOffice Hackfest Online #2」に参加してみました.
今回は#2で#0から始まったので3回目.

Jitsi Meet で集まってYoutubeLive での配信も行っていました.配信された動画はアーカイブされていて以下で公開されています.

今回はLibreOffice のビルドをする回でした.自分は確か以前LOOLを試すためにbuildして以来で2,3年ぶりかな?デスクトップ版は初めてです.
いつも使っている環境はLinuxのDebian sid amd64 環境なのでここでbuildすることに.

当日だけだとsourceをとってくるだけで終わってしまうだろうと前日までに source の clone と build-dep でbuild に必要なパッケージを導入しておきました.

$ git clone git://anongit.freedesktop.org/libreoffice/core
$ sudo apt build-dep libreoffice

そして当日は autogen.sh を実行して依存関係に失敗,以下のあたりを追加で導入しました.

$ sudo apt install git ccache junit4 gstreamer1.0-libav libkrb5-dev nasm graphviz libpython3-dev

その後,再度 autogen.sh を実行.

$ ./autogen.sh

makeを掛けるとHackfest に利用しているJitsi Meets に影響が出そうです.てことで影響が出たら中断するつもりでこんな感じで優先度を下げて実行しました.問題なさそうなのでそのまま放置しておきました.

$ time nice -n 19 make -j1

Hackfest が終わってもまだ終わる気配はなかったのでそのままおいときます.
そして翌朝やっと終了していました.

make は20:06:23〜翌日の06:29:35 まで掛かっていました.優先度を下げていたとはいえかなり時間がかかりました.
時間がかかったのはCPUの温度が上がってCPUスロットリングが効いて0.8GHzとかにクロックが落ちていたのが大きそうです.

早速実行すると起動して利用できそうです.

$ instdir/program/soffice

LibOBuild1 20200507 12:05:26 2204368

しかしUI言語がUSAしか選べません.

LibOBuild2 20200507 19:05:56 2517755

恐らく autogen.sh の実行時にオプションがなかったせいだと思います.

$ ./autogen.sh --help|grep -i with-lang -A 13
  --with-lang="es sw tu cs sk"
                          Use this option to build LibreOffice with additional
                          UI language support. English (US) is always included
                          by default. Separate multiple languages with space.
                          For all languages, use --with-lang=ALL.
  --with-locales="en es pt fr zh kr ja"
                          Use this option to limit the locale information
                          built in. Separate multiple locales with space. Very
                          experimental and might well break stuff. Just a
                          desperate measure to shrink code and data size. By
                          default all the locales available is included. This
                          option is completely unrelated to --with-lang.

                          Affects also our character encoding conversion
                          tables for encodings mainly targeted for a
                          particular locale, like EUC-CN and EUC-TW for
                          zh, ISO-2022-JP for ja.

                          Affects also our add-on break iterator data for
                          some languages.

                          For the default, all locales, don't use this switch at all.
                          Specifying just the language part of a locale means all matching
                          locales will be included.

ということで --with-lang=ALL--with-locales="en es pt fr zh kr ja" で多国言語対応と,--with-package-format='deb' でDebian package 書き出し,それに依存して --enable-epm を付けてみました.

$ ./autogen.sh --with-package-format='deb' --enable-epm --with-lang=ALL --with-locales="en es pt fr zh kr ja"

そして make

今回は結果をTwitterに投稿するようにしてみました.

$ /bin/time -o /tmp/time -f "%E 位掛かりました" nice -n 19 make -j1 && echo "SAYAKAによる自動投稿: LibreOfficeのbuildが正常に 終わった みたいです.$(echo ;cat /tmp/time)" || echo "SAYAKAによる自動投稿: LibreOfficeのbuildが失敗したみたいです($?)$(echo ;cat /tmp/time)" | sayaka --post

しかし6時間46分程してから失敗><

SAYAKAによる自動投稿: LibreOfficeのbuildが失敗したみたいです(2)
Command exited with non-zero status 2
6:46:38 位掛かりました

logを見るとtranslationsのcloneをずっとやっていて回線が不安定になったかタイムアウトかそんな感じで途中でcloneに失敗して転けていました.

Cloning into '/home/matoken/src/core/translations'...
error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.

再度実行してみると正常終了しました.

SAYAKAによる自動投稿: LibreOfficeのbuildが正常に 終わったみたいです.
6:36:46 位掛かりました

起動してみると日本語も選べます :)

$ /instdir/program/soffice

libodevalpha0

せっかくbuildできたのでこのLibreOfficeDev 7.0.0.0.alpha0+ の Impress でスライドを作ってみました.60ページほどのスライドをざっと書いてみましたが特に問題なく普通にかけてしまい拍子抜けしてしまいました.

VPSサーバでもbuild

ローカルのDebian sid amd64環境ではうまく行ったけど回線やPCの問題で時間がかかります.VPSサーバでbuildしてからバイナリパッケージをダウンロードしたほうが早いのではと試してみました.
このサーバはドイツのニュルンベルクでホストされているContabo社のVPS300です.スペック(CPU 2Core/RAM 4GB/HDD 300GB)の割のとても安い(€3.99/月)けど回線が細い感じのサーバです.

OSはDebian 10(buster) amd64を導入してあります.依存関係が少し手間取りましたが後はスムーズに&手元のPCよりずっと速く終わりました.

必要なパッケージの導入
$ sudo apt build-dep libreoffice
$ sudo apt install libperl-dev libarchive-zip-perl javacc gperf python-dev bison flex ant doxygen ccache gstreamer1.0-libav libkrb5-dev nasm
sourceの入手
$ time git clone git://anongit.freedesktop.org/libreoffice/core
   :
real    35m26.954s
user    8m5.441s
sys     1m1.694s
autogen(--with-locales も`ALL` にしてみた)
$ time ./autogen.sh --with-package-format='deb' --enable-epm --with-lang=ALL --with-locales=ALL
make
$ time make -j$(nproc)
  :
real    137m3.246s
user    59m6.001s
sys     25m13.390s

その後も git pull && make とかして 7.0.0.0.alpha1+ にすることも出来ました.

buildしたDebianパッケージはいつまでかわからないけどここで公開しています.

てことでどうにかビルドできました.build後のsource ディレクトリ以下は20GB近く.build-depでも1GB以上消費しました.ディスクも結構食いますね.

相談しながら引っかかったら聞くという場があるのは助かりますね.今回の機会がなかったら自分でbuildしなかったと思います.

次回の「LibreOffice Hackfest Online #3」は05/13(Wed)に開催で以下のページから申し込みが出来ます.jitsi Meetでの開催で,YoutubeLiveでの配信も行われる予定です.

Youtube-dlコマンドで字幕をダウンロードする

add 2020-06-12

以下の例では動画ファイルと字幕ファイルが別々に作成されます.動画に字幕ファイルを埋め込めないかなとオプションを確認したら --embed-subs というオプションがありました.これを利用したら1つの動画ファイルの中に字幕も埋め込めました :)

$ youtube-dl --help|grep -- --embed
    --embed-subs                     Embed subtitles in the video (only for mp4, webm and mkv videos)
    --embed-thumbnail                Embed thumbnail in the audio as cover art

ただし,Debian sid amd64環境では別途 atomicparsley パッケージも必要でした.

atomicparsley パッケージを入れる前のエラー
ERROR: AtomicParsley was not found. Please install.
atomicparsley パッケージの導入
$ sudo apt install atomicparsley
480pでダウンロードして日本語機械翻訳字幕を埋め込み
$ youtube-dl --write-auto-sub --sub-lang=ja --embed-subs -c -f 133 -o './%(title)s.%(ext)s' 'https://www.youtube.com/playlist?list=PLYUtdmpYPTTKgmkaIUFDiNvYPxQUzuY8y'
以下のあたりでも書いたのですが,回線が不安定で途中で止まったり解像度が低かったりするのでVODをローカルにダウンロードしてから視聴することが多いです.

日本語の動画の場合はこれで問題ないのですが, id:naruoga/@naru0gaさんがLibreOffice Asia Conference 2019 Tokyo 基調講演の動画に日本語字幕を付けてくれました.OSSが興味ある人なら気になる感じの内容のようなので視聴したいけど字幕ダウンロードしたこと無いなと試してみました.

導入していない人はインストールしましょう.バイナリを1つダウンロードして実行権を付けるだけです.以下は ~/bin に導入する例.

$ curl -L https://yt-dl.org/downloads/latest/youtube-dl -o ~/bin/youtube-dl
$ chmod +rx ~/bin/youtube-dl

先ずはhelpを確認します.

$ youtube-dl --help|grep 'Subtitle Options:' -A7
  Subtitle Options:
    --write-sub                      Write subtitle file
    --write-auto-sub                 Write automatically generated subtitle file (YouTube only)
    --all-subs                       Download all the available subtitles of the video
    --list-subs                      List all available subtitles for the video
    --sub-format FORMAT              Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"
    --sub-lang LANGS                 Languages of the subtitles to download (optional) separated by commas, use --list-subs for available
                                     language tags

結構シンプルな感じですね.早速試してみます.

先ずは --list-subs で字幕の一覧を取得してみます.

$ youtube-dl --ignore-config --list-subs QS-Zz-2ovo0
[youtube] QS-Zz-2ovo0: Downloading webpage
[youtube] QS-Zz-2ovo0: Looking for automatic captions
[youtube] QS-Zz-2ovo0: Downloading MPD manifest
Available automatic captions for QS-Zz-2ovo0:
Language formats
gu       vtt, ttml, srv3, srv2, srv1
zh-Hans  vtt, ttml, srv3, srv2, srv1
zh-Hant  vtt, ttml, srv3, srv2, srv1
gd       vtt, ttml, srv3, srv2, srv1
ga       vtt, ttml, srv3, srv2, srv1
gl       vtt, ttml, srv3, srv2, srv1
lb       vtt, ttml, srv3, srv2, srv1
la       vtt, ttml, srv3, srv2, srv1
lo       vtt, ttml, srv3, srv2, srv1
tt       vtt, ttml, srv3, srv2, srv1
tr       vtt, ttml, srv3, srv2, srv1
lv       vtt, ttml, srv3, srv2, srv1
lt       vtt, ttml, srv3, srv2, srv1
tk       vtt, ttml, srv3, srv2, srv1
th       vtt, ttml, srv3, srv2, srv1
tg       vtt, ttml, srv3, srv2, srv1
te       vtt, ttml, srv3, srv2, srv1
fil      vtt, ttml, srv3, srv2, srv1
haw      vtt, ttml, srv3, srv2, srv1
yi       vtt, ttml, srv3, srv2, srv1
ceb      vtt, ttml, srv3, srv2, srv1
yo       vtt, ttml, srv3, srv2, srv1
de       vtt, ttml, srv3, srv2, srv1
da       vtt, ttml, srv3, srv2, srv1
el       vtt, ttml, srv3, srv2, srv1
eo       vtt, ttml, srv3, srv2, srv1
en       vtt, ttml, srv3, srv2, srv1
eu       vtt, ttml, srv3, srv2, srv1
et       vtt, ttml, srv3, srv2, srv1
es       vtt, ttml, srv3, srv2, srv1
ru       vtt, ttml, srv3, srv2, srv1
rw       vtt, ttml, srv3, srv2, srv1
ro       vtt, ttml, srv3, srv2, srv1
bn       vtt, ttml, srv3, srv2, srv1
be       vtt, ttml, srv3, srv2, srv1
bg       vtt, ttml, srv3, srv2, srv1
uk       vtt, ttml, srv3, srv2, srv1
jv       vtt, ttml, srv3, srv2, srv1
bs       vtt, ttml, srv3, srv2, srv1
ja       vtt, ttml, srv3, srv2, srv1
or       vtt, ttml, srv3, srv2, srv1
xh       vtt, ttml, srv3, srv2, srv1
co       vtt, ttml, srv3, srv2, srv1
ca       vtt, ttml, srv3, srv2, srv1
cy       vtt, ttml, srv3, srv2, srv1
cs       vtt, ttml, srv3, srv2, srv1
ps       vtt, ttml, srv3, srv2, srv1
pt       vtt, ttml, srv3, srv2, srv1
pa       vtt, ttml, srv3, srv2, srv1
vi       vtt, ttml, srv3, srv2, srv1
pl       vtt, ttml, srv3, srv2, srv1
hy       vtt, ttml, srv3, srv2, srv1
hr       vtt, ttml, srv3, srv2, srv1
ht       vtt, ttml, srv3, srv2, srv1
hu       vtt, ttml, srv3, srv2, srv1
hmn      vtt, ttml, srv3, srv2, srv1
hi       vtt, ttml, srv3, srv2, srv1
ha       vtt, ttml, srv3, srv2, srv1
mg       vtt, ttml, srv3, srv2, srv1
uz       vtt, ttml, srv3, srv2, srv1
ml       vtt, ttml, srv3, srv2, srv1
mn       vtt, ttml, srv3, srv2, srv1
mi       vtt, ttml, srv3, srv2, srv1
mk       vtt, ttml, srv3, srv2, srv1
ur       vtt, ttml, srv3, srv2, srv1
mt       vtt, ttml, srv3, srv2, srv1
ms       vtt, ttml, srv3, srv2, srv1
mr       vtt, ttml, srv3, srv2, srv1
ug       vtt, ttml, srv3, srv2, srv1
ta       vtt, ttml, srv3, srv2, srv1
my       vtt, ttml, srv3, srv2, srv1
af       vtt, ttml, srv3, srv2, srv1
sw       vtt, ttml, srv3, srv2, srv1
is       vtt, ttml, srv3, srv2, srv1
am       vtt, ttml, srv3, srv2, srv1
it       vtt, ttml, srv3, srv2, srv1
iw       vtt, ttml, srv3, srv2, srv1
sv       vtt, ttml, srv3, srv2, srv1
ar       vtt, ttml, srv3, srv2, srv1
su       vtt, ttml, srv3, srv2, srv1
zu       vtt, ttml, srv3, srv2, srv1
az       vtt, ttml, srv3, srv2, srv1
id       vtt, ttml, srv3, srv2, srv1
ig       vtt, ttml, srv3, srv2, srv1
nl       vtt, ttml, srv3, srv2, srv1
no       vtt, ttml, srv3, srv2, srv1
ne       vtt, ttml, srv3, srv2, srv1
ny       vtt, ttml, srv3, srv2, srv1
fr       vtt, ttml, srv3, srv2, srv1
ku       vtt, ttml, srv3, srv2, srv1
fy       vtt, ttml, srv3, srv2, srv1
fa       vtt, ttml, srv3, srv2, srv1
fi       vtt, ttml, srv3, srv2, srv1
ka       vtt, ttml, srv3, srv2, srv1
kk       vtt, ttml, srv3, srv2, srv1
sr       vtt, ttml, srv3, srv2, srv1
sq       vtt, ttml, srv3, srv2, srv1
ko       vtt, ttml, srv3, srv2, srv1
kn       vtt, ttml, srv3, srv2, srv1
km       vtt, ttml, srv3, srv2, srv1
st       vtt, ttml, srv3, srv2, srv1
sk       vtt, ttml, srv3, srv2, srv1
si       vtt, ttml, srv3, srv2, srv1
so       vtt, ttml, srv3, srv2, srv1
sn       vtt, ttml, srv3, srv2, srv1
sm       vtt, ttml, srv3, srv2, srv1
sl       vtt, ttml, srv3, srv2, srv1
ky       vtt, ttml, srv3, srv2, srv1
sd       vtt, ttml, srv3, srv2, srv1
Available subtitles for QS-Zz-2ovo0:
Language formats
en       vtt, ttml, srv3, srv2, srv1
ja       vtt, ttml, srv3, srv2, srv1

大量に出てきましたが,上の方の Available automatic captions の物はYoutubeの自動生成&自動翻訳されたもののようです.
Available subtitles 以下のものが人の手で翻訳されたものだと思います.今回の動画では en, ja があるようです.

--write-sub --sub-lang=ja で日本語の字幕を書き出すよう指定してみます.

$ youtube-dl --ignore-config --write-sub --sub-lang=ja QS-Zz-2ovo0

動画名.mp4動画名.ja.vtt というファイルが入手できました.動画名.言語.vtt というファイルが字幕ファイルのようです.この2ファイルが同じディレクトリにある状態で動画プレイヤーで .mp4 を再生すると字幕が表示されました :)

Totemでは表示されませんでしたが,メニューから字幕ファイルを指定すると表示されました.

$ ls LibreOffice\ Asia\ Conference\ 2019\ -\ LibreOffice\,\ the\ many\ different\ faces\ of\ a\ global\ community.*
'LibreOffice Asia Conference 2019 - LibreOffice, the many different faces of a global community.ja.vtt'
'LibreOffice Asia Conference 2019 - LibreOffice, the many different faces of a global community.mp4'
$ mpv ./LibreOffice\ Asia\ Conference\ 2019\ -\ LibreOffice\,\ the\ many\ different\ faces\ of\ a\ global\ community.mp4
$ cvlc ./LibreOffice\ Asia\ Conference\ 2019\ -\ LibreOffice\,\ the\ many\ different\ faces\ of\ a\ global\ community.mp4

youtu dl subtitle

これでとりあえず目的は果たせました.
でもYoutubeでのみですが,自動生成翻訳字幕のダウンロードが気になるのでこれも試してみます.
今度は日本語字幕の存在しないDebconf19のもので日本語の自動生成字幕 --sub-lang=ja --write-auto-sub オプション&解像度を240pにしておきます.

$ youtube-dl --sub-lang=ja --write-auto-sub -f 'bestvideo[height<=240]+bestaudio/best[height<=360]' U17DID4vdpc

自動生成&機械翻訳なのでおかしなところはありますがいけたようです.

youtube dl subtitle auto

後はライブ動画やライブ音声のリアルタイム翻訳ができるといいなーと思ったりも.DeepSpeechで文字起こししてみんなの翻訳とかDeeplに都賀具感じでリアルタイムで出来ないかなとか.

環境
$ youtube-dl --version
2020.05.03
$ dpkg-query -W mpv vlc totem firejail
firejail        0.9.62-3
mpv     0.32.0-1
totem   3.34.1-2+b1
vlc     3.0.10-1

9

Bluetooth ヘッドセットが A2DP に切り替えられなくて困る

最近Bluetooth ヘッドセットで A2DP に切り替えが出来なくなっていました.オーディオプロファイルを A2DP にしようとすると変更に失敗します.

20200410 03:04:39 1847144

20200410 03:04:39 1847144 2

有線のヘッドホン(セリア製100円!)で使っていたのですが頭に合わなかったり不自由なので調べることに.
以下のページを見つけました.

どうも PulseAudio の自動切り替えがうまく行っていないようでこれを無効にすることで直りました.

具体的な設定は, /etc/pulse/default.pa ファイルの load-module module-bluetooth-policyauto_switch=false というオプションを付けでデーモンの再起動です.

/etc/pulse/default.pa を修正.
$ sudo git -C /etc diff /etc/pulse/default.pa
diff --git a/pulse/default.pa b/pulse/default.pa
index f670be0..494c1ce 100644
--- a/pulse/default.pa
+++ b/pulse/default.pa
@@ -64,7 +64,7 @@ load-module module-jackdbus-detect channels=2

 ### Automatically load driver modules for Bluetooth hardware
 .ifexists module-bluetooth-policy.so
-load-module module-bluetooth-policy
+load-module module-bluetooth-policy auto_switch=false
 .endif

 .ifexists module-bluetooth-discover.so
daemonを再起動(Pulseaudioは自動復帰した)
$ pulseaudio -k
$ sudo service bluetooth restart

この後ヘッドセットを接続し直すことでA2DPが使えるようになりました.

今使っているヘッドセットは Aukey EP-B26 で長時間使えていたのが良かったのですが,バッテリーがへたってしまっています.今はUSBケーブルで給電しながら使っています.有線なんだけど細いケーブル(100円ショップの巻取りUSB microBの中の線だけにしたもの)で小さなモバイルバッテリーをポケットに入れて使うと結構自由度高い感じです.

でも出来れば新調したいところ.同じものはもう売ってないようなのでこのへんとかかな?

AfterShokz も気になってるけどちょっとお高いですね.

環境
$ dpkg-query -W pulseaudio* bluez* blueman
blueman 2.1.2-1
bluez   5.53-0ubuntu2
bluez-alsa
bluez-audio
bluez-cups      5.53-0ubuntu2
bluez-gnome
bluez-input
bluez-network
bluez-obexd     5.53-0ubuntu2
bluez-serial
bluez-utils
pulseaudio      1:13.99.1-1ubuntu1
pulseaudio-module-bluetooth     1:13.99.1-1ubuntu1
pulseaudio-utils        1:13.99.1-1ubuntu1
$ lsb_release -dr
Description:    Ubuntu Focal Fossa (development branch)
Release:        20.04
$ uname -m
x86_64
$ lsusb -d 0a5c:217f
Bus 001 Device 016: ID 0a5c:217f Broadcom Corp. BCM2045B (BDC-2.1)
$ lspci | grep -i audio
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 06)