LoginSignup
5
4

More than 3 years have passed since last update.

GstreamerでMotionJPEG over HTTPをRTSPにて配信してみる

Last updated at Posted at 2020-06-20

GstreamerでIPカメラの映像をRTSP配信する

目的:HTTPのmultipart/x-mixed-replaceなどのcontent-typeで画像を連続配信するIPカメラがあるがRTSPプロトコルには対応していないことがある。その場合、RTSPにしか対応していないビデオレコーダーに映像を連携できないため、RTSPで配信できるようにサーバーもしくは、SBC(Single Board Computer)で対応する。

注意:H.264のコーデックなど映像系のライセンス関連は注意必要なので商用利用は、詳細調査必要

環境

  • OS:Ubuntu18.04 LTS
  • HTTPで映像配信するネットワークカメラ
  • VLCプレイヤー

手順

gstreamerをインストール

sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly

test-launchのDLとコンパイル

こちらの方の記事を参考にさせていただいた。

上記から、test-launch.cを取得しコンパイル

sudo apt install libgstrtspserver-1.0-dev
gcc -o test-launch test-launch.c `pkg-config --cflags --libs gstreamer-rtsp-server-1.0`

gstreamerでHTTPをRTSP配信

./test-launch 'souphttpsrc location="<http://cameraip/motionjpegurl>" ! multipartdemux ! image/jpeg,width=320,height=240,framerate=5/1 ! jpegdec ! videorate ! video/x-raw,framerate=60/1 ! x264enc tune=zerolatency ! h264parse ! rtph264pay name=pay0 pt=96'

フレームレートは、対象のカメラに合わせて変更。

VLCプレイヤーで確認

Windowsなどの端末でVLCプレイヤーを起動して確認
メニュー>メディア>ネットワークストリームを開く で、以下にアクセス。
rtsp://ip-address:port/test

5
4
1

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
5
4