(Mac) Gstremerで接続デバイスを確認する方法


本記事ではGstremerのコマンドの一つをご紹介します。
今回のコマンドを使用することで、Macに接続されているデバイス(video/audio)を確認することができます。

環境

macOS Monterlay 12.0.1
GStreamer Core Library version 1.18.4

下記のコマンドを実行する。

$ gst-device-monitor-1.0

結果は以下のとおり。

Device found:

    name  : FaceTime HDカメラ(内蔵)
    class : Video/Source
    caps  : video/x-raw(memory:GLMemory), width=1280, height=720, format=UYVY, framerate=[ 1/1, 10000000/333333 ], texture-target=rectangle
            video/x-raw(memory:GLMemory), width=640, height=480, format=UYVY, framerate=[ 1/1, 10000000/333333 ], texture-target=rectangle
            video/x-raw, width=1280, height=720, format={ (string)UYVY, (string)YUY2, (string)NV12, (string)BGRA }, framerate=[ 1/1, 10000000/333333 ]
            video/x-raw, width=640, height=480, format={ (string)UYVY, (string)YUY2, (string)NV12, (string)BGRA }, framerate=[ 1/1, 10000000/333333 ]
    properties:
        device.api = ~~~
        avf.unique_id = ~~~
        avf.model_id = ~~~
        avf.has_flash = ~~~
        avf.has_torch = ~~~
        avf.manufacturer = "Apple\ Inc."
    gst-launch-1.0 avfvideosrc device-index=0 ! ...


Gstremerのパイプラインを作成する際に、主に確認する項目は下記の部分です。

デバイス番号の確認

# 下記をそのまま活用すればOK。Webカメラなどは device-index=1 ! 等が割り当てられていることが多い。
gst-launch-1.0 avfvideosrc device-index=0 ! ...

スペック確認

# 仕様を指定する際に必要な項目。※ fps=10000000/333333 と書いてあるが30/1でうまくいく場合もあり表記方法があいまい。うまくいかない場合、両方の表記方法を試してみるといいかも。
 caps  : video/x-raw(memory:GLMemory), width=1280, height=720, format=UYVY, framerate=[ 1/1, 10000000/333333 ], texture-target=rectangle

以上で終わりです。
このコマンドはパイプラインを作成する際によく利用することになると思います。ちなみにコマンドの末尾に「Vidio/Source」または「Audio/Source」を追加すると検索結果を絞ることができるので、ぜひお試しください。