Abstract
Time Keeperって便利ですよね。でもZoomで使うのにはOBS周りのインストールに加えて、スピーカーの設定とか、諸々変えなきゃいけません。正直面倒です。
ということで今回はPowerShellで、スピーカーの設定とかをコマンドで行い、あとはZoomで設定変えるだけってところまで持って行きます。
補足: OBS 28のベータではWindows版にのみApplication-specific audio captureを追加すると記載があります。今後はここに述べているような方法は必要ないのかもしれません。ご注意を。参考↓
環境
Windowsです。PowerShellを使います。
- Windows 10
- PowerShell 7.2.5
Macとかはわかりません...
手順
アプリケーションを導入
wingetで割とインストールできるようになっているので便利ですね。
- OBS studio
- サイトから -> https://obsproject.com/ja/download
- 通常? ->
winget install -e --id OBSProject.OBSStudio
- Microsoft Store版 ->
winget install -e --id XPFFH613W8V6LV
- OBS-VirtualCam
- github release -> https://github.com/CatxFish/obs-virtual-cam/releases
winget install -e --id Fenrirthviti.obs-virtual-cam
- VB-cable
- wingetは対応してなさげ。
- サイトから -> https://vb-audio.com/Cable/index.htm
AudioDeviceCmdletsの導入
次にPowerShellからオーディオ設定を変更するコマンドを導入します。
(PowerShellからオーディオ設定を触る部分を自作するのは相当骨が折れます。参考: Windowsの音声出力先を変えるショートカット作成)
AudioDeviceCmdletsをインストールしましょう。
Install-Module -Name AudioDeviceCmdlets
コマンドの使い方自体はusageをご覧ください。
次のコマンドで、普段使っている出力デバイスのindexを確認しておいてください。
Get-AudioDevice -List
以下のような出力が得られますので、indexをメモしておきましょう。自分は普段、index: 1のスピーカー (USB Audio DAC)とindex: 5のマイクを使っているので、1と5を覚えておきます。
Index : 1
Default : False
DefaultCommunication : True
Type : Playback
Name : スピーカー (USB Audio DAC )
ID : {0.0.0.00000000}.{25efcb78-99e7-4967-ab9f-e2c7ffe62d94}
Device : CoreAudioApi.MMDevice
...(略)
コマンド定義
最後に、プロファイルに設定などを一括で行うコマンドを定義します。お好きなエディタで$PROFILE
を編集します。
VSCodeならcode $PROFILE
です。ファイルの末尾に次の関数を書き加えます。
function findAudioDeviceIndexByName([string]$name) {
<#
.SYNOPSIS
find index by its name. if no device is found, return -1.
.DESCRIPTION
find index by its name. if no device is found, return -1.
.PARAMETER name
Specifies device name you want to find.
.LINK
https://github.com/frgnca/AudioDeviceCmdlets
#>
$index = -1
foreach($device in Get-AudioDevice -List){
if ($device.Name -eq $name){
$index = $device.Index
break
}
}
if ($index -eq -1) {
Write-Output "No $name found."
}
return $index
}
function activateWebTimer([switch]$OpenManual) {
<#
.SYNOPSIS
set audio output devece "CABLE Input (VB-Audio Virtual Cable)"
.DESCRIPTION
set audio output devece "CABLE Input (VB-Audio Virtual Cable)"
You need to install [AudioDeviceCmdlets](https://github.com/frgnca/AudioDeviceCmdlets) via `Install-Module -Name AudioDeviceCmdlets`.
#>
#* 出力デバイスを変更 *#
$index = findAudioDeviceIndexByName("CABLE Input (VB-Audio Virtual Cable)")
Set-AudioDevice -Index $index -DefaultOnly
$index = findAudioDeviceIndexByName("CABLE Output (VB-Audio Virtual Cable)")
Set-AudioDevice -Index $index -DefaultOnly
#* WebTimerを起動 *#
# ref: https://abhp.net/it/IT_Google_Chrome_950000.html
Start-Process Chrome "https://maruta.github.io/timekeeper/#t1=7:00&t2=10:00&t3=15:00&m=10%20min%20talk%20%26amp%3B%205%20min%20discussion%26nbsp%3B", --new-window, --disable-extensions, --incognito
#* OBS studioを起動 *#
# ref: https://sugiyamatatsuya.com/obs-studio%E3%82%92%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%A7%E5%AE%9F%E8%A1%8C/
Set-Location "C:\Program Files\obs-studio\bin\64bit"
# 仮想カメラを有効にして開始
.\obs64.exe --startvirtualcam
if ($OpenManual) {
Start-Process Chrome "https://flex.phys.tohoku.ac.jp/japanese/computer/timer.html"
}
}
function deactivateWebTimer() {
#* 元々普段使っているデバイスに設定 *#
#! ここを先ほど控えたindexに書き換える
Set-AudioDevice -Index 1 -DefaultOnly
Set-AudioDevice -Index 5 -DefaultOnly
}
なお、ここではGoogle ChromeでWebTimerを起動していますが、コマンドで起動できるなら何でもよいです。
画面をZoomで公開するため、お気に入り等が映っても問題ないようにシークレットモードにしています。
使い方
WebTimerが必要になった際には、PowerShellでactivateWebTimer
を呼び出して諸々を起動します。
OBSでは…
- ソースの+からウィンドウキャプチャを選択し、ウインドウからブラウザを選択。
- 自分の場合は [Chrome.exe]: Time Keeper - Google Chrome でした。
- ブラウザが最小化されていると選択肢に現れません
- 表示を適当に調整します。
- 名前が左下に入ったりするので、多少上側にタイマーが表示されるように調整するのが良いかも?
Zoomの設定では…
- ビデオを OBS-Camera にします。
- マイビデオをミラーリングのチェックを外します。
- 低照度に対して補正のチェックを外します。
- スピーカー・マイクは システムと同じ にします。
はぁ、Zoomもコマンドで色々設定させて...
WebTimerが不要になったら、deactivateWebTimer
でオーディオデバイスを普段のものに戻して、諸々のウィンドウを閉じればオッケーです。
Zoomのカメラの設定なども普段使いのものに戻しましょう。