LoginSignup
30
32

More than 5 years have passed since last update.

GStreaemer の便利ツールたち

Last updated at Posted at 2015-12-06

諸事情(突然の招集)により1日遅れてまいました... :bow:
yashi さんに圧倒的感謝…

気を取り直して、今日は gstreamer のツールについてです。

※ GStreamer 1.6.1 を前提に書いています。バージョンによっては紹介するツールがありませんので気を付けてください!

さて、gstreamer の全体像と言えばこの絵です。
この、左上の gstreamer tools を紹介します。

gstreamer

tool 一覧

名前 概要
gst-launch-1.0 省略
gst-inspect-1.0 省略
gst-play-1.0 gst-play-1.0 - Simple command line playback testing tool
gst-typefind-1.0 print Media type of file
gst-discoverer-1.0 Display file metadata and stream information
gst-device-monitor-1.0 Simple command line testing tool for GStreamer device monitors

gstreamer0.10 では gst-editor という GUI でパイプラインを組み立てるツールがあったのですが、gstreamer1.0 はサポートしていないみたいです。

知りたい人はこちら -> gst-editor

以下はそれぞれのツールの紹介です。

gst-play

gst-playplayback testing tool とは言っていますが、再生するだけなら gst-launch より楽なすぐれものです。

verbose オプションのようなものはありませんが、GST_DEBUG を使えば、中のパイプラインが見えるかもしれませんね。
一通りの機能がそろっているので、メディアプレイヤーを開発したい方はこのソースコードがかなり参考になりそうです

$ gst-play-1.0 music.mp3
Press 'k' to see a list of keyboard shortcuts.
Now playing /home/shotam/music.mp3
Interactive mode - keyboard controls:

        space    : pause/unpause
        q or ESC : quit
        >        : play next
        <        : play previous
        →        : seek forward
        ←        : seek backward
        ↑        : volume up
        ↓        : volume down
        +        : increase playback rate
        -        : decrease playback rate
        d        : change playback direction
        t        : enable/disable trick modes
        a        : change audio track
        v        : change video track
        s        : change subtitle track
        k        : show keyboard shortcuts

0:00:04.1 / 0:05:34.0

ただ、Windows上だと、再生はできるものの、キー入力を受け付けてくれませんでした。こんなメッセージがでます。

Interactive keyboard handling in terminal not available.

気になるので、近々ソースコードでも眺めてみようかな...

gst-typefind

パイプラインを組み立てたり、欲しいエレメントを探す時に便利なツールです。

たとえば、mp3 ファイルを処理したい場合、gst-typefind を使い以下の情報を得ます。

$ gst-typefind-1.0 music.mp3
music.mp3 - audio/mpeg, mpegversion=(int)1, layer=(int)3, parsed=(boolean)false

このことから「この mp3 ファイルを処理するためには、Element の sink pad が audio/mpeg に対応している必要がある。」ということがわかります。

gst-discover

gst-typefind よりもさらに詳しいメタ情報を得るのが gst-discover です。

$ gst-discoverer-1.0 music.mp3
Analyzing file:///C:/msys64/home/skyin_000/music.mp3
Done discovering file:///C:/msys64/home/skyin_000/music.mp3

Topology:
  audio: MPEG-1 Layer 3 (MP3)

Properties:
  Duration: 0:05:32.820000000
  Seekable: yes
  Tags:
      has crc: false
      channel mode: joint-stereo
      audio codec: MPEG-1 Layer 3 (MP3)
      nominal bitrate: 256000
      bitrate: 256000

gst-device-monitor

接続したカメラなどの対応フォーマットを表示することができます。
v4l-utils で v4l2-ctl --list-formats-ext とやっていた人はこれに置き換えることができますね。

gst-device-monitor-1.0
Probing devices...


Device found:

        name  : Rear Camera
        class : Video/Source
        caps  : video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                video/x-raw, format=(string)YUY2, width=(int)640, height=(int)360, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)3264, height=(int)2448, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)2592, height=(int)1944, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)1600, height=(int)1200, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;


Device found:

        name  : Front Camera
        class : Video/Source
        caps  : video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720, framerate=(fraction)10/1, pixel-aspect-ratio=(fraction)1/1;
                video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                video/x-raw, format=(string)YUY2, width=(int)424, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                video/x-raw, format=(string)YUY2, width=(int)640, height=(int)360, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                video/x-raw, format=(string)YUY2, width=(int)848, height=(int)480, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1;
                video/x-raw, format=(string)YUY2, width=(int)960, height=(int)540, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)1280, height=(int)720, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)640, height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)424, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)640, height=(int)360, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)848, height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;
                image/jpeg, width=(int)960, height=(int)540, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1;

以上、ツールの紹介でした。

30
32
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
32