[英]How to make NGINX RTMP module store streamed HLS?
我正在使用帶有 RTMP 模塊的 NGINX 到 HLS 格式的 stream 視頻。 我想讓它以 HLS 格式存儲正在流式傳輸的實時視頻。 我知道 RTMP 模塊的hls_cleanup
指令,但是關閉清理並不能阻止.m3u8
被一遍又一遍地覆蓋。 如何為.m3u8
文件制作 NGINX append 新塊而不是覆蓋它? 如果這不是解決此問題的正確方法,我還有哪些其他選擇?
雖然答案可能有點晚,但我面臨同樣的挑戰,因此考慮回答。 總之hls_playlist_length
是解決方案。
hls_playlist_lenght 100d; #d = days y = years
您可能還想關閉hls_continious
。
hls_continious off; # plays video from the beginning I assume.
但是,請注意,播放列表時間過長會很快使m3u8
文件膨脹到一個巨大的大小。 因此,擔心直播可能對服務器端和客戶端都產生負面影響,我采用了以下方法。
application live {
live on;
hls on;
on_publish http://example.com/auth/onpublish;
on_update http://example.com/auth/onupdate;
on_done http://example.com/auth/ondone;
# Use some encrypted channel name to avoid unwanted streaming
# Make sure the push channels publish only from localhost
#
push rtmp://<ip>/livechannel_8jzh%6ifu....DZBVzdbdg12;
push rtmp://<ip>/hls_raid_8jzh%6ifu....DZBVzdbdg12;
}
直播設置(低延遲)
application livechannel_8jzh%6ifu....DZBVzdbdg12 {
# Only allow localhost to publish
allow publish 127.0.0.1; #!important
hls on;
hls_path /path/to/live/hls_storage;
hls_cleanup on;
# set play from present segment or
# right from beginning. Default off
hls_continuous on;
# push stream to stream key directory
hls_nested on;
# Low latency optimisation
# hls_sync 2ms;
hls_fragment 2s;
hls_playlist_length 6s;
}
保存完整的 hls 以備后用
application hls_raid_8jzh%6ifu....DZBVzdbdg12 {
# Only allow localhost to publish
allow publish 127.0.0.1; #!important
live on;
hls on;
hls_nested on;
hls_path /another/path/to/hls_raid;
hls_cleanup off;
hls_fragment 10s;
hls_playlist_length 100d;# choose any large number
hls_continuous off;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.