![見出し画像](https://assets.st-note.com/production/uploads/images/89980917/rectangle_large_type_2_fc6bbd49193be9276a867f936b8839bd.jpeg?width=1200)
【お手軽】Windowsでも出来るRTMPおよびHLS変換によるブラウザ視聴サポートが出来るサーバの構築について
前回の記事
Windowsならこちらが楽ちんであるので、記事を上げる。
対象要件
自分のパソコン内(ローカル)で実行すること
パソコンおよび配信に使うスマホはwifiルーターに繋がっていること
圧縮ファイルを解凍する方法を知っていること
wifi 接続することができること
windows 10 かwindows 11のパソコンを使用していること
rtmp配信に使うスマホ、およびアプリを持っていること
所要時間
30分
内訳
ダウンロード:5分
圧縮ファイル解凍、配置:5分
サーバの起動まで:10分
配信、内容確認:10分
実行方法
圧縮ファイルのダウンロード
下記のアドレスより、圧縮ファイルをダウンロードする。
https://github.com/ustoopia/Live-stream-server-portable-Windows-Nginx-RTMP-HLS-Dash
[Code] → [Download Zip]
![](https://assets.st-note.com/img/1666975321299-J1OdAqj6Cd.png?width=1200)
![](https://assets.st-note.com/img/1666975548886-jqbrnxuGXv.png?width=1200)
圧縮ファイルの解凍
圧縮ファイルをダウンロードしたら解凍しよう。
圧縮ファイルを選択して右クリック「すべて展開」する
![](https://assets.st-note.com/img/1666975762292-l00RaVBNpf.png?width=1200)
![](https://assets.st-note.com/img/1666975856553-JNRFj62O2G.png?width=1200)
![](https://assets.st-note.com/img/1666975943334-vWqd7WrOr3.png?width=1200)
フォルダの配置
必要に応じて解凍したファイルをリネームして配置しよう。今回は公式サイトの記述通り、livestreamとリネームしてCドライブ直下に配置する。なお、ダウンロードした圧縮フォルダは削除してよい。
First we need to make sure that all the files are unblocked by Windows so we can run them. You can accomplish this by right-clicking the executable files and choose properties, and then choose unblock. But there is a faster, easy way to unblock all the files in a certain folder. Click start, start typing: "Windows Powershell" and if it appears, right click on it and choose: "Run as administrator". Enter something like the following in the window. (In this example I placed the contents of the zip file in C:\livestream.
![](https://assets.st-note.com/img/1666976762129-wNi0rJjLUx.png?width=1200)
PowerShellを起動してコマンドを実行する
Windowsのマークを右クリックして、Windows PowerShell(管理者)をクリックする
![](https://assets.st-note.com/img/1666977517680-8CKhXpiqFk.png?width=1200)
Windows PowerShellが立ち上がったら、下記のコマンドを入力してEnterを押す
dir C:\livestream -Recurse | Unblock-File
![](https://assets.st-note.com/img/1666977870965-5q2FIVrkqK.png?width=1200)
![](https://assets.st-note.com/img/1666977990736-Slgb5HDkAO.png?width=1200)
サーバーの起動
配置したフォルダに含まれる、NGINX.exeをダブルクリックしてサーバーを起動する。
![](https://assets.st-note.com/img/1666978953781-UebSUcFtyh.png?width=1200)
![](https://assets.st-note.com/img/1666979489435-9vU8xidxTF.png?width=1200)
実行したパソコンにローカルサーバとしてnginxサーバが立ち上がる
rtmpによる配信
スマホからrtmp配信のアプリを起動して、ストリームURLとストリームキーをもとに配信をする
The stream URL should be: "rtmp://localhost/live" and the live- stream key should be: "stream"
なお、配信するスマホからみれば、サーバのアドレスはlocalhostではないのでサーバのipアドレスを調べて仮に"192.168.0.1"であれば、下記のように指定する。
rtmp://192.168.0.1/live/stream
サーバのアドレスが分からない場合は、ipconfigのコマンドで確認しよう。
![](https://assets.st-note.com/img/1666982984757-tCE0pk6wWL.png?width=1200)
ブラウザによる確認
サーバーのアドレスをブラウザで開く
http://localhost
![](https://assets.st-note.com/img/1666979832345-u4GZr8XA84.png?width=1200)
Welcome to nginx for Windows!という画面が表示されたら、「test_HLS」というリンクをクリックする。
![](https://assets.st-note.com/img/1666980947269-Ad3V8e7AVE.png?width=1200)
配信内容が表示される
![](https://assets.st-note.com/img/1666982159222-IDw3cGVL5u.png?width=1200)
サーバの終了
要件が済んだら、stop-nginx.batをダブルクリックして実行する
![](https://assets.st-note.com/img/1666984050802-BQyFbpx91B.png?width=1200)
まとめ
特別、設定も要らずにサーバを構築できたと思う。少し試すだけであれば、これで十分だ。
おわり!