Skip to main content
Version: 5.0 (Stable) ✅


The url of RTMP is simple, and the vhost is not a new concept, although it's easy to confuse for the fresh. What is vhost? What is app? Why FMLE should input the app and stream?

Vhost(Virtual Host) is used to seperate customers or businesses. Let's take a look at the typical use scenaio of vhost.

The benifit of RTMP and HLS, see: HLS

Use Scenario

The use scenario of vhost:

  • Multiple customers cloud: For example, CDN(content delivery network) serves multiple customers. How does CDN to seperate customer and stat the data? Maybe stream path is duplicated, for example, live/livestream is the most frequently used app and stream. The vhost, similar to the virtual server, provides abstract for multiple customers.
  • Different config: For example, FMLE publish h264+mp3, which should be transcoded to h264+aac. We can use vhost to use different config, h264+mp3 disabled hls while the h264+aac vhost enalbe hls.

In a word, vhost is the element of config, to seperate customer and apply different config.

Standard RTMP URL

Standard RTMP URL is the most compatible URL, for all servers and players can identify. The RTMP URL is similar to the HTTP URL:


It is:

  • Schema:The protocol prefix, HTTP/HTTPS for HTTP protocol, and RTMP/RTMPS/RTMPE/RTMPT for RTMP protocol, while the RTMFP is adobe flash p2p protocol.
  • Host:The server ip or dns name to connect to. It is dns name for CDN, and the dns name is used as the vhost for the specified customer.
  • Port:The tcp port, default 80 for HTTP and 1935 for RTMP.
  • Path:The http file path for HTTP.
  • App:The application for RTMP, similar to the directory of resource(stream).
  • Stream:The stream for RTMP, similar to the resource(file) in specified app.

NO Vhost

However, most user donot need the vhost, and it's a little complex, so donot use it when you donot need it. Most user actually only need app and stream.

When to use vhost? When you serve 100+ customers and use the same delivery network, they use theire own vhost and can use the sample app and stream.

The common use scenario, for example, if you use SRS to build a video website. So you are the only customer, donot need vhost. Suppose you provides video chat, there are some categories which includes some chat rooms. For example, categories are military, reader, history. The military category has rooms rock, radar; the reader category has red_masion. The config of SRS is very simple:

listen              1935;
vhost __defaultVhost__ {

When generate web pages, for instance, military category, all app is military. The url of chat room is rtmp://, while the encoder publish this stream, and all player play this stream.

The other pages of the military category use the same app name military, but use the different stream name, fr example, radar chat room use the stream url rtmp://

When generate the pages, add new stream, the config of SRS no need to change. For example, when add a new chat room cannon, no need to change config of SRS. It is simple enough!

The reader category can use app reader, and the red_mansion chat room can use the url rtmp://

Vhost Use Scenarios

The vhost of RTMP is same to HTTP virtual server. For example, the is resolve to by dns or hosts:


The use scenario of vhost:

  • Multiple Customers: When need to serve multiple customers use the same network, for example, cctv and wasu delivery stream on the same CDN, how to seperate them, when they use the same app and stream?
  • DNS scheduler: When CDN delivery content, the fast edge for the specified user is resolved for the dns name. We can use vhost as the dns name to scheduler user to different edge.
  • Multiple Config sections: Sometimes we need different config, for example, to delivery RTMP for PC and transcode RTMP to HLS for android and IOS, we can use one vhost to delivery RTMP and another for HLS.

Multiple Customers

For example, we got two customers cctv and wasu, use the same edge server, when user access the stream of these two customers:


The config on the edge, need to config the vhost:

listen              1935;
vhost {
vhost {


Please refer to the tech for DNS and CDN.

Config Unit

For example, two customers cctv and wasu, and cctv needs mininum latency, while wasu needs fast startup.

Then we config the cctv without gop cache, and wasu config with gop cache:

listen              1935;
vhost {
    chunk_size 128;
vhost {
    chunk_size 4096;

These two vhosts is completely isolated.

Default Vhost

The default vhost is __defaultVhost_\ introduced by FMS. When mismatch and vhost not found, use the default vhost if configed.

For example, the config of SRS on

listen              1935;
vhost {

Then, when user access the vhost:

  • rtmp://, matched vhost is
  • rtmp://, no matched vhost, and no default vhost.

The rule of default vhost is same to other vhost, the default is used for the vhost not matched and not find.

Locate Vhost

There are two ways to access the vhost on server:

  • DNS name: When access the dns name equals to the vhost, by dns resolve or hosts file, we can access the vhost on server.
  • Stream parameters: While publishing or playing stream, the parameter can take the vhost. This needs the server supports this way, for example, SRS can use parameter ?vhost=VHOST and ?domain=VHOST to access specified vhost.

For example:

RTMP URL: rtmp://
Edge servers: 50 servers
Edge server ip: to
Edge SRS config:
    listen              1935;
    vhost {
        mode remote;
        origin: xxxxxxx;

The ways to access the url on edge servers:

UserRTMP URLhostsTarget
Userrtmp:// by DNS
DevOpsrtmp:// demo.srs.comConnect to
-Connect to
-Connect to

It is sample way to access other servers.

Parameters in URL

There is no parameters for RTMP URL, similar to query string of HTTP, we can pass parameters in RTMP URL for SRS:

  • Vhost:Specifies the vhost in the RTMP URL for SRS.
  • Token authentication: Not implements for SRS, while user can specifies the token in the RTMP URL, SRS can fetch the token and verify it on remote authentication server. The token authentication is better and complex than refer authentication.

The parameters in SRS URL:

  • rtmp://
  • rtmp://
  • rtmp://
  • rtmp://

Note: FMLE passes the parameters in app, which should not be used now, because it confuses people.

It's also applied to other protocols, for example:

  • webrtc://

Note: SRT is another story, please read SRT Parameters for details.


SRS always simplify the problem, never make it more complex.

The RTMP URL of SRS use standard RTMP URL. Generally do not need to modify the url or add parameters in it, except:

  • Change vhost: Manually change vhost in RTMP URL for debuging.
  • Token authentication: To support token authentication.

Furthermore, recomment user to use one level app and stream, never use multiple level app and stream. For example:

// Not recomment multiple level app and stream, which confuse people.

The srs_player and srs_publisher donot support multiple level app and stream. Both srs_player and srs_publisher make the word behind the last / to stream, the left is tcUrl(vhost/app). For example:

// For both srs_player and srs_publisher:
// play or publish the following rtmp URL:
schema: rtmp
app: show/live/livestream
stream: 2013

It simplify the url, the palyer and publisher only need user to input a url, not tcUrl and stream.


rtmp:// RTMP URL
rtmp:// specifies vhost
rtmp:// specifies token authentication

Example Vhosts in SRS

The full.conf of conf of SRS contains many vhost, which used to show each feature. All features is put into the vhost

RTMPdefaultVhostDefault Vhost, only RTMP.
RTMPchunksize.vhost.comSample to set the chunk_size.
Forwardsame.vhost.forward.vhost.comSample for Foward stream to the same vhost.
HLSwith-hls.vhost.comSample for HLS.
HLSno-hls.vhost.comSample to disable the HLS.
RTMPmin.delay.comSample to config the minimum latency for RTMP.
RTMPrefer.anti_suck.comSample for Refer anti-suck DRM.
RTMPremoved.vhost.comSample to disable vhost.
Callbackhooks.callback.vhost.comSample for http callback.
Transcodemirror.transcode.vhost.comSample for transcode, to use the sample filter of FFMPEG.
Transcodecrop.transcode.vhost.comSample for transcode, to use the crop filter of FFMPEG.
Transcodelogo.transcode.vhost.comSample for transcode, to use the logo filter of FFMPEG.
Transcodeaudio.transcode.vhost.comSample for transcode, to transcode audio only.
Transcodecopy.transcode.vhost.comSample for transcode, demux and mux.
Transcodeall.transcode.vhost.comSample for transcode, all transcode features.
Transcodeffempty.transcode.vhost.comSample for empty transcode, display the parameters.
Transcodeapp.transcode.vhost.comSample for transcode, transcode specified app streams.
Transcodestream.transcode.vhost.comSample for transcode, transcode specified streams.

The demo.conf of conf of SRS, used for demo of SRS。

DEMOplayersThe vhost for default stream of srs_player, ingest this stream.
DEMOplayers_pubThe vhost for the srs_publisher to publish stream to.
DEMOplayers_pub_rtmpThe low latency vhost for demo.
DEMOdemo.srs.comThe full features for demo.
OthersdevThe vhost for dev, ignore.

Winlin 2014.10