LoginSignup
13
14

More than 5 years have passed since last update.

Gstreamerを使ったビデオストリーミング

Last updated at Posted at 2016-05-29

概要

Gstreamerを使ってビデオストリーミングをしてみた

動作環境

ボード     :Raspberry Pi 3
カメラモジュール:Raspberry Pi Camera V2
イメージ    :emlid-raspbian-20160408

使用方法

  • Raspberry Pi側
  1. カメラモジュールを有効にする。
    Raspberry Piを起動したらコンフィグを起動する。
    sudo raspi-config
    『6 Enable Camera』を選択し、Enableを選択する。
    ※起動前にカメラモジュールをRaspberry Piに接続しておく必要がある。
    選択したらリブートする。

  2. Gstreamerをインストールする。
    sudo apt-get update
    sudo apt-get install gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad

  3. Gstreamerを起動する。
    raspivid -n -w 1280 -h 720 -b 1000000 -fps 15 -t 0 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=ストリーミング先のIP port=9000

  • クライアント側

GstreamerはMac,Linux,WindowsなどのOSで動作するが、
今回はWindowsでストリーミング再生を行う。

  1. Gstreamerからアプリケーションをダウンロード
    https://gstreamer.freedesktop.org/
    インストールは方法省略

  2. Gstreamerを起動
    コマンドプロンプトを起動し、以下のコマンドを実行
    cd gstremaerインストール先のディレクトリ
    gst-launch-1.0 -v udpsrc port=9000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=f

上記コマンドを実行するとストリーミング映像が再生される。
gst.jpg

トラブルシューティング

  • WARNING: erroneous pipeline: no element "avdec_h264"
    Gstreamerが古い可能性がある。
    公式から最新のGstreamerをダウンロードし、再インストールする。
    自分の場合は最新のGstreamerをダウンロードし、インストール時に"Complete"を選択してインストールを行ったことで、
    上記のWARNINGが表示されなくなった。

  • ERROR: from element /GstPipeline:pipeline0/GstH264Parse:h264parse0: No valid frames found before end of stream
    カメラモジュールが正しく接続されていない可能性がある。
    接続を確認し、再度実行することで改善される。

13
14
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
13
14