LoginSignup
0
0

More than 1 year has passed since last update.

【Mac】Gstremerで動画を保存する方法

Last updated at Posted at 2021-12-27

本記事ではGstremerのコマンドの一つをご紹介します。
今回のコマンドを使用することで、Macに接続されているカメラデバイスで撮影した映像を動画にして保存することができます。

環境

macOS Monterlay 12.0.1
GStreamer Core Library version 1.18.4

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

$ gst-launch-1.0 -e avfvideosrc device-index=1 ! vtenc_h264 ! qtmux ! filesink location=file-test1.mp4

撮影が開始されると下記の画面になります。

パイプラインを一時停止 (PAUSED) にしています...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
パイプラインを再生中 (PLAYING) にしています...
New clock: GstSystemClock
Redistribute latency...
Redistribute latency...
0:00:10.9 / 99:99:99.

動画の撮影をCtl+Cで強制終了させます。これで実行したディレクトリに動画が保存されます。

パイプラインを一時停止 (PAUSED) にしています...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
パイプラインを再生中 (PLAYING) にしています...
New clock: GstSystemClock
Redistribute latency...
Redistribute latency...
^Chandling interrupt.
割り込み: パイプラインを停止しています...
EOS on shutdown enabled -- Forcing EOS on the pipeline
Waiting for EOS...
Got EOS from element "pipeline0".
EOS received - stopping pipeline...
Execution ended after 0:00:16.649098000
Setting pipeline to NULL ...
Freeing pipeline ...

パイプラインの簡単な解説

  • -e
    • 撮影を強制終了しても、動画が破損しないようにするオプション。
  • avfvideosrc device-index=1 !
    • デバイス番号の指定。※ 今回接続したWebカメラの番号は1番。
  • vtenc_h264 !
    • 特定のエンコード。
  • qtmux !
    • コンテナ化。※ 今回はquick time形式でコンテナ化。
  • filesink location=file-test1.mp4
    • 名前を指定してファイルを保存。

以上で終わりです。
パイプライン作成にあたり、利用できるオプションはたくさんあります。またエンコードやコンテナ化の種類もたくさんあります。Webカメラの種類や使用するPCの仕様で組み合わせが変わるので、都度ご確認ください。

0
0
0

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
0
0