Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
9
Help us understand the problem. What is going on with this article?

More than 1 year has passed since last update.

@ekzemplaro

Raspberry Pi に rtmp サーバーを立てる

Raspberry Pi に rtmp ストリーミングサーバーを立てる方法です。Nginx をコンパイルする必要があります。

ソースの用意

wget http://nginx.org/download/nginx-1.12.2.tar.gz
git clone https://github.com/arut/nginx-rtmp-module.git

必要なソフトのインストール

sudo apt install g++
sudo apt install make
sudo apt install libpcre3-dev
sudo apt install libssl-dev

コンパイル、インストール

cd nginx-1.12.2
./configure --add-module=/home/uchida/tmp/nginx-rtmp-module
make
sudo make install

バージョンの確認

$ /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.12.2

$ /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1) 
built with OpenSSL 1.0.2l  25 May 2017
TLS SNI support enabled
configure arguments: --add-module=/home/uchida/tmp/rtmp/nginx-rtmp-module

Nginx を起動してみる

sudo /usr/local/nginx/sbin/nginx

ブラウザーでアクセスすると、
/usr/local/nginx/html/index.html が表示される

停止

sudo /usr/local/nginx/sbin/nginx -s stop

systemctl で起動できるようにする

/lib/systemd/system/nginx.service
[Unit]
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
After=network.target

[Service]
Type=forking
#PIDFile=/run/nginx.pid
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/local/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/local/nginxsbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile $PIDFile 
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target

起動

sudo systemctl start nginx

状態を調べる

sudo systemctl status nginx

停止

sudo systemctl stop nginx

/usr/local/nginx/conf/nginx.conf の最後に次の設定をつける

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                play /usr/local/nginx/html/video;
                        live on;
                        record off;
                }
        }
}

mp4 を保存するフォルダーを作成

sudo chmod 0777 /usr/local/nginx/html
mkdir /usr/local/nginx/html/video

/usr/local/nginx/html/video にサンプルの *.mp4 を入れる

Nginx を 起動する

curl で確認

curl -o tmp01.mp4 rtmp://pansy.local/live/sample.mp4

vlc でネットワーク越しに確認

vlc rtmp://pansy.local/live/sample.mp4
9
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
9
Help us understand the problem. What is going on with this article?