diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md index 4e2f20bb..a95fb904 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md @@ -7,263 +7,7 @@ hide_table_of_contents: false # HTTP-FLV Delivery -## HTTP FLV Live Stream - -SRS supports remux the rtmp stream to http flv stream, when publish rtmp stream on SRS, SRS will mount a http flv url and when user access the flv url, SRS will remux the rtmp stream to user. - -The config to delivery HTTP flv live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTPS FLV Live Stream - -SRS supports remux the rtmp stream to https flv stream, when publish rtmp stream on SRS, SRS will mount a https flv url and when user access the flv url, SRS will remux the rtmp stream to user. - -The config to delivery HTTPS flv live stream: - -``` -http_server { - enabled on; - listen 8080; - https { - enabled on; - listen 8088; - key ./conf/server.key; - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -> Remark: Please use your HTTPS key and cert file. - -> Note: To enable the HTTPS API, please read [HTTPS API](http://ossrs.net/srs.release/v4_EN_HTTPApi#https-api) - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP and HTTPS Proxy - -SRS works very well with HTTP/HTTPS proxy, like [Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), -[HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), -etc. Please read [#2881](https://github.com/ossrs/srs/issues/2881) for details. - -## HTTP TS Live Stream - -SRS supports remux the rtmp stream to http ts stream, when publish rtmp stream on SRS, SRS will mount a http ts url and when user access the ts url, SRS will remux the rtmp stream to user. - -The config to delivery HTTP ts live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].ts; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP Mp3 Live Stream - -SRS support remux the rtmp stream to http mp3 stream, drop video and mount mp3 http url, SRS will delivery mp3 stream when user access it. - -The config to delivery HTTP mp3 live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].mp3; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP Aac Live Stream - -SRS support remux the rtmp stream to http aac stream, drop video and mount aac http url, SRS will delivery aac stream when user access it. - -The config to delivery HTTP ac live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].aac; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP Live Stream Config - -The config for HTTP Flv/Mp3/Aac Live Stream, use different extension to apply different stream: - -``` -http_server { - # whether http streaming service is enabled. - # default: off - enabled on; - # the http streaming listen entry is <[ip:]port> - # for example, 192.168.1.100:8080 - # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 - # @remark, if use lower port, for instance 80, user must start srs by root. - # default: 8080 - listen 8080; - # For https_server or HTTPS Streaming. - https { - # Whether enable HTTPS Streaming. - # default: off - enabled on; - # The listen endpoint for HTTPS Streaming. - # default: 8088 - listen 8088; - # The SSL private key file, generated by: - # openssl genrsa -out server.key 2048 - # default: ./conf/server.key - key ./conf/server.key; - # The SSL public cert file, generated by: - # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" - # default: ./conf/server.crt - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - # http flv/mp3/aac/ts stream vhost specified config - http_remux { - # whether enable the http live streaming service for vhost. - # default: off - enabled on; - # the fast cache for audio stream(mp3/aac), - # to cache more audio and send to client in a time to make android(weixin) happy. - # @remark the flv/ts stream ignore it - # @remark 0 to disable fast cache for http audio stream. - # default: 0 - fast_cache 30; - # the stream mout for rtmp to remux to live streaming. - # typical mount to [vhost]/[app]/[stream].flv - # the variables: - # [vhost] current vhost for http live stream. - # [app] current app for http live stream. - # [stream] current stream for http live stream. - # @remark the [vhost] is optional, used to mount at specified vhost. - # the extension: - # .flv mount http live flv stream, use default gop cache. - # .ts mount http live ts stream, use default gop cache. - # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. - # .aac mount http live aac stream, ignore video and audio aac codec required. - # for example: - # mount to [vhost]/[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # mount to /[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # or by http://192.168.1.173:8080/live/livestream.flv - # mount to [vhost]/[app]/[stream].mp3 - # access by http://ossrs.net:8080/live/livestream.mp3 - # mount to [vhost]/[app]/[stream].aac - # access by http://ossrs.net:8080/live/livestream.aac - # mount to [vhost]/[app]/[stream].ts - # access by http://ossrs.net:8080/live/livestream.ts - # @remark the port of http is specified by http_server section. - # default: [vhost]/[app]/[stream].flv - mount [vhost]/[app]/[stream].flv; - } -} -``` - -Remark: Use forward+vhost to support multiple http live stream for a stream. - -Remark: The http server config section, read [HTTP Server](./http-server.md#config) - -## About HTTP FLV - -This section descrbes the HTTP FLV live streaming. - -How to use multiple process for HTTP FLV? Please read [Reuse Port](./reuse-port.md) for detail. - -### What is HTTP FLV - -All http streaming is a http flv url, for instance `http://ossrs.net:8081/live/livestream.flv`, but the delivery methods maybe different: - -1. FLV file, HTTP progressiv streaming. User can download and play the file which is serve by nginx, but user cannot seek to the part that not downloaded. -1. FLV pseudo streaming. This is the common used HTTP FLV streaming, to support to seek to the part which is not download, the server must accept a param, for instance .flv?start= to specifies the start time to play. This is HTTP FLV pseudo stream, but it's vod not live streaming. -1. FLV live streaming. The HTTP FLV streaming of SRS, is absolute live streaming, which is similar to RTMP for cluster, low latency, fault-backup and gop cache. And the HTTP FLV also similar to HTTP which can traverse firewall, HTTP 302 and simple. Because of SRS implements the HTTP and RTMP protocol, SRS remux the HTTP FLV stream on the edge server, and still use RTMP in cluster inside. The server which implements the RTMP and HTTP, only SRS and nginx-rtmp, but nginx-rtmp does not support HTTP FLV. - -In a word, the HTTP FLV of SRS is enhanced RTMP, absolute realtime media streaming delivery. - -### Confuse HTTP FLV - -The HTTP FLV of SRS is not: - -1. RTMPT: The rtmpt is similar to HTTP FLV of SRS, but rtmpt is rtmp over HTTP, not FLV over HTTP. -2. HDL/HFL: There exists another HXX stream, the latence maybe different, for SRS use RTMP to delivery HTTP FLV. -3. HDS: Absolutely not HTTP FLV, HDS is similar to HLS. - -### Why HTTP FLV - -Why SRS supports HTTP FLV? - -1. The internet realtime live streaming, generally use RTMP for low latence, while HTTP FLV latency equals to RTMP. -1. Firewall traverse: Many firewall may block RTMP, but never HTTP. -1. For GSLB: The HTTP FLV can support HTTP 302, to help GSLB to correct the stupid DNS problem. -1. Fault tolerance: The HTTP FLV of SRS similar to RTMP, support mulitple origin and fault backup. -1. Common Protocol: The HTTP FLV is ok for flash and other player. -1. Simple: FLV is the most simple media stream fomat, HTTP is the standard protocol of internet, they make thinks simple. - -## Sample - -The config sample, read https://github.com/ossrs/srs/issues/293#issuecomment-70449126 - -To config HTTP FLV, read [Sample](./sample-http-flv.md) - -## Websocket FLV - -After transmuxing HTTP-FLV to WebSocket-FLV, we could use [MSE(flv.js)](https://github.com/Bilibili/flv.js#features), please read [videojs-flow](https://github.com/winlinvip/videojs-flow). - -About transmuxing HTTP to WebSocket, please read [mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go). - -## HTTP FLV VOD Stream - -About the HTTP flv vod stream, read [v4_EN_FlvVodStream](./flv-vod-stream.md) - -Winlin 2015.1 - -[go-sharp]: https://github.com/ossrs/go-sharp +Migrated to [HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.io&path=/lts/doc/en/v6/delivery-http-flv) diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/flv.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/flv.md index 8eee543f..4a7d0685 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/flv.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/flv.md @@ -7,8 +7,207 @@ hide_table_of_contents: false # HTTP-FLV -See [HTTP-FLV](./delivery-http-flv.md). +HTTP-FLV is a live streaming protocol, sometimes simply called FLV, which is used to transmit live streams in FLV +format over an HTTP connection. -![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/en/v6/flv) +Unlike file downloads, live streams have an indefinite or uncertain length, so they are usually implemented using +the HTTP Chunked protocol. Similar to HTTP-FLV, there are also HTTP-TS and HTTP-MP3. TS is mainly used in broadcasting +and television, while MP3 is mainly used in the audio field. + +Different from HLS, which is essentially an HTTP file download, HTTP-FLV is a streaming protocol. CDN support for +HTTP file downloads is well-developed, making HLS more compatible than HTTP-FLV. However, HTTP-FLV has lower latency +than HLS, typically achieving a delay of around 3 to 5 seconds, while HLS latency is generally 8 to 10 seconds or more. + +In terms of protocol implementation, RTMP and HTTP-FLV are very similar. RTMP is based on the TCP protocol, and +HTTP-FLV is based on HTTP, which is also a TCP protocol. Therefore, their characteristics are very similar. RTMP +is generally used for streaming and live production because most live production devices support RTMP. For playback +and consumption, HTTP-FLV or HLS is used because playback devices have better support for HTTP. + +HTTP-FLV is highly compatible, supported by almost all platforms and browsers except for the native iOS browser. +You can refer to [MSE](https://caniuse.com/?search=mse) for more information. To support the iOS browser, you can +consider using HLS or WASM. Note that for native iOS apps, the ijkplayer can be used as a playback option. + +## Usage + +SRS supports HTTP-FLV distribution, you can use [docker](./getting-started.md) or [build from source](./getting-started-build.md): + +```bash +docker run --rm -it -p 1935:1935 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5 \ + ./objs/srs -c conf/http.flv.live.conf +``` + +Use [FFmpeg(click to download)](https://ffmpeg.org/download.html) or [OBS(click to download)](https://obsproject.com/download) to push the stream: + +```bash +ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream +``` + +Open the following page to play the stream (if SRS is not on your local machine, please replace localhost with the server IP): + +* HLS by SRS player: [http://localhost:8080/live/livestream.flv](http://localhost:8080/players/srs_player.html) + +## Config + +The configuration for HTTP-FLV is as follows: + +```bash +http_server { + # whether http streaming service is enabled. + # Overwrite by env SRS_HTTP_SERVER_ENABLED + # default: off + enabled on; + # the http streaming listen entry is <[ip:]port> + # for example, 192.168.1.100:8080 + # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 + # @remark, if use lower port, for instance 80, user must start srs by root. + # Overwrite by env SRS_HTTP_SERVER_LISTEN + # default: 8080 + listen 8080; + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +vhost __defaultVhost__ { + # http flv/mp3/aac/ts stream vhost specified config + http_remux { + # whether enable the http live streaming service for vhost. + # Overwrite by env SRS_VHOST_HTTP_REMUX_ENABLED for all vhosts. + # default: off + enabled on; + # the fast cache for audio stream(mp3/aac), + # to cache more audio and send to client in a time to make android(weixin) happy. + # @remark the flv/ts stream ignore it + # @remark 0 to disable fast cache for http audio stream. + # Overwrite by env SRS_VHOST_HTTP_REMUX_FAST_CACHE for all vhosts. + # default: 0 + fast_cache 30; + # Whether drop packet if not match header. For example, there is has_audio and has video flag in FLV header, if + # this is set to on and has_audio is false, then SRS will drop audio packets when got audio packets. Generally + # it should work, but sometimes you might need SRS to keep packets even when FLV header is set to false. + # See https://github.com/ossrs/srs/issues/939#issuecomment-1348740526 + # TODO: Only support HTTP-FLV stream right now. + # Overwrite by env SRS_VHOST_HTTP_REMUX_DROP_IF_NOT_MATCH for all vhosts. + # Default: on + drop_if_not_match on; + # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header audio flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts. + # Default: on + has_audio on; + # Whether stream has video track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header video flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts. + # Default: on + has_video on; + # Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If + # guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream + # is not regular. If not guessing, use the configured default value has_audio and has_video. + # For HTTP-FLV, enable guessing for av header flag, because FLV can't change the header. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, ignore guessing because TS refresh the PMT when codec changed. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts. + # Default: on + guess_has_av on; + # the stream mount for rtmp to remux to live streaming. + # typical mount to [vhost]/[app]/[stream].flv + # the variables: + # [vhost] current vhost for http live stream. + # [app] current app for http live stream. + # [stream] current stream for http live stream. + # @remark the [vhost] is optional, used to mount at specified vhost. + # the extension: + # .flv mount http live flv stream, use default gop cache. + # .ts mount http live ts stream, use default gop cache. + # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. + # .aac mount http live aac stream, ignore video and audio aac codec required. + # for example: + # mount to [vhost]/[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # mount to /[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # or by http://192.168.1.173:8080/live/livestream.flv + # mount to [vhost]/[app]/[stream].mp3 + # access by http://ossrs.net:8080/live/livestream.mp3 + # mount to [vhost]/[app]/[stream].aac + # access by http://ossrs.net:8080/live/livestream.aac + # mount to [vhost]/[app]/[stream].ts + # access by http://ossrs.net:8080/live/livestream.ts + # @remark the port of http is specified by http_server section. + # Overwrite by env SRS_VHOST_HTTP_REMUX_MOUNT for all vhosts. + # default: [vhost]/[app]/[stream].flv + mount [vhost]/[app]/[stream].flv; + } +} +``` + +> Note: These settings are only for playing HLS. For streaming settings, please follow your protocol, like referring to [RTMP](./rtmp.md#config), [SRT](./srt.md#config), or [WebRTC](./webrtc.md#config) streaming configurations. + +The important settings are explained below: + +* `has_audio`: If there is an audio stream or not. If your stream doesn't have audio, set this to `off`. Otherwise, the player might wait for audio. +* `has_video`: If there is a video stream or not. If your stream doesn't have video, set this to `off`. Otherwise, the player might wait for video. + +## Cluster + +SRS supports HTTP-FLV cluster distribution, which can handle a large number of viewing clients. Please refer to [HTTP-FLV Cluster](./sample-http-flv-cluster.md) and [Edge](./edge.md). + +## Crossdomain + +SRS supports HTTP CORS by default. Please refer to [HTTP CORS](./http-server.md#crossdomain). + +## Websocket FLV +You can convert HTTP-FLV to WebSocket-FLV stream. Please refer to [videojs-flow](https://github.com/winlinvip/videojs-flow). + +For HTTP to WebSocket conversion, please refer to [mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go). + +## HTTP FLV VOD Stream + +For HTTP FLV on-demand streaming, please refer to: [v4_CN_FlvVodStream](./flv-vod-stream.md). + +## HTTP and HTTPS Proxy + +SRS works well with HTTP/HTTPS proxies such as [Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), [HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), etc. For detailed configuration, please refer to [#2881](https://github.com/ossrs/srs/issues/2881). + +## HTTPS FLV Live Stream + +SRS supports converting RTMP streams to HTTPS FLV streams. When publishing RTMP streams, a corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTPS FLV file, and the RTMP stream is converted to FLV for distribution. + +Please refer to [HTTPS Server](./http-server.md#https-server) or the `conf/https.flv.live.conf` configuration file. + +## HTTP TS Live Stream + +SRS supports converting RTMP streams to HTTP TS streams. When publishing RTMP streams, a corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTP TS file, and the RTMP stream is converted to TS for distribution. + +Please refer to the `conf/http.ts.live.conf` configuration file. + +## HTTP Mp3 Live Stream + +SRS supports discarding video from RTMP streams and converting audio streams to MP3 format. A corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTP MP3 file, and the RTMP stream is converted to MP3 for distribution. + +Please refer to the `conf/http.mp3.live.conf` configuration file. + +## HTTP Aac Live Stream + +SRS supports discarding video from RTMP streams and converting audio streams to AAC format. A corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTP AAC file, and the RTMP stream is converted to AAC for distribution. + +Please refer to the `conf/http.aac.live.conf` configuration file. + +## Why HTTP FLV + +Why use HTTP FLV? HTTP FLV streaming is becoming more popular. The main advantages are: + +1. In the field of real-time Internet streaming media, RTMP is still dominant. HTTP-FLV has the same latency as RTMP, so it can meet latency requirements. +2. Firewall penetration: Many firewalls block RTMP but not HTTP, so HTTP FLV is less likely to have strange issues. +3. Scheduling: RTMP has a 302 feature, but it's only supported in the player's ActionScript. HTTP FLV supports 302, making it easier for CDNs to correct DNS errors. +4. Fault tolerance: SRS's HTTP FLV can have multiple sources, just like RTMP, supporting multi-level hot backup. +5. Universality: Flash can play both RTMP and HTTP FLV. Custom apps and mainstream players also support HTTP FLV playback. +6. Simplicity: FLV is the simplest streaming media encapsulation, and HTTP is the most widely used protocol. Combining these two makes maintenance much easier than RTMP. + +![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/en/v6/flv) diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started-build.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started-build.md index 55d11d9a..31af36f0 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started-build.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started-build.md @@ -181,7 +181,7 @@ CANDIDATE="192.168.1.10" > Remark: Please use your HTTPS key and cert file, please read > **[HTTPS API](./http-api.md#https-api)** > and **[HTTPS Callback](./http-callback.md#https-callback)** -> and **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> and **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > however HTTPS proxy also works perfect with SRS such as Nginx. Push stream to SRS by [WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started.md index ba73f355..9788397c 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/getting-started.md @@ -129,7 +129,7 @@ docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 1990:1990 -p 8088: > Remark: Please use your HTTPS key and cert file, please read > **[HTTPS API](./http-api.md#https-api)** > and **[HTTPS Callback](./http-callback.md#https-callback)** -> and **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> and **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > however HTTPS proxy also works perfect with SRS such as Nginx. Push stream to SRS by [WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/hls.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/hls.md index 90ad1406..12dec02e 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/hls.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/hls.md @@ -46,7 +46,7 @@ ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream Open the following page to play the stream (if SRS is not on your local machine, replace localhost with the server IP): -* HLS (by [VLC](https://www.videolan.org/)): `http://localhost:8080/live/livestream.m3u8` +* HLS by SRS player: [http://localhost:8080/live/livestream.m3u8](http://localhost:8080/players/srs_player.html?stream=livestream.m3u8) > Note: Please wait about 10 seconds before playing the stream, otherwise it will fail, as it takes some time to generate the first segment. @@ -260,6 +260,8 @@ vhost __defaultVhost__ { } ``` +> Note: These settings are only for playing HLS. For streaming settings, please follow your protocol, like referring to [RTMP](./rtmp.md#config), [SRT](./srt.md#config), or [WebRTC](./webrtc.md#config) streaming configurations. + Here are the main settings: * enabled: Turn HLS on/off, default is off. * hls_fragment: Seconds, specify the minimum length of ts slices. For the actual length of ts files, please refer to the detailed description of [HLS TS Duration](#hls-ts-duration). @@ -409,7 +411,7 @@ vhost __defaultVhost__ { Of course, you can't reduce it too much, as it may cause insufficient buffering for the player or skipping when the player's network is poor, possibly resulting in playback failure. The lower the latency, the higher the chance of buffering. HLS latency cannot be less than 5 seconds, especially considering CDN and player compatibility. -If you need latency within 5 seconds, consider using protocols like [HTTP-FLV](./sample-http-flv.md), [SRT](./srt.md), or [WebRTC](./webrtc.md). +If you need latency within 5 seconds, consider using protocols like [HTTP-FLV](./flv.md), [SRT](./srt.md), or [WebRTC](./webrtc.md). ## ON HLS Notify diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-api.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-api.md index 98b74e0b..1d169c49 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-api.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-api.md @@ -257,7 +257,7 @@ http_api { > Remark: Please use your HTTPS key and cert file. -> Note: To enable the HTTPS live streaming, please read [HTTPS FLV Live Stream](./delivery-http-flv.md#https-flv-live-stream) +> Note: To enable the HTTPS live streaming, please read [HTTPS FLV Live Stream](./flv.md#https-flv-live-stream) ## HTTP and HTTPS Proxy diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-server.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-server.md index 8c7d6b11..7b3f4886 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-server.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/http-server.md @@ -94,6 +94,50 @@ Remark: The `http_stream` of SRS1 renamed to `http_server` in SRS2, which specif Remark: The `http` of vhost of SRS1 renamed to `http_static`, similar to global `http_server` for HTTP static files delivery. While the `http_remux` introduced in SRS2 is dynamic remux RTMP to HTTP Live FLV/Mp3/Aac/HLS/Hds/MPEG-DASH stream. +## HTTPS Server + +SRS supports HTTPS, just enable it in the configuration. By default, it uses a sub-signed certificate. If you need +to use a CA-issued certificate, please replace the relevant files. The related configuration is as follows: + +```bash +http_server { + https { + # Whether enable HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_ENABLED + # default: off + enabled on; + # The listen endpoint for HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_LISTEN + # default: 8088 + listen 8088; + # The SSL private key file, generated by: + # openssl genrsa -out server.key 2048 + # Overwrite by env SRS_HTTP_SERVER_HTTPS_KEY + # default: ./conf/server.key + key ./conf/server.key; + # The SSL public cert file, generated by: + # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" + # Overwrite by env SRS_HTTP_SERVER_HTTPS_CERT + # default: ./conf/server.crt + cert ./conf/server.crt; + } +} +``` + +## Crossdomain + +SRS has CORS (Cross-Origin Resource Sharing) support enabled by default. The related configuration is as follows: + +```bash +http_server { + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +``` + ## MIME Only some MIME is supported: diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/resource.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/resource.md index 5acc6a7a..6f5b0e7d 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/resource.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/resource.md @@ -15,7 +15,7 @@ The ports used by SRS, kernel services: * `tcp://1935`, for [RTMP live streaming server](./rtmp.md). * `tcp://1985`, HTTP API server, for [HTTP-API](./http-api.md), [WebRTC](./webrtc.md), etc. -* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./sample-http-flv.md), [HLS](./hls.md) as such. +* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./flv.md), [HLS](./hls.md) as such. * `udp://8000`, [WebRTC Media](./webrtc.md) server. For optional HTTPS services, which might be provided by other web servers: diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md index c81d1253..6cfaf853 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md @@ -9,7 +9,7 @@ hide_table_of_contents: false There are two major methods to deliver video over internet, Live and WebRTC. -* Live streaming: [HLS](./hls.md), [RTMP](./rtmp.md) and [HTTP-FLV](./delivery-http-flv.md) for entertainment. +* Live streaming: [HLS](./hls.md), [RTMP](./rtmp.md) and [HTTP-FLV](./flv.md) for entertainment. * WebRTC: [RTC](./webrtc.md), for communication. Ignore other delivery protocol, which is not used on internet: diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp.md index 0c8a9d0d..5004ac2a 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/rtmp.md @@ -272,7 +272,7 @@ If want to convert RTMP to HLS, please see [HLS](./hls.md). ## Converting RTMP to HTTP-FLV -If want to convert RTMP to HTTP-FLV or HTTP-TS, please see [HTTP-FLV](./sample-http-flv.md). +If want to convert RTMP to HTTP-FLV or HTTP-TS, please see [HTTP-FLV](./flv.md). ## Converting RTMP to WebRTC diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md index f6884771..9bb7a804 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md @@ -7,7 +7,7 @@ hide_table_of_contents: false # HTTP FLV Cluster Example -About the HTTP FLV cluster of SRS, read [HTTP FLV](./delivery-http-flv.md#about-http-flv) +About the HTTP FLV cluster of SRS, read [HTTP FLV](./flv.md#about-http-flv) How to use multiple process for HTTP FLV? Please read [Reuse Port](./reuse-port.md) for detail. @@ -40,7 +40,7 @@ For detail, read [Build](./install.md) ## Step 3, config origin SRS -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Save bellow as config, or use `conf/http.flv.live.conf`: @@ -64,7 +64,7 @@ vhost __defaultVhost__ { ## Step 4, config edge SRS -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Save bellow as config, or use `conf/http.flv.live.edge1.conf` or `conf/http.flv.live.edge2.conf`: @@ -92,7 +92,7 @@ vhost __defaultVhost__ { ## Step 5, start SRS -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) ```bash ./objs/srs -c conf/http.flv.live.conf & @@ -102,7 +102,7 @@ For detail, read [HTTP FLV](./delivery-http-flv.md) ## Step 6, start Encoder -For detail, read read [HTTP FLV](./delivery-http-flv.md) +For detail, read read [HTTP FLV](./flv.md) Use FFMPEG to publish stream: @@ -136,7 +136,7 @@ The streams on SRS edge2: ## Step 7, play RTMP -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Origin RTMP url is: `rtmp://192.168.1.170:1935/live/livestream`, User can use vlc to play the RTMP stream. @@ -148,7 +148,7 @@ Note: Please replace all ip 192.168.1.170 to your server ip. ## Step 8, play HTTP FLV -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Origin HTTP FLV url: `http://192.168.1.170:8080/live/livestream.flv`, User can use vlc to play the HLS stream. Or, use online SRS player(you must input the flv url): [srs-player](https://ossrs.net/players/srs_player.html) diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md index 35202de6..fe721df1 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md @@ -7,110 +7,7 @@ hide_table_of_contents: false # HTTP FLV deploy example -About the HTTP FLV of SRS, read [HTTP FLV](./delivery-http-flv.md#about-http-flv) - -How to use multiple process for HTTP FLV? Please read [Reuse Port](./reuse-port.md) for detail. - -**Suppose the server ip is 192.168.1.170** - -## Step 1, get SRS - -For detail, read [GIT](./git.md) - -```bash -git clone https://github.com/ossrs/srs -cd srs/trunk -``` - -Or update the exists code: - -```bash -git pull -``` - -## Step 2, build SRS - -For detail, read [Build](./install.md) - -```bash -./configure && make -``` - -## Step 3, config SRS - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -Save bellow as config, or use `conf/http.flv.live.conf`: - -```bash -# conf/http.flv.live.conf -listen 1935; -max_connections 1000; -http_server { - enabled on; - listen 8080; - dir ./objs/nginx/html; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - hstrs on; - } -} -``` - -## Step 4, start SRS - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -```bash -./objs/srs -c conf/http.flv.live.conf -``` - -## Step 5, start Encoder - -For detail, read read [HTTP FLV](./delivery-http-flv.md) - -Use FFMPEG to publish stream: - -```bash - for((;;)); do \ - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.flv \ - -c copy \ - -f flv rtmp://192.168.1.170/live/livestream; \ - sleep 1; \ - done -``` - -Or use FMLE to publish: - -```bash -FMS URL: rtmp://192.168.1.170/live -Stream: livestream -``` - -The streams on SRS: -* RTMP: `rtmp://192.168.1.170/live/livestream` -* HTTP FLV: `http://192.168.1.170:8080/live/livestream.flv` - -## Step 6, play RTMP - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -RTMP url is: `rtmp://192.168.1.170:1935/live/livestream`, User can use vlc to play the RTMP stream. - -Note: Please replace all ip 192.168.1.170 to your server ip. - -## Step 7, play HTTP FLV - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -HTTP FLV url: `http://192.168.1.170:8080/live/livestream.flv`, User can use vlc to play the HLS stream. Or, use online SRS player(you must input the flv url): [srs-player](https://ossrs.net/players/srs_player.html) - -Note: Please replace all ip 192.168.1.170 to your server ip. - -Winlin 2014.11 +Migrated to [HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.io&path=/lts/doc/en/v6/sample-http-flv) diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/srt.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/srt.md index f0991b60..156fa8a7 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/srt.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/srt.md @@ -9,6 +9,10 @@ hide_table_of_contents: false See [SRT](./sample-srt.md). +## Config + +On the way. + ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/en/v6/srt) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md index 37a8b660..cf358762 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/delivery-http-flv.md @@ -7,263 +7,7 @@ hide_table_of_contents: false # HTTP FLV 分发 -## HTTP FLV Live Stream - -SRS支持将RTMP流转封装为HTTP flv流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置),用户在访问这个http flv文件时,从rtmp流转封装为flv分发给用户。 - -分发HTTP FLV直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTPS FLV Live Stream - -SRS支持将RTMP流转封装为HTTPS flv流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置),用户在访问这个https flv文件时,从rtmp流转封装为flv分发给用户。 - -分发HTTPS FLV直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; - https { - enabled on; - listen 8088; - key ./conf/server.key; - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -> Remark: 请使用你的证书文件,代替上面配置中的key和cert。 - -> Note: 若需要开启HTTPS API,请参考[HTTPS API](./http-api.md#https-api) - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP and HTTPS Proxy - -SRS可以和HTTP/HTTPS代理一起工作得很好,比如[Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), -[HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), -等等。详细配置请参考 [#2881](https://github.com/ossrs/srs/issues/2881)。 - -## HTTP TS Live Stream - -SRS支持将RTMP流转封装为HTTP ts流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置),用户在访问这个http ts文件时,从rtmp流转封装为ts分发给用户。 - -分发HTTP TS直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].ts; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP Mp3 Live Stream - -SRS支持将rtmp流中的视频丢弃,将音频流转封装为mp3格式,在SRS的http模块中挂载对应的http地址(根据配置),用户在访问这个http mp3文件时,从rtmp转封装为mp3分发给用户。 - -分发HTTP mp3直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].mp3; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP Aac Live Stream - -SRS支持将rtmp流中的视频丢弃,将音频流转封装为aac格式,在SRS的http模块中挂载对应的http地址(根据配置),用户在访问这个http aac文件时,从rtmp转封装为aac分发给用户。 - -分发HTTP aac直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].aac; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP Live Stream Config - -HTTP Flv/Mp3/Aac Live Stream的配置如下,更改不同的扩展名即可以不同方式分发: - -``` -http_server { - # whether http streaming service is enabled. - # default: off - enabled on; - # the http streaming listen entry is <[ip:]port> - # for example, 192.168.1.100:8080 - # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 - # @remark, if use lower port, for instance 80, user must start srs by root. - # default: 8080 - listen 8080; - # For https_server or HTTPS Streaming. - https { - # Whether enable HTTPS Streaming. - # default: off - enabled on; - # The listen endpoint for HTTPS Streaming. - # default: 8088 - listen 8088; - # The SSL private key file, generated by: - # openssl genrsa -out server.key 2048 - # default: ./conf/server.key - key ./conf/server.key; - # The SSL public cert file, generated by: - # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" - # default: ./conf/server.crt - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - # http flv/mp3/aac/ts stream vhost specified config - http_remux { - # whether enable the http live streaming service for vhost. - # default: off - enabled on; - # the fast cache for audio stream(mp3/aac), - # to cache more audio and send to client in a time to make android(weixin) happy. - # @remark the flv/ts stream ignore it - # @remark 0 to disable fast cache for http audio stream. - # default: 0 - fast_cache 30; - # the stream mout for rtmp to remux to live streaming. - # typical mount to [vhost]/[app]/[stream].flv - # the variables: - # [vhost] current vhost for http live stream. - # [app] current app for http live stream. - # [stream] current stream for http live stream. - # @remark the [vhost] is optional, used to mount at specified vhost. - # the extension: - # .flv mount http live flv stream, use default gop cache. - # .ts mount http live ts stream, use default gop cache. - # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. - # .aac mount http live aac stream, ignore video and audio aac codec required. - # for example: - # mount to [vhost]/[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # mount to /[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # or by http://192.168.1.173:8080/live/livestream.flv - # mount to [vhost]/[app]/[stream].mp3 - # access by http://ossrs.net:8080/live/livestream.mp3 - # mount to [vhost]/[app]/[stream].aac - # access by http://ossrs.net:8080/live/livestream.aac - # mount to [vhost]/[app]/[stream].ts - # access by http://ossrs.net:8080/live/livestream.ts - # @remark the port of http is specified by http_server section. - # default: [vhost]/[app]/[stream].flv - mount [vhost]/[app]/[stream].flv; - } -} -``` - -备注:若需要同时分发不同的http live stream,可以使用forward到其他vhost,不同的vhost配置不同的http live stream。 - -备注:HTTP服务器配置,参考[HTTP Server](./http-server.md#config) - -## About HTTP FLV - -这一节详细解释HTTP FLV的背景。 - -SRS的HTTP FLV边缘只能使用单进程,如何做到多进程呢?请参考[Reuse Port](./reuse-port.md) - -### What is HTTP FLV - -所有的HTTP FLV流都是一个HTTP FLV地址,譬如:`http://ossrs.net:8081/live/livestream.flv`,但是,流的形式却至少有三种: - -1. FLV文件,渐进式HTTP流。放一个文件到nginx目录,可以访问下载在播放器播放,这是HTTP FLV文件,也就是渐进式下载流。所谓渐进式下载,也就是用户观看时无法从未下载的地方开始看。 -1. FLV伪流。一般说的HTTP FLV,比上面的渐进式流高级一点,譬如,一个120分钟的电影,作为渐进式流播放时,用户需要从60分钟开始看,如何支持呢?因为nginx是当做文件下载的,无法直接跳转到第60分钟(nginx也不知道60分钟对应的字节偏移是多少呀)。后来有人就支持这种跳着播放,通过指定时间服务器从指定的位置开始给流,这种支持flv?start=,就是http flv的伪流,本质上还是点播流。 -1. FLV直播流。SRS所指的HTTP FLV流,是严格意义上的直播流,有RTMP的所有特征,譬如集群、低延迟、热备、GOP cache,而且有HTTP的优势,譬如302、穿墙、通用。由于SRS内部实现了HTTP服务器,所以SRS是在边缘将RTMP流转换成HTTP流,SRS集群内部还是使用RTMP分发。当前唯一将RTMP和HTTP协议都解析的服务器,目前只有SRS和nginx-rtmp,可惜nginx-rtmp没有实现这个流。 - -用一句话概括,SRS的HTTP FLV就是增强的RTMP,真正的实时流媒体分发。 - -### Confuse HTTP FLV - -SRS的HTTP FLV容易和下面的几种分发方式混淆: - -1. RTMPT:这个实际上是最接近SRS的HTTP FLV的概念的。但是从本质上来讲,rtmpt是基于HTTP的RTMP,所以还是RTMP而不是FLV。 -2. HDL/HFL:国内一些厂家的HXX流,就是FLV流,主要和SRS的区别在于服务器集群内部SRS还是走RTMP,所以延迟可能会有很大差异。SRS的HTTP FLV和RTMP延迟一样,0.8-3秒。 -3. HDS:这个差的太远了,不是一个东西。HDS和HLS像,但是HTTP FLV和他们两个都完全不像。 - -### Why HTTP FLV - -为何要整个HTTP FLV出来呢?当下HTTP FLV流正大行其道。主要的优势在于: - -1. 互联网流媒体实时领域,还是RTMP。HTTP-FLV和RTMP的延迟一样,因此可以满足延迟的要求。 -1. 穿墙:很多防火墙会墙掉RTMP,但是不会墙HTTP,因此HTTP FLV出现奇怪问题的概率很小。 -1. 调度:RTMP也有个302,可惜是播放器as中支持的,HTTP FLV流就支持302方便CDN纠正DNS的错误。 -1. 容错:SRS的HTTP FLV回源时可以回多个,和RTMP一样,可以支持多级热备。 -1. 通用:Flash可以播RTMP,也可以播HTTP FLV。自己做的APP,也都能支持。主流播放器也都支持http flv的播放。 -1. 简单:FLV是最简单的流媒体封装,HTTP是最广泛的协议,这两个到一起维护性很高,比RTMP简单多了。 - -## Sample - -配置实例参考:https://github.com/ossrs/srs/issues/293#issuecomment-70449126 - -一步一步配置HTTP FLV: [Sample](./sample-http-flv.md) - -## Websocket FLV - -可以将HTTP-FLV转成WebSocket-FLV流,这样就可以使用[MSE(flv.js)](https://github.com/Bilibili/flv.js#features)播放了,参考[videojs-flow](https://github.com/winlinvip/videojs-flow)。 - -关于HTTP转WebSocket参考[mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go)。 - -## HTTP FLV VOD Stream - -关于HTTP flv 点播流,参考:[v4_CN_FlvVodStream](./flv-vod-stream.md) - -Winlin 2015.1 - -[go-sharp]: https://github.com/ossrs/go-sharp +迁移到了[HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v6/delivery-http-flv) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/flv.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/flv.md index 2d59a0d8..33eccbac 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/flv.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/flv.md @@ -7,8 +7,207 @@ hide_table_of_contents: false # HTTP-FLV -See [HTTP-FLV](./delivery-http-flv.md). +HTTP-FLV是一种直播流协议,有时候也简称FLV,是在HTTP连接上传输FLV格式的直播流。 -![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v6/flv) +和文件下载不同的是,直播流的长度是无限长,或者不确定长度,因此一般是基于HTTP Chunked协议实现。和HTTP-FLV类似的,还有HTTP-TS, +或者HTTP-MP3,TS主要应用于广播电视领域,MP3主要应用于音频领域。 + +和HLS不同的是,HLS本质上就是HTTP文件下载,而HTTP-FLV本质上是流传输。CDN对于HTTP文件下载的支持很完善,因此HLS的兼容性比HTTP-FLV +要好很多;同样HTTP-FLV的延迟比HLS要低很多,基本上可以做到3的5秒左右延迟,而HLS的延迟一般是8到10秒以上。 + +从协议实现上看,RTMP和HTTP-FLV几乎一样,RTMP是基于TCP协议,而HTTP-FLV基于HTTP也是TCP协议,因此两者的特点也非常类似。一般推流和 +流的生产使用RTMP,主要是因为流的生产设备都支持RTMP;而流的播放和消费端采用HTTP-FLV或这HLS,因为播放设备支持HTTP更完善。 + +HTTP-FLV的兼容性很好,除了iOS原生浏览器不支持,其他平台和浏览器都支持了,参考[MSE](https://caniuse.com/?search=mse)。 +若需要支持iOS浏览器,你可以考虑使用HLS或者使用WASM;注意一般iOS的Native应用,可以选择使用ijkplayer播放器。 + +## Usage + +SRS支持HTTP-FLV分发,可以用[docker](./getting-started.md)或者[从源码编译](./getting-started-build.md): + +```bash +docker run --rm -it -p 1935:1935 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5 \ + ./objs/srs -c conf/http.flv.live.conf +``` + +使用 [FFmpeg(点击下载)](https://ffmpeg.org/download.html) 或 [OBS(点击下载)](https://obsproject.com/download) 推流: + +```bash +ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream +``` + +打开下面的页面播放流(若SRS不在本机,请将localhost更换成服务器IP): + +* HLS by SRS player: [http://localhost:8080/live/livestream.flv](http://localhost:8080/players/srs_player.html) + +## Config + +HTTP-FLV相关的配置如下: + +```bash +http_server { + # whether http streaming service is enabled. + # Overwrite by env SRS_HTTP_SERVER_ENABLED + # default: off + enabled on; + # the http streaming listen entry is <[ip:]port> + # for example, 192.168.1.100:8080 + # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 + # @remark, if use lower port, for instance 80, user must start srs by root. + # Overwrite by env SRS_HTTP_SERVER_LISTEN + # default: 8080 + listen 8080; + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +vhost __defaultVhost__ { + # http flv/mp3/aac/ts stream vhost specified config + http_remux { + # whether enable the http live streaming service for vhost. + # Overwrite by env SRS_VHOST_HTTP_REMUX_ENABLED for all vhosts. + # default: off + enabled on; + # the fast cache for audio stream(mp3/aac), + # to cache more audio and send to client in a time to make android(weixin) happy. + # @remark the flv/ts stream ignore it + # @remark 0 to disable fast cache for http audio stream. + # Overwrite by env SRS_VHOST_HTTP_REMUX_FAST_CACHE for all vhosts. + # default: 0 + fast_cache 30; + # Whether drop packet if not match header. For example, there is has_audio and has video flag in FLV header, if + # this is set to on and has_audio is false, then SRS will drop audio packets when got audio packets. Generally + # it should work, but sometimes you might need SRS to keep packets even when FLV header is set to false. + # See https://github.com/ossrs/srs/issues/939#issuecomment-1348740526 + # TODO: Only support HTTP-FLV stream right now. + # Overwrite by env SRS_VHOST_HTTP_REMUX_DROP_IF_NOT_MATCH for all vhosts. + # Default: on + drop_if_not_match on; + # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header audio flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts. + # Default: on + has_audio on; + # Whether stream has video track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header video flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts. + # Default: on + has_video on; + # Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If + # guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream + # is not regular. If not guessing, use the configured default value has_audio and has_video. + # For HTTP-FLV, enable guessing for av header flag, because FLV can't change the header. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, ignore guessing because TS refresh the PMT when codec changed. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts. + # Default: on + guess_has_av on; + # the stream mount for rtmp to remux to live streaming. + # typical mount to [vhost]/[app]/[stream].flv + # the variables: + # [vhost] current vhost for http live stream. + # [app] current app for http live stream. + # [stream] current stream for http live stream. + # @remark the [vhost] is optional, used to mount at specified vhost. + # the extension: + # .flv mount http live flv stream, use default gop cache. + # .ts mount http live ts stream, use default gop cache. + # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. + # .aac mount http live aac stream, ignore video and audio aac codec required. + # for example: + # mount to [vhost]/[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # mount to /[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # or by http://192.168.1.173:8080/live/livestream.flv + # mount to [vhost]/[app]/[stream].mp3 + # access by http://ossrs.net:8080/live/livestream.mp3 + # mount to [vhost]/[app]/[stream].aac + # access by http://ossrs.net:8080/live/livestream.aac + # mount to [vhost]/[app]/[stream].ts + # access by http://ossrs.net:8080/live/livestream.ts + # @remark the port of http is specified by http_server section. + # Overwrite by env SRS_VHOST_HTTP_REMUX_MOUNT for all vhosts. + # default: [vhost]/[app]/[stream].flv + mount [vhost]/[app]/[stream].flv; + } +} +``` + +> Note: 这些配置只是播放HTTP-FLV相关的配置,推流的配置请根据你的协议,比如参考[RTMP](./rtmp.md#config)或者[SRT](./srt.md#config)或者[WebRTC](./webrtc.md#config)的推流配置。 + +关键配置说明如下: + +* `has_audio` 是否有音频流,如果你的流没有音频,则需要配置这个为`off`,否则播放器可能会等待音频。 +* `has_video` 是否有视频流,如果你的流没有视频,则需要配置这个为`off`,否则播放器可能会等待视频。 + +## Cluster + +SRS支持HTTP-FLV集群分发,可以支持海量的观看客户端,参考[HTTP-FLV Cluster](./sample-http-flv-cluster.md)和[Edge](./edge.md) + +## Crossdomain + +SRS默认支持了HTTP CORS,请参考[HTTP CORS](./http-server.md#crossdomain) + +## Websocket FLV +可以将HTTP-FLV转成WebSocket-FLV流,参考[videojs-flow](https://github.com/winlinvip/videojs-flow)。 + +关于HTTP转WebSocket参考[mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go)。 + +## HTTP FLV VOD Stream + +关于HTTP flv 点播流,参考:[v4_CN_FlvVodStream](./flv-vod-stream.md) + +## HTTP and HTTPS Proxy + +SRS可以和HTTP/HTTPS代理一起工作得很好,比如[Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), +[HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), +等等。详细配置请参考 [#2881](https://github.com/ossrs/srs/issues/2881)。 + +## HTTPS FLV Live Stream + +SRS支持将RTMP流转封装为HTTPS flv流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置), +用户在访问这个https flv文件时,从rtmp流转封装为flv分发给用户。 + +具体请参考[HTTPS Server](./http-server.md#https-server),或者`conf/https.flv.live.conf`配置文件。 + +## HTTP TS Live Stream + +SRS支持将RTMP流转封装为HTTP ts流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置), +用户在访问这个http ts文件时,从rtmp流转封装为ts分发给用户。 + +具体请参考`conf/http.ts.live.conf`配置文件。 + +## HTTP Mp3 Live Stream + +SRS支持将rtmp流中的视频丢弃,将音频流转封装为mp3格式,在SRS的http模块中挂载对应的http地址(根据配置), +用户在访问这个http mp3文件时,从rtmp转封装为mp3分发给用户。 + +具体请参考`conf/http.mp3.live.conf`配置文件。 + +## HTTP Aac Live Stream + +SRS支持将rtmp流中的视频丢弃,将音频流转封装为aac格式,在SRS的http模块中挂载对应的http地址(根据配置), +用户在访问这个http aac文件时,从rtmp转封装为aac分发给用户。 + +具体请参考`conf/http.aac.live.conf`配置文件。 + +## Why HTTP FLV + +为何要整个HTTP FLV出来呢?当下HTTP FLV流正大行其道。主要的优势在于: + +1. 互联网流媒体实时领域,还是RTMP。HTTP-FLV和RTMP的延迟一样,因此可以满足延迟的要求。 +1. 穿墙:很多防火墙会墙掉RTMP,但是不会墙HTTP,因此HTTP FLV出现奇怪问题的概率很小。 +1. 调度:RTMP也有个302,可惜是播放器as中支持的,HTTP FLV流就支持302方便CDN纠正DNS的错误。 +1. 容错:SRS的HTTP FLV回源时可以回多个,和RTMP一样,可以支持多级热备。 +1. 通用:Flash可以播RTMP,也可以播HTTP FLV。自己做的APP,也都能支持。主流播放器也都支持http flv的播放。 +1. 简单:FLV是最简单的流媒体封装,HTTP是最广泛的协议,这两个到一起维护性很高,比RTMP简单多了。 + +![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v6/flv) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started-build.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started-build.md index b82b0ca9..507041e5 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started-build.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started-build.md @@ -201,7 +201,7 @@ CANDIDATE="192.168.1.10" > Remark: 请使用你的证书文件,代替上面配置中的key和cert,请参考 > **[HTTPS API](./http-api.md#https-api)** > 以及 **[HTTPS Callback](./http-callback.md#https-callback)** -> 以及 **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> 以及 **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > 当然了HTTPS的反向代理也能和SRS工作很好,比如Nginx代理到SRS。 使用WebRTC推流到SRS:[WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started.md index eac23101..dcdd8c2f 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/getting-started.md @@ -131,7 +131,7 @@ docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 1990:1990 -p 8088: > Remark: 请使用你的证书文件,代替上面配置中的key和cert,请参考 > **[HTTPS API](./http-api.md#https-api)** > 以及 **[HTTPS Callback](./http-callback.md#https-callback)** -> 以及 **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> 以及 **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > 当然了HTTPS的反向代理也能和SRS工作很好,比如Nginx代理到SRS。 使用WebRTC推流到SRS:[WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/hls.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/hls.md index 2c88605a..d7bf22fd 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/hls.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/hls.md @@ -15,7 +15,7 @@ HLS是适配性和兼容性最好的流媒体协议,没有之一。这个世 当然了,HLS并不是没有毛病,它的问题就是延迟比较高,一般在30秒左右。虽然经过优化可以到8秒左右,但是不同播放器的行为可能不一致。 对比起其他流媒体协议,优化后的延迟也很高。因此如果你特别在意直播的延迟,那么请使用[RTMP](./rtmp.md)或者 -[HTTP-FLV](./sample-http-flv.md)协议。 +[HTTP-FLV](./flv.md)协议。 HLS主要的应用场景包括: * 跨平台:PC主要的直播方案是HLS,可用hls.js库播放HLS。所以实际上如果选一种协议能跨PC/Android/IOS,那就是HLS。 @@ -43,7 +43,7 @@ ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream 打开下面的页面播放流(若SRS不在本机,请将localhost更换成服务器IP): -* HLS (by [VLC](https://www.videolan.org/)): `http://localhost:8080/live/livestream.m3u8` +* HLS by SRS player: [http://localhost:8080/live/livestream.m3u8](http://localhost:8080/players/srs_player.html?stream=livestream.m3u8) > Note: 请等待大约10秒左右,再播放流,否则会播放失败,因为生成第一个切片需要一些时间。 @@ -257,6 +257,8 @@ vhost __defaultVhost__ { } ``` +> Note: 这些配置只是播放HLS相关的配置,推流的配置请根据你的协议,比如参考[RTMP](./rtmp.md#config)或者[SRT](./srt.md#config)或者[WebRTC](./webrtc.md#config)的推流配置。 + 主要配置项如下: * enabled:是否开启HLS,on/off,默认off。 * hls_fragment:秒,指定ts切片的最小长度。实际上ts文件的长度请参考[HLS TS Duration](#hls-ts-duration)的详细说明。 @@ -414,7 +416,7 @@ vhost __defaultVhost__ { 当然,也不能减少得非常少,容易造成播放器缓冲不足,或者播放器网络不佳时跳片,可能会有播放失败。 延迟越低,卡顿概率越高,HLS的延迟并不能做到5秒之内,特别是考虑CDN和播放器的适配情况。 -如果需要5秒之内的延迟,建议使用[HTTP-FLV](./sample-http-flv.md)或者[SRT](./srt.md)或者[WebRTC](./webrtc.md)等协议。 +如果需要5秒之内的延迟,建议使用[HTTP-FLV](./flv.md)或者[SRT](./srt.md)或者[WebRTC](./webrtc.md)等协议。 ## ON HLS Notify diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-api.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-api.md index 7dbf3063..5e1cecdb 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-api.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-api.md @@ -278,7 +278,7 @@ http_api { > Remark: 请使用你的证书文件,代替上面配置中的key和cert。 -> Note: 若需要开启HTTPS直播流,请参考[HTTPS FLV Live Stream](./delivery-http-flv.md#https-flv-live-stream) +> Note: 若需要开启HTTPS直播流,请参考[HTTPS FLV Live Stream](./flv.md#https-flv-live-stream) ## HTTP and HTTPS Proxy diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-server.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-server.md index 2a3f720c..f600bc97 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-server.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/http-server.md @@ -53,18 +53,51 @@ srs会一如既往的保持最简单,http的代码不会有多少行,功能 # need to open the feature http of vhost. http_server { # whether http streaming service is enabled. + # Overwrite by env SRS_HTTP_SERVER_ENABLED # default: off - enabled on; - # the http streaming port + enabled on; + # the http streaming listen entry is <[ip:]port> + # for example, 192.168.1.100:8080 + # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 # @remark, if use lower port, for instance 80, user must start srs by root. + # Overwrite by env SRS_HTTP_SERVER_LISTEN # default: 8080 - listen 8080; + listen 8080; # the default dir for http root. + # Overwrite by env SRS_HTTP_SERVER_DIR # default: ./objs/nginx/html - dir ./objs/nginx/html; + dir ./objs/nginx/html; + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; + # For https_server or HTTPS Streaming. + https { + # Whether enable HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_ENABLED + # default: off + enabled on; + # The listen endpoint for HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_LISTEN + # default: 8088 + listen 8088; + # The SSL private key file, generated by: + # openssl genrsa -out server.key 2048 + # Overwrite by env SRS_HTTP_SERVER_HTTPS_KEY + # default: ./conf/server.key + key ./conf/server.key; + # The SSL public cert file, generated by: + # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" + # Overwrite by env SRS_HTTP_SERVER_HTTPS_CERT + # default: ./conf/server.crt + cert ./conf/server.crt; + } } ``` +## HTTP Vhost + 同时,vhost上可以指定http配置(虚拟目录和vhost): ```bash @@ -105,6 +138,49 @@ vhost your_vhost { 注意:SRS1中vhost的`http`在SRS2改名为`http_static`,和全局的`http_server`类似用来分发静态的文件。而SRS2新增的功能`http_remux`,用来动态转封装,将RTMP流转封装为 HTTP Live FLV/Mp3/Aac/Hls/Hds/MPEG-DASH流。 +## HTTPS Server + +SRS支持HTTPS,在配置中开启即可,默认使用子签名证书,若需要使用CA颁发的证书,请替换相关的文件。相关配置如下: + +```bash +http_server { + https { + # Whether enable HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_ENABLED + # default: off + enabled on; + # The listen endpoint for HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_LISTEN + # default: 8088 + listen 8088; + # The SSL private key file, generated by: + # openssl genrsa -out server.key 2048 + # Overwrite by env SRS_HTTP_SERVER_HTTPS_KEY + # default: ./conf/server.key + key ./conf/server.key; + # The SSL public cert file, generated by: + # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" + # Overwrite by env SRS_HTTP_SERVER_HTTPS_CERT + # default: ./conf/server.crt + cert ./conf/server.crt; + } +} +``` + +## Crossdomain + +SRS默认开启了CORS跨域的支持,相关配置如下: + +```bash +http_server { + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +``` + ## MIME 支持少量的MIME,见下表。 diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/resource.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/resource.md index caf41a5d..4726ed54 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/resource.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/resource.md @@ -15,7 +15,7 @@ The ports used by SRS, kernel services: * `tcp://1935`, for [RTMP live streaming server](./rtmp.md). * `tcp://1985`, HTTP API server, for [HTTP-API](./http-api.md), [WebRTC](./webrtc.md), etc. -* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./sample-http-flv.md), [HLS](./hls.md) as such. +* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./flv.md), [HLS](./hls.md) as such. * `udp://8000`, [WebRTC Media](./webrtc.md) server. For optional HTTPS services, which might be provided by other web servers: diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md index bb991851..748f50e1 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp-pk-http.md @@ -9,7 +9,7 @@ hide_table_of_contents: false 互联网上的两种主要的分发方式:直播和WebRTC,什么时候用谁,完全决定于应用场景。 -* 直播:[HLS](./hls.md),[RTMP](./rtmp.md)和[HTTP-FLV](./delivery-http-flv.md),主要是娱乐和教育场景。 +* 直播:[HLS](./hls.md),[RTMP](./rtmp.md)和[HTTP-FLV](./flv.md),主要是娱乐和教育场景。 * WebRTC:[RTC](./webrtc.md),主要应用于通话,直播连麦,教育等场景。 还有其他的分发方式,这些分发方式不属于互联网常见和通用的方式,不予以比较: diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp.md index 587a0cac..1edfe775 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/rtmp.md @@ -268,7 +268,7 @@ vhost __defaultVhost__ { ## Converting RTMP to HTTP-FLV -如果需要将RTMP转HTTP-FLV或HTTP-TS协议,请参考[HTTP-FLV](./sample-http-flv.md). +如果需要将RTMP转HTTP-FLV或HTTP-TS协议,请参考[HTTP-FLV](./flv.md). ## Converting RTMP to WebRTC diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md index ecc79c9e..b6df4226 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv-cluster.md @@ -7,7 +7,7 @@ hide_table_of_contents: false # HTTP-FLV集群部署实例 -SRS支持HTTP FLV直播流集群分发,详细参考[HTTP FLV](./delivery-http-flv.md#about-http-flv) +SRS支持HTTP FLV直播流集群分发,详细参考[HTTP FLV](./flv.md#about-http-flv) SRS的HTTP FLV边缘只能使用单进程,如何做到多进程呢?请参考[Reuse Port](./reuse-port.md) @@ -40,7 +40,7 @@ git pull ## 第三步,编写SRS源站配置文件 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 将以下内容保存为文件,譬如`conf/http.flv.live.conf`,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。 @@ -64,7 +64,7 @@ vhost __defaultVhost__ { ## 第四步,编写SRS边缘配置文件 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 将以下内容保存为文件,譬如`conf/http.flv.live.edge1.conf`和`conf/http.flv.live.edge2.conf`,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。 @@ -92,7 +92,7 @@ vhost __defaultVhost__ { ## 第五步,启动SRS -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) ```bash ./objs/srs -c conf/http.flv.live.conf & @@ -102,7 +102,7 @@ vhost __defaultVhost__ { ## 第六步,启动推流编码器 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 使用FFMPEG命令推流: @@ -136,7 +136,7 @@ Stream: livestream ## 第七步,观看RTMP流 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 源站RTMP流地址为:`rtmp://192.168.1.170/live/livestream`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) @@ -148,7 +148,7 @@ Stream: livestream ## 第八步,观看HTTP流 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 源站HTTP FLV流地址为: `http://192.168.1.170:8080/live/livestream.flv`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md index fb6b534d..b9148861 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/sample-http-flv.md @@ -7,110 +7,7 @@ hide_table_of_contents: false # HTTP-FLV部署实例 -SRS支持HTTP FLV直播流分发,详细参考[HTTP FLV](./delivery-http-flv.md#about-http-flv) - -SRS的HTTP FLV边缘只能使用单进程,如何做到多进程呢?请参考[Reuse Port](./reuse-port.md) - -**假设服务器的IP是:192.168.1.170** - -## 第一步,获取SRS - -详细参考[GIT获取代码](./git.md) - -```bash -git clone https://github.com/ossrs/srs -cd srs/trunk -``` - -或者使用git更新已有代码: - -```bash -git pull -``` - -## 第二步,编译SRS - -详细参考[Build](./install.md) - -```bash -./configure && make -``` - -## 第三步,编写SRS配置文件 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -将以下内容保存为文件,譬如`conf/http.flv.live.conf`,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。 - -```bash -# conf/http.flv.live.conf -listen 1935; -max_connections 1000; -http_server { - enabled on; - listen 8080; - dir ./objs/nginx/html; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - hstrs on; - } -} -``` - -## 第四步,启动SRS - -详细参考[HTTP FLV](./delivery-http-flv.md) - -```bash -./objs/srs -c conf/http.flv.live.conf -``` - -## 第五步,启动推流编码器 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -使用FFMPEG命令推流: - -```bash - for((;;)); do \ - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.flv \ - -c copy \ - -f flv rtmp://192.168.1.170/live/livestream; \ - sleep 1; \ - done -``` - -或使用支持FMLE推流: - -```bash -FMS URL: rtmp://192.168.1.170/live -Stream: livestream -``` - -生成的流地址为: -* RTMP流地址为:`rtmp://192.168.1.170/live/livestream` -* HTTP FLV: `http://192.168.1.170:8080/live/livestream.flv` - -## 第六步,观看RTMP流 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -RTMP流地址为:`rtmp://192.168.1.170/live/livestream`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) - -备注:请将所有实例的IP地址192.168.1.170都换成部署的服务器IP地址。 - -## 第七步,观看FLV流 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -HTTP FLV流地址为: `http://192.168.1.170:8080/live/livestream.flv`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) - -备注:请将所有实例的IP地址192.168.1.170都换成部署的服务器IP地址。 - -Winlin 2014.4 +迁移到了[HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v6/sample-http-flv) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/srt.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/srt.md index c670e246..bed37911 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/srt.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/srt.md @@ -9,6 +9,10 @@ hide_table_of_contents: false See [SRT](./sample-srt.md). +## Config + +On the way. + ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v6/srt) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/delivery-http-flv.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/delivery-http-flv.md index 7420934a..df35afe5 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/delivery-http-flv.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/delivery-http-flv.md @@ -7,263 +7,7 @@ hide_table_of_contents: false # HTTP FLV 分发 -## HTTP FLV Live Stream - -SRS支持将RTMP流转封装为HTTP flv流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置),用户在访问这个http flv文件时,从rtmp流转封装为flv分发给用户。 - -分发HTTP FLV直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTPS FLV Live Stream - -SRS支持将RTMP流转封装为HTTPS flv流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置),用户在访问这个https flv文件时,从rtmp流转封装为flv分发给用户。 - -分发HTTPS FLV直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; - https { - enabled on; - listen 8088; - key ./conf/server.key; - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -> Remark: 请使用你的证书文件,代替上面配置中的key和cert。 - -> Note: 若需要开启HTTPS API,请参考[HTTPS API](./http-api.md#https-api) - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP and HTTPS Proxy - -SRS可以和HTTP/HTTPS代理一起工作得很好,比如[Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), -[HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), -等等。详细配置请参考 [#2881](https://github.com/ossrs/srs/issues/2881)。 - -## HTTP TS Live Stream - -SRS支持将RTMP流转封装为HTTP ts流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置),用户在访问这个http ts文件时,从rtmp流转封装为ts分发给用户。 - -分发HTTP TS直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].ts; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP Mp3 Live Stream - -SRS支持将rtmp流中的视频丢弃,将音频流转封装为mp3格式,在SRS的http模块中挂载对应的http地址(根据配置),用户在访问这个http mp3文件时,从rtmp转封装为mp3分发给用户。 - -分发HTTP mp3直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].mp3; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP Aac Live Stream - -SRS支持将rtmp流中的视频丢弃,将音频流转封装为aac格式,在SRS的http模块中挂载对应的http地址(根据配置),用户在访问这个http aac文件时,从rtmp转封装为aac分发给用户。 - -分发HTTP aac直播流的配置如下: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].aac; - } -} -``` - -配置项的详细信息参考下面的[配置章节](./delivery-http-flv.md#http-live-stream-config)的说明。 - -## HTTP Live Stream Config - -HTTP Flv/Mp3/Aac Live Stream的配置如下,更改不同的扩展名即可以不同方式分发: - -``` -http_server { - # whether http streaming service is enabled. - # default: off - enabled on; - # the http streaming listen entry is <[ip:]port> - # for example, 192.168.1.100:8080 - # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 - # @remark, if use lower port, for instance 80, user must start srs by root. - # default: 8080 - listen 8080; - # For https_server or HTTPS Streaming. - https { - # Whether enable HTTPS Streaming. - # default: off - enabled on; - # The listen endpoint for HTTPS Streaming. - # default: 8088 - listen 8088; - # The SSL private key file, generated by: - # openssl genrsa -out server.key 2048 - # default: ./conf/server.key - key ./conf/server.key; - # The SSL public cert file, generated by: - # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" - # default: ./conf/server.crt - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - # http flv/mp3/aac/ts stream vhost specified config - http_remux { - # whether enable the http live streaming service for vhost. - # default: off - enabled on; - # the fast cache for audio stream(mp3/aac), - # to cache more audio and send to client in a time to make android(weixin) happy. - # @remark the flv/ts stream ignore it - # @remark 0 to disable fast cache for http audio stream. - # default: 0 - fast_cache 30; - # the stream mout for rtmp to remux to live streaming. - # typical mount to [vhost]/[app]/[stream].flv - # the variables: - # [vhost] current vhost for http live stream. - # [app] current app for http live stream. - # [stream] current stream for http live stream. - # @remark the [vhost] is optional, used to mount at specified vhost. - # the extension: - # .flv mount http live flv stream, use default gop cache. - # .ts mount http live ts stream, use default gop cache. - # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. - # .aac mount http live aac stream, ignore video and audio aac codec required. - # for example: - # mount to [vhost]/[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # mount to /[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # or by http://192.168.1.173:8080/live/livestream.flv - # mount to [vhost]/[app]/[stream].mp3 - # access by http://ossrs.net:8080/live/livestream.mp3 - # mount to [vhost]/[app]/[stream].aac - # access by http://ossrs.net:8080/live/livestream.aac - # mount to [vhost]/[app]/[stream].ts - # access by http://ossrs.net:8080/live/livestream.ts - # @remark the port of http is specified by http_server section. - # default: [vhost]/[app]/[stream].flv - mount [vhost]/[app]/[stream].flv; - } -} -``` - -备注:若需要同时分发不同的http live stream,可以使用forward到其他vhost,不同的vhost配置不同的http live stream。 - -备注:HTTP服务器配置,参考[HTTP Server](./http-server.md#config) - -## About HTTP FLV - -这一节详细解释HTTP FLV的背景。 - -SRS的HTTP FLV边缘只能使用单进程,如何做到多进程呢?请参考[Reuse Port](./reuse-port.md) - -### What is HTTP FLV - -所有的HTTP FLV流都是一个HTTP FLV地址,譬如:`http://ossrs.net:8081/live/livestream.flv`,但是,流的形式却至少有三种: - -1. FLV文件,渐进式HTTP流。放一个文件到nginx目录,可以访问下载在播放器播放,这是HTTP FLV文件,也就是渐进式下载流。所谓渐进式下载,也就是用户观看时无法从未下载的地方开始看。 -1. FLV伪流。一般说的HTTP FLV,比上面的渐进式流高级一点,譬如,一个120分钟的电影,作为渐进式流播放时,用户需要从60分钟开始看,如何支持呢?因为nginx是当做文件下载的,无法直接跳转到第60分钟(nginx也不知道60分钟对应的字节偏移是多少呀)。后来有人就支持这种跳着播放,通过指定时间服务器从指定的位置开始给流,这种支持flv?start=,就是http flv的伪流,本质上还是点播流。 -1. FLV直播流。SRS所指的HTTP FLV流,是严格意义上的直播流,有RTMP的所有特征,譬如集群、低延迟、热备、GOP cache,而且有HTTP的优势,譬如302、穿墙、通用。由于SRS内部实现了HTTP服务器,所以SRS是在边缘将RTMP流转换成HTTP流,SRS集群内部还是使用RTMP分发。当前唯一将RTMP和HTTP协议都解析的服务器,目前只有SRS和nginx-rtmp,可惜nginx-rtmp没有实现这个流。 - -用一句话概括,SRS的HTTP FLV就是增强的RTMP,真正的实时流媒体分发。 - -### Confuse HTTP FLV - -SRS的HTTP FLV容易和下面的几种分发方式混淆: - -1. RTMPT:这个实际上是最接近SRS的HTTP FLV的概念的。但是从本质上来讲,rtmpt是基于HTTP的RTMP,所以还是RTMP而不是FLV。 -2. HDL/HFL:国内一些厂家的HXX流,就是FLV流,主要和SRS的区别在于服务器集群内部SRS还是走RTMP,所以延迟可能会有很大差异。SRS的HTTP FLV和RTMP延迟一样,0.8-3秒。 -3. HDS:这个差的太远了,不是一个东西。HDS和HLS像,但是HTTP FLV和他们两个都完全不像。 - -### Why HTTP FLV - -为何要整个HTTP FLV出来呢?当下HTTP FLV流正大行其道。主要的优势在于: - -1. 互联网流媒体实时领域,还是RTMP。HTTP-FLV和RTMP的延迟一样,因此可以满足延迟的要求。 -1. 穿墙:很多防火墙会墙掉RTMP,但是不会墙HTTP,因此HTTP FLV出现奇怪问题的概率很小。 -1. 调度:RTMP也有个302,可惜是播放器as中支持的,HTTP FLV流就支持302方便CDN纠正DNS的错误。 -1. 容错:SRS的HTTP FLV回源时可以回多个,和RTMP一样,可以支持多级热备。 -1. 通用:Flash可以播RTMP,也可以播HTTP FLV。自己做的APP,也都能支持。主流播放器也都支持http flv的播放。 -1. 简单:FLV是最简单的流媒体封装,HTTP是最广泛的协议,这两个到一起维护性很高,比RTMP简单多了。 - -## Sample - -配置实例参考:https://github.com/ossrs/srs/issues/293#issuecomment-70449126 - -一步一步配置HTTP FLV: [Sample](./sample-http-flv.md) - -## Websocket FLV - -可以将HTTP-FLV转成WebSocket-FLV流,这样就可以使用[MSE(flv.js)](https://github.com/Bilibili/flv.js#features)播放了,参考[videojs-flow](https://github.com/winlinvip/videojs-flow)。 - -关于HTTP转WebSocket参考[mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go)。 - -## HTTP FLV VOD Stream - -关于HTTP flv 点播流,参考:[v4_CN_FlvVodStream](./flv-vod-stream.md) - -Winlin 2015.1 - -[go-sharp]: https://github.com/ossrs/go-sharp +迁移到了[HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v5/delivery-http-flv) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/flv.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/flv.md index 22d499cc..8709d183 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/flv.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/flv.md @@ -7,8 +7,207 @@ hide_table_of_contents: false # HTTP-FLV -See [HTTP-FLV](./delivery-http-flv.md). +HTTP-FLV是一种直播流协议,有时候也简称FLV,是在HTTP连接上传输FLV格式的直播流。 -![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v5/flv) +和文件下载不同的是,直播流的长度是无限长,或者不确定长度,因此一般是基于HTTP Chunked协议实现。和HTTP-FLV类似的,还有HTTP-TS, +或者HTTP-MP3,TS主要应用于广播电视领域,MP3主要应用于音频领域。 + +和HLS不同的是,HLS本质上就是HTTP文件下载,而HTTP-FLV本质上是流传输。CDN对于HTTP文件下载的支持很完善,因此HLS的兼容性比HTTP-FLV +要好很多;同样HTTP-FLV的延迟比HLS要低很多,基本上可以做到3的5秒左右延迟,而HLS的延迟一般是8到10秒以上。 + +从协议实现上看,RTMP和HTTP-FLV几乎一样,RTMP是基于TCP协议,而HTTP-FLV基于HTTP也是TCP协议,因此两者的特点也非常类似。一般推流和 +流的生产使用RTMP,主要是因为流的生产设备都支持RTMP;而流的播放和消费端采用HTTP-FLV或这HLS,因为播放设备支持HTTP更完善。 + +HTTP-FLV的兼容性很好,除了iOS原生浏览器不支持,其他平台和浏览器都支持了,参考[MSE](https://caniuse.com/?search=mse)。 +若需要支持iOS浏览器,你可以考虑使用HLS或者使用WASM;注意一般iOS的Native应用,可以选择使用ijkplayer播放器。 + +## Usage + +SRS支持HTTP-FLV分发,可以用[docker](./getting-started.md)或者[从源码编译](./getting-started-build.md): + +```bash +docker run --rm -it -p 1935:1935 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5 \ + ./objs/srs -c conf/http.flv.live.conf +``` + +使用 [FFmpeg(点击下载)](https://ffmpeg.org/download.html) 或 [OBS(点击下载)](https://obsproject.com/download) 推流: + +```bash +ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream +``` + +打开下面的页面播放流(若SRS不在本机,请将localhost更换成服务器IP): + +* HLS by SRS player: [http://localhost:8080/live/livestream.flv](http://localhost:8080/players/srs_player.html) + +## Config + +HTTP-FLV相关的配置如下: + +```bash +http_server { + # whether http streaming service is enabled. + # Overwrite by env SRS_HTTP_SERVER_ENABLED + # default: off + enabled on; + # the http streaming listen entry is <[ip:]port> + # for example, 192.168.1.100:8080 + # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 + # @remark, if use lower port, for instance 80, user must start srs by root. + # Overwrite by env SRS_HTTP_SERVER_LISTEN + # default: 8080 + listen 8080; + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +vhost __defaultVhost__ { + # http flv/mp3/aac/ts stream vhost specified config + http_remux { + # whether enable the http live streaming service for vhost. + # Overwrite by env SRS_VHOST_HTTP_REMUX_ENABLED for all vhosts. + # default: off + enabled on; + # the fast cache for audio stream(mp3/aac), + # to cache more audio and send to client in a time to make android(weixin) happy. + # @remark the flv/ts stream ignore it + # @remark 0 to disable fast cache for http audio stream. + # Overwrite by env SRS_VHOST_HTTP_REMUX_FAST_CACHE for all vhosts. + # default: 0 + fast_cache 30; + # Whether drop packet if not match header. For example, there is has_audio and has video flag in FLV header, if + # this is set to on and has_audio is false, then SRS will drop audio packets when got audio packets. Generally + # it should work, but sometimes you might need SRS to keep packets even when FLV header is set to false. + # See https://github.com/ossrs/srs/issues/939#issuecomment-1348740526 + # TODO: Only support HTTP-FLV stream right now. + # Overwrite by env SRS_VHOST_HTTP_REMUX_DROP_IF_NOT_MATCH for all vhosts. + # Default: on + drop_if_not_match on; + # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header audio flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts. + # Default: on + has_audio on; + # Whether stream has video track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header video flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts. + # Default: on + has_video on; + # Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If + # guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream + # is not regular. If not guessing, use the configured default value has_audio and has_video. + # For HTTP-FLV, enable guessing for av header flag, because FLV can't change the header. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, ignore guessing because TS refresh the PMT when codec changed. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts. + # Default: on + guess_has_av on; + # the stream mount for rtmp to remux to live streaming. + # typical mount to [vhost]/[app]/[stream].flv + # the variables: + # [vhost] current vhost for http live stream. + # [app] current app for http live stream. + # [stream] current stream for http live stream. + # @remark the [vhost] is optional, used to mount at specified vhost. + # the extension: + # .flv mount http live flv stream, use default gop cache. + # .ts mount http live ts stream, use default gop cache. + # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. + # .aac mount http live aac stream, ignore video and audio aac codec required. + # for example: + # mount to [vhost]/[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # mount to /[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # or by http://192.168.1.173:8080/live/livestream.flv + # mount to [vhost]/[app]/[stream].mp3 + # access by http://ossrs.net:8080/live/livestream.mp3 + # mount to [vhost]/[app]/[stream].aac + # access by http://ossrs.net:8080/live/livestream.aac + # mount to [vhost]/[app]/[stream].ts + # access by http://ossrs.net:8080/live/livestream.ts + # @remark the port of http is specified by http_server section. + # Overwrite by env SRS_VHOST_HTTP_REMUX_MOUNT for all vhosts. + # default: [vhost]/[app]/[stream].flv + mount [vhost]/[app]/[stream].flv; + } +} +``` + +> Note: 这些配置只是播放HTTP-FLV相关的配置,推流的配置请根据你的协议,比如参考[RTMP](./rtmp.md#config)或者[SRT](./srt.md#config)或者[WebRTC](./webrtc.md#config)的推流配置。 + +关键配置说明如下: + +* `has_audio` 是否有音频流,如果你的流没有音频,则需要配置这个为`off`,否则播放器可能会等待音频。 +* `has_video` 是否有视频流,如果你的流没有视频,则需要配置这个为`off`,否则播放器可能会等待视频。 + +## Cluster + +SRS支持HTTP-FLV集群分发,可以支持海量的观看客户端,参考[HTTP-FLV Cluster](./sample-http-flv-cluster.md)和[Edge](./edge.md) + +## Crossdomain + +SRS默认支持了HTTP CORS,请参考[HTTP CORS](./http-server.md#crossdomain) + +## Websocket FLV +可以将HTTP-FLV转成WebSocket-FLV流,参考[videojs-flow](https://github.com/winlinvip/videojs-flow)。 + +关于HTTP转WebSocket参考[mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go)。 + +## HTTP FLV VOD Stream + +关于HTTP flv 点播流,参考:[v4_CN_FlvVodStream](./flv-vod-stream.md) + +## HTTP and HTTPS Proxy + +SRS可以和HTTP/HTTPS代理一起工作得很好,比如[Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), +[HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), +等等。详细配置请参考 [#2881](https://github.com/ossrs/srs/issues/2881)。 + +## HTTPS FLV Live Stream + +SRS支持将RTMP流转封装为HTTPS flv流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置), +用户在访问这个https flv文件时,从rtmp流转封装为flv分发给用户。 + +具体请参考[HTTPS Server](./http-server.md#https-server),或者`conf/https.flv.live.conf`配置文件。 + +## HTTP TS Live Stream + +SRS支持将RTMP流转封装为HTTP ts流,即在publish发布RTMP流时,在SRS的http模块中挂载一个对应的http地址(根据配置), +用户在访问这个http ts文件时,从rtmp流转封装为ts分发给用户。 + +具体请参考`conf/http.ts.live.conf`配置文件。 + +## HTTP Mp3 Live Stream + +SRS支持将rtmp流中的视频丢弃,将音频流转封装为mp3格式,在SRS的http模块中挂载对应的http地址(根据配置), +用户在访问这个http mp3文件时,从rtmp转封装为mp3分发给用户。 + +具体请参考`conf/http.mp3.live.conf`配置文件。 + +## HTTP Aac Live Stream + +SRS支持将rtmp流中的视频丢弃,将音频流转封装为aac格式,在SRS的http模块中挂载对应的http地址(根据配置), +用户在访问这个http aac文件时,从rtmp转封装为aac分发给用户。 + +具体请参考`conf/http.aac.live.conf`配置文件。 + +## Why HTTP FLV + +为何要整个HTTP FLV出来呢?当下HTTP FLV流正大行其道。主要的优势在于: + +1. 互联网流媒体实时领域,还是RTMP。HTTP-FLV和RTMP的延迟一样,因此可以满足延迟的要求。 +1. 穿墙:很多防火墙会墙掉RTMP,但是不会墙HTTP,因此HTTP FLV出现奇怪问题的概率很小。 +1. 调度:RTMP也有个302,可惜是播放器as中支持的,HTTP FLV流就支持302方便CDN纠正DNS的错误。 +1. 容错:SRS的HTTP FLV回源时可以回多个,和RTMP一样,可以支持多级热备。 +1. 通用:Flash可以播RTMP,也可以播HTTP FLV。自己做的APP,也都能支持。主流播放器也都支持http flv的播放。 +1. 简单:FLV是最简单的流媒体封装,HTTP是最广泛的协议,这两个到一起维护性很高,比RTMP简单多了。 + +![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v5/flv) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started-build.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started-build.md index f82a463e..e53398a9 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started-build.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started-build.md @@ -201,7 +201,7 @@ CANDIDATE="192.168.1.10" > Remark: 请使用你的证书文件,代替上面配置中的key和cert,请参考 > **[HTTPS API](./http-api.md#https-api)** > 以及 **[HTTPS Callback](./http-callback.md#https-callback)** -> 以及 **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> 以及 **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > 当然了HTTPS的反向代理也能和SRS工作很好,比如Nginx代理到SRS。 使用WebRTC推流到SRS:[WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started.md index a623ab3a..1828fe51 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/getting-started.md @@ -131,7 +131,7 @@ docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 1990:1990 -p 8088: > Remark: 请使用你的证书文件,代替上面配置中的key和cert,请参考 > **[HTTPS API](./http-api.md#https-api)** > 以及 **[HTTPS Callback](./http-callback.md#https-callback)** -> 以及 **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> 以及 **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > 当然了HTTPS的反向代理也能和SRS工作很好,比如Nginx代理到SRS。 使用WebRTC推流到SRS:[WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/hls.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/hls.md index b8133f24..7b983a2f 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/hls.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/hls.md @@ -15,7 +15,7 @@ HLS是适配性和兼容性最好的流媒体协议,没有之一。这个世 当然了,HLS并不是没有毛病,它的问题就是延迟比较高,一般在30秒左右。虽然经过优化可以到8秒左右,但是不同播放器的行为可能不一致。 对比起其他流媒体协议,优化后的延迟也很高。因此如果你特别在意直播的延迟,那么请使用[RTMP](./rtmp.md)或者 -[HTTP-FLV](./sample-http-flv.md)协议。 +[HTTP-FLV](./flv.md)协议。 HLS主要的应用场景包括: * 跨平台:PC主要的直播方案是HLS,可用hls.js库播放HLS。所以实际上如果选一种协议能跨PC/Android/IOS,那就是HLS。 @@ -43,7 +43,7 @@ ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream 打开下面的页面播放流(若SRS不在本机,请将localhost更换成服务器IP): -* HLS (by [VLC](https://www.videolan.org/)): `http://localhost:8080/live/livestream.m3u8` +* HLS by SRS player: [http://localhost:8080/live/livestream.m3u8](http://localhost:8080/players/srs_player.html?stream=livestream.m3u8) > Note: 请等待大约10秒左右,再播放流,否则会播放失败,因为生成第一个切片需要一些时间。 @@ -257,6 +257,8 @@ vhost __defaultVhost__ { } ``` +> Note: 这些配置只是播放HLS相关的配置,推流的配置请根据你的协议,比如参考[RTMP](./rtmp.md#config)或者[SRT](./srt.md#config)或者[WebRTC](./webrtc.md#config)的推流配置。 + 主要配置项如下: * enabled:是否开启HLS,on/off,默认off。 * hls_fragment:秒,指定ts切片的最小长度。实际上ts文件的长度请参考[HLS TS Duration](#hls-ts-duration)的详细说明。 @@ -414,7 +416,7 @@ vhost __defaultVhost__ { 当然,也不能减少得非常少,容易造成播放器缓冲不足,或者播放器网络不佳时跳片,可能会有播放失败。 延迟越低,卡顿概率越高,HLS的延迟并不能做到5秒之内,特别是考虑CDN和播放器的适配情况。 -如果需要5秒之内的延迟,建议使用[HTTP-FLV](./sample-http-flv.md)或者[SRT](./srt.md)或者[WebRTC](./webrtc.md)等协议。 +如果需要5秒之内的延迟,建议使用[HTTP-FLV](./flv.md)或者[SRT](./srt.md)或者[WebRTC](./webrtc.md)等协议。 ## ON HLS Notify diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-api.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-api.md index a4b5c948..29f3b96e 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-api.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-api.md @@ -278,7 +278,7 @@ http_api { > Remark: 请使用你的证书文件,代替上面配置中的key和cert。 -> Note: 若需要开启HTTPS直播流,请参考[HTTPS FLV Live Stream](./delivery-http-flv.md#https-flv-live-stream) +> Note: 若需要开启HTTPS直播流,请参考[HTTPS FLV Live Stream](./flv.md#https-flv-live-stream) ## HTTP and HTTPS Proxy diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-server.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-server.md index e677d2e7..8d0c6194 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-server.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/http-server.md @@ -105,6 +105,49 @@ vhost your_vhost { 注意:SRS1中vhost的`http`在SRS2改名为`http_static`,和全局的`http_server`类似用来分发静态的文件。而SRS2新增的功能`http_remux`,用来动态转封装,将RTMP流转封装为 HTTP Live FLV/Mp3/Aac/Hls/Hds/MPEG-DASH流。 +## HTTPS Server + +SRS支持HTTPS,在配置中开启即可,默认使用子签名证书,若需要使用CA颁发的证书,请替换相关的文件。相关配置如下: + +```bash +http_server { + https { + # Whether enable HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_ENABLED + # default: off + enabled on; + # The listen endpoint for HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_LISTEN + # default: 8088 + listen 8088; + # The SSL private key file, generated by: + # openssl genrsa -out server.key 2048 + # Overwrite by env SRS_HTTP_SERVER_HTTPS_KEY + # default: ./conf/server.key + key ./conf/server.key; + # The SSL public cert file, generated by: + # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" + # Overwrite by env SRS_HTTP_SERVER_HTTPS_CERT + # default: ./conf/server.crt + cert ./conf/server.crt; + } +} +``` + +## Crossdomain + +SRS默认开启了CORS跨域的支持,相关配置如下: + +```bash +http_server { + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +``` + ## MIME 支持少量的MIME,见下表。 diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/resource.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/resource.md index 929dd3ab..7200f797 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/resource.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/resource.md @@ -15,7 +15,7 @@ The ports used by SRS, kernel services: * `tcp://1935`, for [RTMP live streaming server](./rtmp.md). * `tcp://1985`, HTTP API server, for [HTTP-API](./http-api.md), [WebRTC](./webrtc.md), etc. -* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./sample-http-flv.md), [HLS](./hls.md) as such. +* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./flv.md), [HLS](./hls.md) as such. * `udp://8000`, [WebRTC Media](./webrtc.md) server. For optional HTTPS services, which might be provided by other web servers: diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp-pk-http.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp-pk-http.md index a9041ff7..8488a5be 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp-pk-http.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp-pk-http.md @@ -9,7 +9,7 @@ hide_table_of_contents: false 互联网上的两种主要的分发方式:直播和WebRTC,什么时候用谁,完全决定于应用场景。 -* 直播:[HLS](./hls.md),[RTMP](./rtmp.md)和[HTTP-FLV](./delivery-http-flv.md),主要是娱乐和教育场景。 +* 直播:[HLS](./hls.md),[RTMP](./rtmp.md)和[HTTP-FLV](./flv.md),主要是娱乐和教育场景。 * WebRTC:[RTC](./webrtc.md),主要应用于通话,直播连麦,教育等场景。 还有其他的分发方式,这些分发方式不属于互联网常见和通用的方式,不予以比较: diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp.md index 1404dec9..a95cdccb 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/rtmp.md @@ -266,7 +266,7 @@ vhost __defaultVhost__ { ## Converting RTMP to HTTP-FLV -如果需要将RTMP转HTTP-FLV或HTTP-TS协议,请参考[HTTP-FLV](./sample-http-flv.md). +如果需要将RTMP转HTTP-FLV或HTTP-TS协议,请参考[HTTP-FLV](./flv.md). ## Converting RTMP to WebRTC diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv-cluster.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv-cluster.md index b2b12b30..bfd1afc2 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv-cluster.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv-cluster.md @@ -7,7 +7,7 @@ hide_table_of_contents: false # HTTP-FLV集群部署实例 -SRS支持HTTP FLV直播流集群分发,详细参考[HTTP FLV](./delivery-http-flv.md#about-http-flv) +SRS支持HTTP FLV直播流集群分发,详细参考[HTTP FLV](./flv.md#about-http-flv) SRS的HTTP FLV边缘只能使用单进程,如何做到多进程呢?请参考[Reuse Port](./reuse-port.md) @@ -40,7 +40,7 @@ git pull ## 第三步,编写SRS源站配置文件 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 将以下内容保存为文件,譬如`conf/http.flv.live.conf`,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。 @@ -64,7 +64,7 @@ vhost __defaultVhost__ { ## 第四步,编写SRS边缘配置文件 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 将以下内容保存为文件,譬如`conf/http.flv.live.edge1.conf`和`conf/http.flv.live.edge2.conf`,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。 @@ -92,7 +92,7 @@ vhost __defaultVhost__ { ## 第五步,启动SRS -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) ```bash ./objs/srs -c conf/http.flv.live.conf & @@ -102,7 +102,7 @@ vhost __defaultVhost__ { ## 第六步,启动推流编码器 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 使用FFMPEG命令推流: @@ -136,7 +136,7 @@ Stream: livestream ## 第七步,观看RTMP流 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 源站RTMP流地址为:`rtmp://192.168.1.170/live/livestream`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) @@ -148,7 +148,7 @@ Stream: livestream ## 第八步,观看HTTP流 -详细参考[HTTP FLV](./delivery-http-flv.md) +详细参考[HTTP FLV](./flv.md) 源站HTTP FLV流地址为: `http://192.168.1.170:8080/live/livestream.flv`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv.md index b5f578dd..f2af370c 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/sample-http-flv.md @@ -7,110 +7,7 @@ hide_table_of_contents: false # HTTP-FLV部署实例 -SRS支持HTTP FLV直播流分发,详细参考[HTTP FLV](./delivery-http-flv.md#about-http-flv) - -SRS的HTTP FLV边缘只能使用单进程,如何做到多进程呢?请参考[Reuse Port](./reuse-port.md) - -**假设服务器的IP是:192.168.1.170** - -## 第一步,获取SRS - -详细参考[GIT获取代码](./git.md) - -```bash -git clone https://github.com/ossrs/srs -cd srs/trunk -``` - -或者使用git更新已有代码: - -```bash -git pull -``` - -## 第二步,编译SRS - -详细参考[Build](./install.md) - -```bash -./configure && make -``` - -## 第三步,编写SRS配置文件 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -将以下内容保存为文件,譬如`conf/http.flv.live.conf`,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。 - -```bash -# conf/http.flv.live.conf -listen 1935; -max_connections 1000; -http_server { - enabled on; - listen 8080; - dir ./objs/nginx/html; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - hstrs on; - } -} -``` - -## 第四步,启动SRS - -详细参考[HTTP FLV](./delivery-http-flv.md) - -```bash -./objs/srs -c conf/http.flv.live.conf -``` - -## 第五步,启动推流编码器 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -使用FFMPEG命令推流: - -```bash - for((;;)); do \ - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.flv \ - -c copy \ - -f flv rtmp://192.168.1.170/live/livestream; \ - sleep 1; \ - done -``` - -或使用支持FMLE推流: - -```bash -FMS URL: rtmp://192.168.1.170/live -Stream: livestream -``` - -生成的流地址为: -* RTMP流地址为:`rtmp://192.168.1.170/live/livestream` -* HTTP FLV: `http://192.168.1.170:8080/live/livestream.flv` - -## 第六步,观看RTMP流 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -RTMP流地址为:`rtmp://192.168.1.170/live/livestream`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) - -备注:请将所有实例的IP地址192.168.1.170都换成部署的服务器IP地址。 - -## 第七步,观看FLV流 - -详细参考[HTTP FLV](./delivery-http-flv.md) - -HTTP FLV流地址为: `http://192.168.1.170:8080/live/livestream.flv`,可以使用VLC观看,或者使用在线SRS播放器播放:[srs-player](https://ossrs.net/players/srs_player.html) - -备注:请将所有实例的IP地址192.168.1.170都换成部署的服务器IP地址。 - -Winlin 2014.4 +迁移到了[HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v5/sample-http-flv) diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/srt.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/srt.md index 577cbccd..ef7b741b 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/srt.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/srt.md @@ -9,6 +9,10 @@ hide_table_of_contents: false See [SRT](./sample-srt.md). +## Config + +On the way. + ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/zh/v5/srt) diff --git a/sidebars.json b/sidebars.json index 8cbceddc..5fd38e56 100644 --- a/sidebars.json +++ b/sidebars.json @@ -37,7 +37,7 @@ "doc/rtmp", "doc/hls", "doc/webrtc", - "doc/sample-http-flv", + "doc/flv", "doc/sample-srt", "doc/gb28181", "doc/sample-dash", diff --git a/versioned_docs/version-5.0/doc/delivery-http-flv.md b/versioned_docs/version-5.0/doc/delivery-http-flv.md index 6a59fe25..f6b7581f 100644 --- a/versioned_docs/version-5.0/doc/delivery-http-flv.md +++ b/versioned_docs/version-5.0/doc/delivery-http-flv.md @@ -7,263 +7,7 @@ hide_table_of_contents: false # HTTP-FLV Delivery -## HTTP FLV Live Stream - -SRS supports remux the rtmp stream to http flv stream, when publish rtmp stream on SRS, SRS will mount a http flv url and when user access the flv url, SRS will remux the rtmp stream to user. - -The config to delivery HTTP flv live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTPS FLV Live Stream - -SRS supports remux the rtmp stream to https flv stream, when publish rtmp stream on SRS, SRS will mount a https flv url and when user access the flv url, SRS will remux the rtmp stream to user. - -The config to delivery HTTPS flv live stream: - -``` -http_server { - enabled on; - listen 8080; - https { - enabled on; - listen 8088; - key ./conf/server.key; - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - } -} -``` - -> Remark: Please use your HTTPS key and cert file. - -> Note: To enable the HTTPS API, please read [HTTPS API](http://ossrs.net/srs.release/v4_EN_HTTPApi#https-api) - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP and HTTPS Proxy - -SRS works very well with HTTP/HTTPS proxy, like [Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), -[HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), -etc. Please read [#2881](https://github.com/ossrs/srs/issues/2881) for details. - -## HTTP TS Live Stream - -SRS supports remux the rtmp stream to http ts stream, when publish rtmp stream on SRS, SRS will mount a http ts url and when user access the ts url, SRS will remux the rtmp stream to user. - -The config to delivery HTTP ts live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].ts; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP Mp3 Live Stream - -SRS support remux the rtmp stream to http mp3 stream, drop video and mount mp3 http url, SRS will delivery mp3 stream when user access it. - -The config to delivery HTTP mp3 live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].mp3; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP Aac Live Stream - -SRS support remux the rtmp stream to http aac stream, drop video and mount aac http url, SRS will delivery aac stream when user access it. - -The config to delivery HTTP ac live stream: - -``` -http_server { - enabled on; - listen 8080; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - fast_cache 30; - mount [vhost]/[app]/[stream].aac; - } -} -``` - -@remark For more information about config, read [following detail config](./delivery-http-flv.md#http-live-stream-config). - -## HTTP Live Stream Config - -The config for HTTP Flv/Mp3/Aac Live Stream, use different extension to apply different stream: - -``` -http_server { - # whether http streaming service is enabled. - # default: off - enabled on; - # the http streaming listen entry is <[ip:]port> - # for example, 192.168.1.100:8080 - # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 - # @remark, if use lower port, for instance 80, user must start srs by root. - # default: 8080 - listen 8080; - # For https_server or HTTPS Streaming. - https { - # Whether enable HTTPS Streaming. - # default: off - enabled on; - # The listen endpoint for HTTPS Streaming. - # default: 8088 - listen 8088; - # The SSL private key file, generated by: - # openssl genrsa -out server.key 2048 - # default: ./conf/server.key - key ./conf/server.key; - # The SSL public cert file, generated by: - # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" - # default: ./conf/server.crt - cert ./conf/server.crt; - } -} -vhost __defaultVhost__ { - # http flv/mp3/aac/ts stream vhost specified config - http_remux { - # whether enable the http live streaming service for vhost. - # default: off - enabled on; - # the fast cache for audio stream(mp3/aac), - # to cache more audio and send to client in a time to make android(weixin) happy. - # @remark the flv/ts stream ignore it - # @remark 0 to disable fast cache for http audio stream. - # default: 0 - fast_cache 30; - # the stream mout for rtmp to remux to live streaming. - # typical mount to [vhost]/[app]/[stream].flv - # the variables: - # [vhost] current vhost for http live stream. - # [app] current app for http live stream. - # [stream] current stream for http live stream. - # @remark the [vhost] is optional, used to mount at specified vhost. - # the extension: - # .flv mount http live flv stream, use default gop cache. - # .ts mount http live ts stream, use default gop cache. - # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. - # .aac mount http live aac stream, ignore video and audio aac codec required. - # for example: - # mount to [vhost]/[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # mount to /[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # or by http://192.168.1.173:8080/live/livestream.flv - # mount to [vhost]/[app]/[stream].mp3 - # access by http://ossrs.net:8080/live/livestream.mp3 - # mount to [vhost]/[app]/[stream].aac - # access by http://ossrs.net:8080/live/livestream.aac - # mount to [vhost]/[app]/[stream].ts - # access by http://ossrs.net:8080/live/livestream.ts - # @remark the port of http is specified by http_server section. - # default: [vhost]/[app]/[stream].flv - mount [vhost]/[app]/[stream].flv; - } -} -``` - -Remark: Use forward+vhost to support multiple http live stream for a stream. - -Remark: The http server config section, read [HTTP Server](./http-server.md#config) - -## About HTTP FLV - -This section descrbes the HTTP FLV live streaming. - -How to use multiple process for HTTP FLV? Please read [Reuse Port](./reuse-port.md) for detail. - -### What is HTTP FLV - -All http streaming is a http flv url, for instance `http://ossrs.net:8081/live/livestream.flv`, but the delivery methods maybe different: - -1. FLV file, HTTP progressiv streaming. User can download and play the file which is serve by nginx, but user cannot seek to the part that not downloaded. -1. FLV pseudo streaming. This is the common used HTTP FLV streaming, to support to seek to the part which is not download, the server must accept a param, for instance .flv?start= to specifies the start time to play. This is HTTP FLV pseudo stream, but it's vod not live streaming. -1. FLV live streaming. The HTTP FLV streaming of SRS, is absolute live streaming, which is similar to RTMP for cluster, low latency, fault-backup and gop cache. And the HTTP FLV also similar to HTTP which can traverse firewall, HTTP 302 and simple. Because of SRS implements the HTTP and RTMP protocol, SRS remux the HTTP FLV stream on the edge server, and still use RTMP in cluster inside. The server which implements the RTMP and HTTP, only SRS and nginx-rtmp, but nginx-rtmp does not support HTTP FLV. - -In a word, the HTTP FLV of SRS is enhanced RTMP, absolute realtime media streaming delivery. - -### Confuse HTTP FLV - -The HTTP FLV of SRS is not: - -1. RTMPT: The rtmpt is similar to HTTP FLV of SRS, but rtmpt is rtmp over HTTP, not FLV over HTTP. -2. HDL/HFL: There exists another HXX stream, the latence maybe different, for SRS use RTMP to delivery HTTP FLV. -3. HDS: Absolutely not HTTP FLV, HDS is similar to HLS. - -### Why HTTP FLV - -Why SRS supports HTTP FLV? - -1. The internet realtime live streaming, generally use RTMP for low latence, while HTTP FLV latency equals to RTMP. -1. Firewall traverse: Many firewall may block RTMP, but never HTTP. -1. For GSLB: The HTTP FLV can support HTTP 302, to help GSLB to correct the stupid DNS problem. -1. Fault tolerance: The HTTP FLV of SRS similar to RTMP, support mulitple origin and fault backup. -1. Common Protocol: The HTTP FLV is ok for flash and other player. -1. Simple: FLV is the most simple media stream fomat, HTTP is the standard protocol of internet, they make thinks simple. - -## Sample - -The config sample, read https://github.com/ossrs/srs/issues/293#issuecomment-70449126 - -To config HTTP FLV, read [Sample](./sample-http-flv.md) - -## Websocket FLV - -After transmuxing HTTP-FLV to WebSocket-FLV, we could use [MSE(flv.js)](https://github.com/Bilibili/flv.js#features), please read [videojs-flow](https://github.com/winlinvip/videojs-flow). - -About transmuxing HTTP to WebSocket, please read [mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go). - -## HTTP FLV VOD Stream - -About the HTTP flv vod stream, read [v4_EN_FlvVodStream](./flv-vod-stream.md) - -Winlin 2015.1 - -[go-sharp]: https://github.com/ossrs/go-sharp +Migrated to [HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.io&path=/lts/doc/en/v5/delivery-http-flv) diff --git a/versioned_docs/version-5.0/doc/flv.md b/versioned_docs/version-5.0/doc/flv.md index cd7ce204..8b256cfa 100644 --- a/versioned_docs/version-5.0/doc/flv.md +++ b/versioned_docs/version-5.0/doc/flv.md @@ -7,8 +7,207 @@ hide_table_of_contents: false # HTTP-FLV -See [HTTP-FLV](./delivery-http-flv.md). +HTTP-FLV is a live streaming protocol, sometimes simply called FLV, which is used to transmit live streams in FLV +format over an HTTP connection. -![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/en/v5/flv) +Unlike file downloads, live streams have an indefinite or uncertain length, so they are usually implemented using +the HTTP Chunked protocol. Similar to HTTP-FLV, there are also HTTP-TS and HTTP-MP3. TS is mainly used in broadcasting +and television, while MP3 is mainly used in the audio field. + +Different from HLS, which is essentially an HTTP file download, HTTP-FLV is a streaming protocol. CDN support for +HTTP file downloads is well-developed, making HLS more compatible than HTTP-FLV. However, HTTP-FLV has lower latency +than HLS, typically achieving a delay of around 3 to 5 seconds, while HLS latency is generally 8 to 10 seconds or more. + +In terms of protocol implementation, RTMP and HTTP-FLV are very similar. RTMP is based on the TCP protocol, and +HTTP-FLV is based on HTTP, which is also a TCP protocol. Therefore, their characteristics are very similar. RTMP +is generally used for streaming and live production because most live production devices support RTMP. For playback +and consumption, HTTP-FLV or HLS is used because playback devices have better support for HTTP. + +HTTP-FLV is highly compatible, supported by almost all platforms and browsers except for the native iOS browser. +You can refer to [MSE](https://caniuse.com/?search=mse) for more information. To support the iOS browser, you can +consider using HLS or WASM. Note that for native iOS apps, the ijkplayer can be used as a playback option. + +## Usage + +SRS supports HTTP-FLV distribution, you can use [docker](./getting-started.md) or [build from source](./getting-started-build.md): + +```bash +docker run --rm -it -p 1935:1935 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5 \ + ./objs/srs -c conf/http.flv.live.conf +``` + +Use [FFmpeg(click to download)](https://ffmpeg.org/download.html) or [OBS(click to download)](https://obsproject.com/download) to push the stream: + +```bash +ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream +``` + +Open the following page to play the stream (if SRS is not on your local machine, please replace localhost with the server IP): + +* HLS by SRS player: [http://localhost:8080/live/livestream.flv](http://localhost:8080/players/srs_player.html) + +## Config + +The configuration for HTTP-FLV is as follows: + +```bash +http_server { + # whether http streaming service is enabled. + # Overwrite by env SRS_HTTP_SERVER_ENABLED + # default: off + enabled on; + # the http streaming listen entry is <[ip:]port> + # for example, 192.168.1.100:8080 + # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080 + # @remark, if use lower port, for instance 80, user must start srs by root. + # Overwrite by env SRS_HTTP_SERVER_LISTEN + # default: 8080 + listen 8080; + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +vhost __defaultVhost__ { + # http flv/mp3/aac/ts stream vhost specified config + http_remux { + # whether enable the http live streaming service for vhost. + # Overwrite by env SRS_VHOST_HTTP_REMUX_ENABLED for all vhosts. + # default: off + enabled on; + # the fast cache for audio stream(mp3/aac), + # to cache more audio and send to client in a time to make android(weixin) happy. + # @remark the flv/ts stream ignore it + # @remark 0 to disable fast cache for http audio stream. + # Overwrite by env SRS_VHOST_HTTP_REMUX_FAST_CACHE for all vhosts. + # default: 0 + fast_cache 30; + # Whether drop packet if not match header. For example, there is has_audio and has video flag in FLV header, if + # this is set to on and has_audio is false, then SRS will drop audio packets when got audio packets. Generally + # it should work, but sometimes you might need SRS to keep packets even when FLV header is set to false. + # See https://github.com/ossrs/srs/issues/939#issuecomment-1348740526 + # TODO: Only support HTTP-FLV stream right now. + # Overwrite by env SRS_VHOST_HTTP_REMUX_DROP_IF_NOT_MATCH for all vhosts. + # Default: on + drop_if_not_match on; + # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header audio flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts. + # Default: on + has_audio on; + # Whether stream has video track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header video flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts. + # Default: on + has_video on; + # Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If + # guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream + # is not regular. If not guessing, use the configured default value has_audio and has_video. + # For HTTP-FLV, enable guessing for av header flag, because FLV can't change the header. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, ignore guessing because TS refresh the PMT when codec changed. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts. + # Default: on + guess_has_av on; + # the stream mount for rtmp to remux to live streaming. + # typical mount to [vhost]/[app]/[stream].flv + # the variables: + # [vhost] current vhost for http live stream. + # [app] current app for http live stream. + # [stream] current stream for http live stream. + # @remark the [vhost] is optional, used to mount at specified vhost. + # the extension: + # .flv mount http live flv stream, use default gop cache. + # .ts mount http live ts stream, use default gop cache. + # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. + # .aac mount http live aac stream, ignore video and audio aac codec required. + # for example: + # mount to [vhost]/[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # mount to /[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # or by http://192.168.1.173:8080/live/livestream.flv + # mount to [vhost]/[app]/[stream].mp3 + # access by http://ossrs.net:8080/live/livestream.mp3 + # mount to [vhost]/[app]/[stream].aac + # access by http://ossrs.net:8080/live/livestream.aac + # mount to [vhost]/[app]/[stream].ts + # access by http://ossrs.net:8080/live/livestream.ts + # @remark the port of http is specified by http_server section. + # Overwrite by env SRS_VHOST_HTTP_REMUX_MOUNT for all vhosts. + # default: [vhost]/[app]/[stream].flv + mount [vhost]/[app]/[stream].flv; + } +} +``` + +> Note: These settings are only for playing HLS. For streaming settings, please follow your protocol, like referring to [RTMP](./rtmp.md#config), [SRT](./srt.md#config), or [WebRTC](./webrtc.md#config) streaming configurations. + +The important settings are explained below: + +* `has_audio`: If there is an audio stream or not. If your stream doesn't have audio, set this to `off`. Otherwise, the player might wait for audio. +* `has_video`: If there is a video stream or not. If your stream doesn't have video, set this to `off`. Otherwise, the player might wait for video. + +## Cluster + +SRS supports HTTP-FLV cluster distribution, which can handle a large number of viewing clients. Please refer to [HTTP-FLV Cluster](./sample-http-flv-cluster.md) and [Edge](./edge.md). + +## Crossdomain + +SRS supports HTTP CORS by default. Please refer to [HTTP CORS](./http-server.md#crossdomain). + +## Websocket FLV +You can convert HTTP-FLV to WebSocket-FLV stream. Please refer to [videojs-flow](https://github.com/winlinvip/videojs-flow). + +For HTTP to WebSocket conversion, please refer to [mse.go](https://github.com/winlinvip/videojs-flow/blob/master/demo/mse.go). + +## HTTP FLV VOD Stream + +For HTTP FLV on-demand streaming, please refer to: [v4_CN_FlvVodStream](./flv-vod-stream.md). + +## HTTP and HTTPS Proxy + +SRS works well with HTTP/HTTPS proxies such as [Nginx](https://github.com/ossrs/srs/issues/2881#nginx-proxy), [HTTPX](https://github.com/ossrs/srs/issues/2881#httpx-proxy), [CaddyServer](https://github.com/ossrs/srs/issues/2881#caddy-proxy), etc. For detailed configuration, please refer to [#2881](https://github.com/ossrs/srs/issues/2881). + +## HTTPS FLV Live Stream + +SRS supports converting RTMP streams to HTTPS FLV streams. When publishing RTMP streams, a corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTPS FLV file, and the RTMP stream is converted to FLV for distribution. + +Please refer to [HTTPS Server](./http-server.md#https-server) or the `conf/https.flv.live.conf` configuration file. + +## HTTP TS Live Stream + +SRS supports converting RTMP streams to HTTP TS streams. When publishing RTMP streams, a corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTP TS file, and the RTMP stream is converted to TS for distribution. + +Please refer to the `conf/http.ts.live.conf` configuration file. + +## HTTP Mp3 Live Stream + +SRS supports discarding video from RTMP streams and converting audio streams to MP3 format. A corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTP MP3 file, and the RTMP stream is converted to MP3 for distribution. + +Please refer to the `conf/http.mp3.live.conf` configuration file. + +## HTTP Aac Live Stream + +SRS supports discarding video from RTMP streams and converting audio streams to AAC format. A corresponding HTTP address is mounted in the SRS HTTP module (according to the configuration). Users can access this HTTP AAC file, and the RTMP stream is converted to AAC for distribution. + +Please refer to the `conf/http.aac.live.conf` configuration file. + +## Why HTTP FLV + +Why use HTTP FLV? HTTP FLV streaming is becoming more popular. The main advantages are: + +1. In the field of real-time Internet streaming media, RTMP is still dominant. HTTP-FLV has the same latency as RTMP, so it can meet latency requirements. +2. Firewall penetration: Many firewalls block RTMP but not HTTP, so HTTP FLV is less likely to have strange issues. +3. Scheduling: RTMP has a 302 feature, but it's only supported in the player's ActionScript. HTTP FLV supports 302, making it easier for CDNs to correct DNS errors. +4. Fault tolerance: SRS's HTTP FLV can have multiple sources, just like RTMP, supporting multi-level hot backup. +5. Universality: Flash can play both RTMP and HTTP FLV. Custom apps and mainstream players also support HTTP FLV playback. +6. Simplicity: FLV is the simplest streaming media encapsulation, and HTTP is the most widely used protocol. Combining these two makes maintenance much easier than RTMP. + +![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/en/v5/flv) diff --git a/versioned_docs/version-5.0/doc/getting-started-build.md b/versioned_docs/version-5.0/doc/getting-started-build.md index cadc6f30..25101c97 100644 --- a/versioned_docs/version-5.0/doc/getting-started-build.md +++ b/versioned_docs/version-5.0/doc/getting-started-build.md @@ -181,7 +181,7 @@ CANDIDATE="192.168.1.10" > Remark: Please use your HTTPS key and cert file, please read > **[HTTPS API](./http-api.md#https-api)** > and **[HTTPS Callback](./http-callback.md#https-callback)** -> and **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> and **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > however HTTPS proxy also works perfect with SRS such as Nginx. Push stream to SRS by [WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/versioned_docs/version-5.0/doc/getting-started.md b/versioned_docs/version-5.0/doc/getting-started.md index fa1a5f29..16154def 100644 --- a/versioned_docs/version-5.0/doc/getting-started.md +++ b/versioned_docs/version-5.0/doc/getting-started.md @@ -129,7 +129,7 @@ docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 1990:1990 -p 8088: > Remark: Please use your HTTPS key and cert file, please read > **[HTTPS API](./http-api.md#https-api)** > and **[HTTPS Callback](./http-callback.md#https-callback)** -> and **[HTTPS Live Streaming](./delivery-http-flv.md#https-flv-live-stream)**, +> and **[HTTPS Live Streaming](./flv.md#https-flv-live-stream)**, > however HTTPS proxy also works perfect with SRS such as Nginx. Push stream to SRS by [WebRTC: Publish](https://192.168.3.82:8088/players/rtc_publisher.html?autostart=true&stream=livestream&api=1990&schema=https) diff --git a/versioned_docs/version-5.0/doc/hls.md b/versioned_docs/version-5.0/doc/hls.md index 1e03ae37..6d8db8c5 100644 --- a/versioned_docs/version-5.0/doc/hls.md +++ b/versioned_docs/version-5.0/doc/hls.md @@ -46,7 +46,7 @@ ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream Open the following page to play the stream (if SRS is not on your local machine, replace localhost with the server IP): -* HLS (by [VLC](https://www.videolan.org/)): `http://localhost:8080/live/livestream.m3u8` +* HLS by SRS player: [http://localhost:8080/live/livestream.m3u8](http://localhost:8080/players/srs_player.html?stream=livestream.m3u8) > Note: Please wait about 10 seconds before playing the stream, otherwise it will fail, as it takes some time to generate the first segment. @@ -260,6 +260,8 @@ vhost __defaultVhost__ { } ``` +> Note: These settings are only for playing HLS. For streaming settings, please follow your protocol, like referring to [RTMP](./rtmp.md#config), [SRT](./srt.md#config), or [WebRTC](./webrtc.md#config) streaming configurations. + Here are the main settings: * enabled: Turn HLS on/off, default is off. * hls_fragment: Seconds, specify the minimum length of ts slices. For the actual length of ts files, please refer to the detailed description of [HLS TS Duration](#hls-ts-duration). @@ -409,7 +411,7 @@ vhost __defaultVhost__ { Of course, you can't reduce it too much, as it may cause insufficient buffering for the player or skipping when the player's network is poor, possibly resulting in playback failure. The lower the latency, the higher the chance of buffering. HLS latency cannot be less than 5 seconds, especially considering CDN and player compatibility. -If you need latency within 5 seconds, consider using protocols like [HTTP-FLV](./sample-http-flv.md), [SRT](./srt.md), or [WebRTC](./webrtc.md). +If you need latency within 5 seconds, consider using protocols like [HTTP-FLV](./flv.md), [SRT](./srt.md), or [WebRTC](./webrtc.md). ## ON HLS Notify diff --git a/versioned_docs/version-5.0/doc/http-api.md b/versioned_docs/version-5.0/doc/http-api.md index 3677f947..d5bd609a 100644 --- a/versioned_docs/version-5.0/doc/http-api.md +++ b/versioned_docs/version-5.0/doc/http-api.md @@ -257,7 +257,7 @@ http_api { > Remark: Please use your HTTPS key and cert file. -> Note: To enable the HTTPS live streaming, please read [HTTPS FLV Live Stream](./delivery-http-flv.md#https-flv-live-stream) +> Note: To enable the HTTPS live streaming, please read [HTTPS FLV Live Stream](./flv.md#https-flv-live-stream) ## HTTP and HTTPS Proxy diff --git a/versioned_docs/version-5.0/doc/http-server.md b/versioned_docs/version-5.0/doc/http-server.md index 6005a88a..a68cf4e0 100644 --- a/versioned_docs/version-5.0/doc/http-server.md +++ b/versioned_docs/version-5.0/doc/http-server.md @@ -94,6 +94,50 @@ Remark: The `http_stream` of SRS1 renamed to `http_server` in SRS2, which specif Remark: The `http` of vhost of SRS1 renamed to `http_static`, similar to global `http_server` for HTTP static files delivery. While the `http_remux` introduced in SRS2 is dynamic remux RTMP to HTTP Live FLV/Mp3/Aac/HLS/Hds/MPEG-DASH stream. +## HTTPS Server + +SRS supports HTTPS, just enable it in the configuration. By default, it uses a sub-signed certificate. If you need +to use a CA-issued certificate, please replace the relevant files. The related configuration is as follows: + +```bash +http_server { + https { + # Whether enable HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_ENABLED + # default: off + enabled on; + # The listen endpoint for HTTPS Streaming. + # Overwrite by env SRS_HTTP_SERVER_HTTPS_LISTEN + # default: 8088 + listen 8088; + # The SSL private key file, generated by: + # openssl genrsa -out server.key 2048 + # Overwrite by env SRS_HTTP_SERVER_HTTPS_KEY + # default: ./conf/server.key + key ./conf/server.key; + # The SSL public cert file, generated by: + # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" + # Overwrite by env SRS_HTTP_SERVER_HTTPS_CERT + # default: ./conf/server.crt + cert ./conf/server.crt; + } +} +``` + +## Crossdomain + +SRS has CORS (Cross-Origin Resource Sharing) support enabled by default. The related configuration is as follows: + +```bash +http_server { + # whether enable crossdomain request. + # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN + # default: on + crossdomain on; +} +``` + ## MIME Only some MIME is supported: diff --git a/versioned_docs/version-5.0/doc/resource.md b/versioned_docs/version-5.0/doc/resource.md index 5fa11aa3..04d487d7 100644 --- a/versioned_docs/version-5.0/doc/resource.md +++ b/versioned_docs/version-5.0/doc/resource.md @@ -15,7 +15,7 @@ The ports used by SRS, kernel services: * `tcp://1935`, for [RTMP live streaming server](./rtmp.md). * `tcp://1985`, HTTP API server, for [HTTP-API](./http-api.md), [WebRTC](./webrtc.md), etc. -* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./sample-http-flv.md), [HLS](./hls.md) as such. +* `tcp://8080`, HTTP live streaming server, [HTTP-FLV](./flv.md), [HLS](./hls.md) as such. * `udp://8000`, [WebRTC Media](./webrtc.md) server. For optional HTTPS services, which might be provided by other web servers: diff --git a/versioned_docs/version-5.0/doc/rtmp-pk-http.md b/versioned_docs/version-5.0/doc/rtmp-pk-http.md index 01fa8948..edf4b503 100644 --- a/versioned_docs/version-5.0/doc/rtmp-pk-http.md +++ b/versioned_docs/version-5.0/doc/rtmp-pk-http.md @@ -9,7 +9,7 @@ hide_table_of_contents: false There are two major methods to deliver video over internet, Live and WebRTC. -* Live streaming: [HLS](./hls.md), [RTMP](./rtmp.md) and [HTTP-FLV](./delivery-http-flv.md) for entertainment. +* Live streaming: [HLS](./hls.md), [RTMP](./rtmp.md) and [HTTP-FLV](./flv.md) for entertainment. * WebRTC: [RTC](./webrtc.md), for communication. Ignore other delivery protocol, which is not used on internet: diff --git a/versioned_docs/version-5.0/doc/rtmp.md b/versioned_docs/version-5.0/doc/rtmp.md index 78c32408..95216de5 100644 --- a/versioned_docs/version-5.0/doc/rtmp.md +++ b/versioned_docs/version-5.0/doc/rtmp.md @@ -270,7 +270,7 @@ If want to convert RTMP to HLS, please see [HLS](./hls.md). ## Converting RTMP to HTTP-FLV -If want to convert RTMP to HTTP-FLV or HTTP-TS, please see [HTTP-FLV](./sample-http-flv.md). +If want to convert RTMP to HTTP-FLV or HTTP-TS, please see [HTTP-FLV](./flv.md). ## Converting RTMP to WebRTC diff --git a/versioned_docs/version-5.0/doc/sample-http-flv-cluster.md b/versioned_docs/version-5.0/doc/sample-http-flv-cluster.md index 9ff995e7..49f7b852 100644 --- a/versioned_docs/version-5.0/doc/sample-http-flv-cluster.md +++ b/versioned_docs/version-5.0/doc/sample-http-flv-cluster.md @@ -7,7 +7,7 @@ hide_table_of_contents: false # HTTP FLV Cluster Example -About the HTTP FLV cluster of SRS, read [HTTP FLV](./delivery-http-flv.md#about-http-flv) +About the HTTP FLV cluster of SRS, read [HTTP FLV](./flv.md#about-http-flv) How to use multiple process for HTTP FLV? Please read [Reuse Port](./reuse-port.md) for detail. @@ -40,7 +40,7 @@ For detail, read [Build](./install.md) ## Step 3, config origin SRS -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Save bellow as config, or use `conf/http.flv.live.conf`: @@ -64,7 +64,7 @@ vhost __defaultVhost__ { ## Step 4, config edge SRS -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Save bellow as config, or use `conf/http.flv.live.edge1.conf` or `conf/http.flv.live.edge2.conf`: @@ -92,7 +92,7 @@ vhost __defaultVhost__ { ## Step 5, start SRS -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) ```bash ./objs/srs -c conf/http.flv.live.conf & @@ -102,7 +102,7 @@ For detail, read [HTTP FLV](./delivery-http-flv.md) ## Step 6, start Encoder -For detail, read read [HTTP FLV](./delivery-http-flv.md) +For detail, read read [HTTP FLV](./flv.md) Use FFMPEG to publish stream: @@ -136,7 +136,7 @@ The streams on SRS edge2: ## Step 7, play RTMP -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Origin RTMP url is: `rtmp://192.168.1.170:1935/live/livestream`, User can use vlc to play the RTMP stream. @@ -148,7 +148,7 @@ Note: Please replace all ip 192.168.1.170 to your server ip. ## Step 8, play HTTP FLV -For detail, read [HTTP FLV](./delivery-http-flv.md) +For detail, read [HTTP FLV](./flv.md) Origin HTTP FLV url: `http://192.168.1.170:8080/live/livestream.flv`, User can use vlc to play the HLS stream. Or, use online SRS player(you must input the flv url): [srs-player](https://ossrs.net/players/srs_player.html) diff --git a/versioned_docs/version-5.0/doc/sample-http-flv.md b/versioned_docs/version-5.0/doc/sample-http-flv.md index e6934013..6f7e3eff 100644 --- a/versioned_docs/version-5.0/doc/sample-http-flv.md +++ b/versioned_docs/version-5.0/doc/sample-http-flv.md @@ -7,110 +7,7 @@ hide_table_of_contents: false # HTTP FLV deploy example -About the HTTP FLV of SRS, read [HTTP FLV](./delivery-http-flv.md#about-http-flv) - -How to use multiple process for HTTP FLV? Please read [Reuse Port](./reuse-port.md) for detail. - -**Suppose the server ip is 192.168.1.170** - -## Step 1, get SRS - -For detail, read [GIT](./git.md) - -```bash -git clone https://github.com/ossrs/srs -cd srs/trunk -``` - -Or update the exists code: - -```bash -git pull -``` - -## Step 2, build SRS - -For detail, read [Build](./install.md) - -```bash -./configure && make -``` - -## Step 3, config SRS - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -Save bellow as config, or use `conf/http.flv.live.conf`: - -```bash -# conf/http.flv.live.conf -listen 1935; -max_connections 1000; -http_server { - enabled on; - listen 8080; - dir ./objs/nginx/html; -} -vhost __defaultVhost__ { - http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; - hstrs on; - } -} -``` - -## Step 4, start SRS - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -```bash -./objs/srs -c conf/http.flv.live.conf -``` - -## Step 5, start Encoder - -For detail, read read [HTTP FLV](./delivery-http-flv.md) - -Use FFMPEG to publish stream: - -```bash - for((;;)); do \ - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.flv \ - -c copy \ - -f flv rtmp://192.168.1.170/live/livestream; \ - sleep 1; \ - done -``` - -Or use FMLE to publish: - -```bash -FMS URL: rtmp://192.168.1.170/live -Stream: livestream -``` - -The streams on SRS: -* RTMP: `rtmp://192.168.1.170/live/livestream` -* HTTP FLV: `http://192.168.1.170:8080/live/livestream.flv` - -## Step 6, play RTMP - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -RTMP url is: `rtmp://192.168.1.170:1935/live/livestream`, User can use vlc to play the RTMP stream. - -Note: Please replace all ip 192.168.1.170 to your server ip. - -## Step 7, play HTTP FLV - -For detail, read [HTTP FLV](./delivery-http-flv.md) - -HTTP FLV url: `http://192.168.1.170:8080/live/livestream.flv`, User can use vlc to play the HLS stream. Or, use online SRS player(you must input the flv url): [srs-player](https://ossrs.net/players/srs_player.html) - -Note: Please replace all ip 192.168.1.170 to your server ip. - -Winlin 2014.11 +Migrated to [HTTP-FLV](./flv.md). ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.io&path=/lts/doc/en/v5/sample-http-flv) diff --git a/versioned_docs/version-5.0/doc/srt.md b/versioned_docs/version-5.0/doc/srt.md index 87e4f382..1bf5fedb 100644 --- a/versioned_docs/version-5.0/doc/srt.md +++ b/versioned_docs/version-5.0/doc/srt.md @@ -9,6 +9,10 @@ hide_table_of_contents: false See [SRT](./sample-srt.md). +## Config + +On the way. + ![](https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/lts/doc/en/v5/srt) diff --git a/versioned_sidebars/version-5.0-sidebars.json b/versioned_sidebars/version-5.0-sidebars.json index 8cbceddc..5fd38e56 100644 --- a/versioned_sidebars/version-5.0-sidebars.json +++ b/versioned_sidebars/version-5.0-sidebars.json @@ -37,7 +37,7 @@ "doc/rtmp", "doc/hls", "doc/webrtc", - "doc/sample-http-flv", + "doc/flv", "doc/sample-srt", "doc/gb28181", "doc/sample-dash",