案外これ探してる人も多いかと思います。個人的な備忘録としてもまとめておこうかと
いつもは個別の固定ページでWowza関連をまとめてますが、今回はモジュールの話なので記事にしてみました
なお、本家のWowzaのページだと、この辺が実はまとまってません(今のところですが)
ただ、実はgithubの方でHLS to S3が可能なモジュールが公開されていたりします
https://github.com/WowzaMediaSystems/wse-example-pushpublish-hls
分かる人はこのリンク先のSample Implementationを参照するだけで大体できると思いますが、私が実際に動かしてみて動作した方法を以下にまとめたので、これを見た方がより確実だと思います
動作環境
まず、私が動作させた環境は以下の通りです
Wowza Stremaing Engine 4.7.7(Linux)
別にWindowsでも動くと思いますが、Windowsだと動作がもっさりするので、私はいつもLinux版を使っています
wse-example-pushpublish-hlsの設定
Sample Implementationの順序をそのまま日本語訳してるだけみたいな感じになりますが、後半では実際に動かした設定も載せます
1)wse-example-pushpublishing-hls.jarをWowzaをインストールしたディレクトリ配下のlibフォルダにコピーします
2)confフォルダ内のPushPublishProfilesCustom.xmlをテキストエディタで開きます
多分、最初はこのような感じになっていると思います
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<PushPublishProfiles>
<PushPublishProfile>
<Name>profilename</Name>
<Protocol>protocol</Protocol>
<BaseClass>classpath</BaseClass>
<UtilClass>utility classpath</UtilClass>
<Implementation>
<Name>destinationname</Name>
</Implementation>
<HTTPConfiguration>
</HTTPConfiguration>
</PushPublishProfile>
</PushPublishProfiles>
</Root>
これを以下のように変更します
<PushPublishProfile>
<Name>cupertino-file</Name>
<Protocol>HTTP</Protocol>
<BaseClass>com.mycompany.wms.example.pushpublish.protocol.cupertino.PushPublishHTTPCupertinoFileHandler</BaseClass>
<UtilClass></UtilClass>
<Implementation>
<Name>Cupertino File</Name>
</Implementation>
<HTTPConfiguration>
</HTTPConfiguration>
</PushPublishProfile>
<PushPublishProfile>
<Name>cupertino-http</Name>
<Protocol>HTTP</Protocol>
<BaseClass>com.mycompany.wms.example.pushpublish.protocol.cupertino.PushPublishHTTPCupertinoHTTPHandler</BaseClass>
<UtilClass></UtilClass>
<Implementation>
<Name>Cupertino HTTP</Name>
</Implementation>
<HTTPConfiguration>
</HTTPConfiguration>
</PushPublishProfile>
そのまま上書きでもいいですが、ちゃんと確認してから行うようにしてください
3)Stream Targetsの機能をWowza Streaming Engine上で有効にし、Wowzaをリスタート
この時、Stream Targetsには何も設定されている感じが無いと思いますが、それでOKです
4)confフォルダ内にあるPushPublishMap.txtの中身を書き換え(超重要)
とりあえずサンプルは以下の通りです
cupertino-file
はローカル接続されているフォルダに対して出力する際に使用します
cupertino-http
はS3やその他WebサーバーなどへHLSをプッシュする際に使用します
#cupertino-file entries
myStream={"entryName":"myStream", "profile":"cupertino-file", "streamName":"myOutputStream", "destinationName":"filesystem", "file.root":"c:\temp\hlsfile"}
myStream={"entryName":"myStreamBackup", "profile":"cupertino-file", "streamName":"myOutputStream", "destinationName":"filesystem", "file.root":"c:\temp\hlsfile", "destinationServer":"backup" }
myStream={"entryName":"myStreamRedundant", "profile":"cupertino-file", "streamName":"myOutputStream", "destinationName":"filesystem", "file.root":"c:\temp\hlsfile", "destinationServer":"redundant" }
#cupertino-http entries
myStream={"entryName":"myStream-http", "profile":"cupertino-http", "streamName":"myOutputStream", "destinationName":"webserver", "host":"example.com", "http.path":"hls"}
myStream={"entryName":"myStreamBackup-http", "profile":"cupertino-http", "streamName":"myOutputStream", "destinationName":"webserver", "host":"example.com", "http.path":"hls", "destinationServer":"backup" }
myStream={"entryName":"myStreamRedundant-http", "profile":"cupertino-http", "streamName":"myOutputStream", "destinationName":"webserver", "host":"example.com", "http.path":"hls", "destinationServer":"redundant" }
最初見たときにある程度理解できましたが、色々と不明な箇所もありました
実際に私が使用した設定はこちらです
総括
とりあえず複雑ではありますが、WowzaからHLSでS3などのストレージに直接出力する事が出来る事が分かりました
最後にとても重要な事を書きますが、実はこの出力方法にはバグ?が含まれており、Wowzaのheapサイズが最大になるとハングアップして止まってしまうという致命的な問題があります
具体的には、Wowzaの内部に蓄積されるTSファイルのファイルサイズが、合計で10GBもしくは9.8GBぐらい?になるとWowza自身がハングアップするという問題です
解決するにはWowzaを再起動するしかないので、当然HLSやMP4などで収録していた場合はダウンタイムが発生します
2018/12/01現在、この問題は改善されていません。メーカー側で修正してくれるとより使いやすくなるんですけどね・・・
【追記】
上記のエラーですが、解決したようです。これで結構汎用的に使えるようになりそうです