正在显示
8 个修改的文件
包含
813 行增加
和
856 行删除
| @@ -52,7 +52,7 @@ cd simple-rtmp-server/trunk | @@ -52,7 +52,7 @@ cd simple-rtmp-server/trunk | ||
| 52 | <strong>Step 2:</strong> build SRS, | 52 | <strong>Step 2:</strong> build SRS, |
| 53 | <strong>Requires Centos6.x/Ubuntu12 32/64bits, others see [Build](https://github.com/winlinvip/simple-rtmp-server/wiki/Build)</strong><br/> | 53 | <strong>Requires Centos6.x/Ubuntu12 32/64bits, others see [Build](https://github.com/winlinvip/simple-rtmp-server/wiki/Build)</strong><br/> |
| 54 | <pre> | 54 | <pre> |
| 55 | -./configure --with-ssl --without-hls --without-ffmpeg --without-http && make | 55 | +./configure --with-ssl --without-hls --without-ffmpeg --without-http-callback && make |
| 56 | </pre> | 56 | </pre> |
| 57 | <strong>Step 3:</strong> start SRS <br/> | 57 | <strong>Step 3:</strong> start SRS <br/> |
| 58 | <pre> | 58 | <pre> |
trunk/conf/demo.conf
0 → 100644
| 1 | +listen 1935; | ||
| 2 | +chunk_size 60000; | ||
| 3 | +log_dir ./objs/logs; | ||
| 4 | +max_connections 2000; | ||
| 5 | + | ||
| 6 | +vhost __defaultVhost__ { | ||
| 7 | + enabled on; | ||
| 8 | + gop_cache on; | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +vhost bandcheck.srs.com { | ||
| 12 | + enabled on; | ||
| 13 | + chunk_size 65000; | ||
| 14 | + bandcheck { | ||
| 15 | + enabled on; | ||
| 16 | + key "35c9b402c12a7246868752e2878f7e0e"; | ||
| 17 | + interval 30; | ||
| 18 | + limit_kbps 4000; | ||
| 19 | + } | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +vhost demo.srs.com { | ||
| 23 | + chunk_size 60000; | ||
| 24 | + enabled on; | ||
| 25 | + gop_cache on; | ||
| 26 | + queue_length 30; | ||
| 27 | + forward 127.0.0.1:19350; | ||
| 28 | + bandcheck { | ||
| 29 | + enabled off; | ||
| 30 | + } | ||
| 31 | + hls { | ||
| 32 | + enabled on; | ||
| 33 | + hls_path ./objs/nginx/html; | ||
| 34 | + hls_fragment 5; | ||
| 35 | + hls_window 30; | ||
| 36 | + } | ||
| 37 | + http_hooks { | ||
| 38 | + enabled on; | ||
| 39 | + on_connect http://127.0.0.1:8085/api/v1/clients; | ||
| 40 | + on_close http://127.0.0.1:8085/api/v1/clients; | ||
| 41 | + on_publish http://127.0.0.1:8085/api/v1/streams; | ||
| 42 | + on_unpublish http://127.0.0.1:8085/api/v1/streams; | ||
| 43 | + on_play http://127.0.0.1:8085/api/v1/sessions; | ||
| 44 | + on_stop http://127.0.0.1:8085/api/v1/sessions; | ||
| 45 | + } | ||
| 46 | + transcode { | ||
| 47 | + enabled on; | ||
| 48 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 49 | + engine ld { | ||
| 50 | + enabled on; | ||
| 51 | + vfilter { | ||
| 52 | + vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontsize=30:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | ||
| 53 | + } | ||
| 54 | + vcodec libx264; | ||
| 55 | + vbitrate 300; | ||
| 56 | + vfps 20; | ||
| 57 | + vwidth 768; | ||
| 58 | + vheight 320; | ||
| 59 | + vthreads 1; | ||
| 60 | + vprofile baseline; | ||
| 61 | + vpreset superfast; | ||
| 62 | + vparams { | ||
| 63 | + } | ||
| 64 | + acodec libaacplus; | ||
| 65 | + abitrate 45; | ||
| 66 | + asample_rate 44100; | ||
| 67 | + achannels 2; | ||
| 68 | + aparams { | ||
| 69 | + } | ||
| 70 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 71 | + } | ||
| 72 | + engine sd { | ||
| 73 | + enabled on; | ||
| 74 | + vfilter { | ||
| 75 | + vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; | ||
| 76 | + } | ||
| 77 | + vcodec libx264; | ||
| 78 | + vbitrate 500; | ||
| 79 | + vfps 20; | ||
| 80 | + vwidth 768; | ||
| 81 | + vheight 320; | ||
| 82 | + vthreads 1; | ||
| 83 | + vprofile main; | ||
| 84 | + vpreset fast; | ||
| 85 | + vparams { | ||
| 86 | + } | ||
| 87 | + acodec libaacplus; | ||
| 88 | + abitrate 40; | ||
| 89 | + asample_rate 44100; | ||
| 90 | + achannels 2; | ||
| 91 | + aparams { | ||
| 92 | + } | ||
| 93 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +vhost players { | ||
| 99 | + enabled on; | ||
| 100 | + gop_cache on; | ||
| 101 | + transcode { | ||
| 102 | + enabled on; | ||
| 103 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 104 | + engine hls { | ||
| 105 | + enabled on; | ||
| 106 | + vfilter { | ||
| 107 | + vf 'drawtext=text=SRS(SimpleRtmpServer):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | ||
| 108 | + } | ||
| 109 | + vcodec libx264; | ||
| 110 | + vbitrate 300; | ||
| 111 | + vfps 20; | ||
| 112 | + vwidth 768; | ||
| 113 | + vheight 320; | ||
| 114 | + vthreads 1; | ||
| 115 | + vprofile baseline; | ||
| 116 | + vpreset superfast; | ||
| 117 | + vparams { | ||
| 118 | + g 100; | ||
| 119 | + } | ||
| 120 | + acodec libaacplus; | ||
| 121 | + abitrate 30; | ||
| 122 | + asample_rate 44100; | ||
| 123 | + achannels 2; | ||
| 124 | + aparams { | ||
| 125 | + } | ||
| 126 | + output rtmp://127.0.0.1:[port]/[app]?vhost=players_pub/[stream]; | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +vhost players_pub { | ||
| 132 | + hls { | ||
| 133 | + enabled on; | ||
| 134 | + hls_path ./objs/nginx/html; | ||
| 135 | + hls_fragment 5; | ||
| 136 | + hls_window 30; | ||
| 137 | + } | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +vhost players_pub_rtmp { | ||
| 141 | + gop_cache off; | ||
| 142 | + hls { | ||
| 143 | + enabled off; | ||
| 144 | + } | ||
| 145 | +} |
trunk/conf/full.conf
0 → 100644
| 1 | +# the listen ports, split by space. | ||
| 2 | +listen 1935; | ||
| 3 | +# the default chunk size is 128, max is 65536, | ||
| 4 | +# some client does not support chunk size change, | ||
| 5 | +# however, most clients supports it and it can improve | ||
| 6 | +# performance about 10%. | ||
| 7 | +# default: 60000 | ||
| 8 | +chunk_size 60000; | ||
| 9 | +# the logs dir. | ||
| 10 | +# if enabled ffmpeg, each stracoding stream will create a log file. | ||
| 11 | +# default: ./objs/logs | ||
| 12 | +log_dir ./objs/logs; | ||
| 13 | +# the max connections. | ||
| 14 | +# if exceed the max connections, server will drop the new connection. | ||
| 15 | +# default: 2000 | ||
| 16 | +max_connections 2000; | ||
| 17 | +# vhost list, the __defaultVhost__ is the default vhost | ||
| 18 | +# for example, user use ip to access the stream: rtmp://192.168.1.2/live/livestream. | ||
| 19 | +# for which cannot identify the required vhost. | ||
| 20 | +vhost __defaultVhost__ { | ||
| 21 | + enabled on; | ||
| 22 | + gop_cache on; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +# vhost for bandwidth check | ||
| 26 | +# generally, the bandcheck vhost must be: bandcheck.srs.com, | ||
| 27 | +# or need to modify the vhost of client. | ||
| 28 | +vhost bandcheck.srs.com { | ||
| 29 | + enabled on; | ||
| 30 | + chunk_size 65000; | ||
| 31 | + # bandwidth check config. | ||
| 32 | + bandcheck { | ||
| 33 | + # whether support bandwidth check, | ||
| 34 | + # default: off. | ||
| 35 | + enabled on; | ||
| 36 | + # the key for server to valid, | ||
| 37 | + # if invalid key, server disconnect and abort the bandwidth check. | ||
| 38 | + key "35c9b402c12a7246868752e2878f7e0e"; | ||
| 39 | + # the interval in seconds for bandwidth check, | ||
| 40 | + # server donot allow new test request. | ||
| 41 | + # default: 30 | ||
| 42 | + interval 30; | ||
| 43 | + # the max available check bandwidth in kbps. | ||
| 44 | + # to avoid attack of bandwidth check. | ||
| 45 | + # default: 1000 | ||
| 46 | + limit_kbps 4000; | ||
| 47 | + } | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +# set the chunk size of vhost. | ||
| 51 | +vhost chunksize.vhost.com { | ||
| 52 | + # the default chunk size is 128, max is 65536, | ||
| 53 | + # some client does not support chunk size change, | ||
| 54 | + # vhost chunk size will override the global value. | ||
| 55 | + # default: global chunk size. | ||
| 56 | + chunk_size 128; | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +# the http hook callback vhost, srs will invoke the hooks for specified events. | ||
| 60 | +vhost hooks.callback.vhost.com { | ||
| 61 | + http_hooks { | ||
| 62 | + # whether the http hooks enalbe. | ||
| 63 | + # default off. | ||
| 64 | + enabled on; | ||
| 65 | + # when client connect to vhost/app, call the hook, | ||
| 66 | + # the request in the POST data string is a object encode by json: | ||
| 67 | + # { | ||
| 68 | + # "action": "on_connect", | ||
| 69 | + # "client_id": 1985, | ||
| 70 | + # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 71 | + # "pageUrl": "http://www.test.com/live.html" | ||
| 72 | + # } | ||
| 73 | + # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 74 | + # an int value specifies the error code(0 corresponding to success): | ||
| 75 | + # 0 | ||
| 76 | + # support multiple api hooks, format: | ||
| 77 | + # on_connect http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 78 | + on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; | ||
| 79 | + # when client close/disconnect to vhost/app/stream, call the hook, | ||
| 80 | + # the request in the POST data string is a object encode by json: | ||
| 81 | + # { | ||
| 82 | + # "action": "on_close", | ||
| 83 | + # "client_id": 1985, | ||
| 84 | + # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live" | ||
| 85 | + # } | ||
| 86 | + # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 87 | + # an int value specifies the error code(0 corresponding to success): | ||
| 88 | + # 0 | ||
| 89 | + # support multiple api hooks, format: | ||
| 90 | + # on_close http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 91 | + on_close http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; | ||
| 92 | + # when client(encoder) publish to vhost/app/stream, call the hook, | ||
| 93 | + # the request in the POST data string is a object encode by json: | ||
| 94 | + # { | ||
| 95 | + # "action": "on_publish", | ||
| 96 | + # "client_id": 1985, | ||
| 97 | + # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 98 | + # "stream": "livestream" | ||
| 99 | + # } | ||
| 100 | + # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 101 | + # an int value specifies the error code(0 corresponding to success): | ||
| 102 | + # 0 | ||
| 103 | + # support multiple api hooks, format: | ||
| 104 | + # on_publish http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 105 | + on_publish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; | ||
| 106 | + # when client(encoder) stop publish to vhost/app/stream, call the hook, | ||
| 107 | + # the request in the POST data string is a object encode by json: | ||
| 108 | + # { | ||
| 109 | + # "action": "on_unpublish", | ||
| 110 | + # "client_id": 1985, | ||
| 111 | + # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 112 | + # "stream": "livestream" | ||
| 113 | + # } | ||
| 114 | + # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 115 | + # an int value specifies the error code(0 corresponding to success): | ||
| 116 | + # 0 | ||
| 117 | + # support multiple api hooks, format: | ||
| 118 | + # on_unpublish http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 119 | + on_unpublish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; | ||
| 120 | + # when client start to play vhost/app/stream, call the hook, | ||
| 121 | + # the request in the POST data string is a object encode by json: | ||
| 122 | + # { | ||
| 123 | + # "action": "on_play", | ||
| 124 | + # "client_id": 1985, | ||
| 125 | + # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 126 | + # "stream": "livestream" | ||
| 127 | + # } | ||
| 128 | + # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 129 | + # an int value specifies the error code(0 corresponding to success): | ||
| 130 | + # 0 | ||
| 131 | + # support multiple api hooks, format: | ||
| 132 | + # on_play http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 133 | + on_play http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; | ||
| 134 | + # when client stop to play vhost/app/stream, call the hook, | ||
| 135 | + # the request in the POST data string is a object encode by json: | ||
| 136 | + # { | ||
| 137 | + # "action": "on_stop", | ||
| 138 | + # "client_id": 1985, | ||
| 139 | + # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 140 | + # "stream": "livestream" | ||
| 141 | + # } | ||
| 142 | + # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 143 | + # an int value specifies the error code(0 corresponding to success): | ||
| 144 | + # 0 | ||
| 145 | + # support multiple api hooks, format: | ||
| 146 | + # on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 147 | + on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; | ||
| 148 | + } | ||
| 149 | +} | ||
| 150 | + | ||
| 151 | +# the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction | ||
| 152 | +vhost mirror.transcode.vhost.com { | ||
| 153 | + transcode { | ||
| 154 | + enabled on; | ||
| 155 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 156 | + engine mirror { | ||
| 157 | + enabled on; | ||
| 158 | + vfilter { | ||
| 159 | + vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; | ||
| 160 | + } | ||
| 161 | + vcodec libx264; | ||
| 162 | + vbitrate 300; | ||
| 163 | + vfps 20; | ||
| 164 | + vwidth 768; | ||
| 165 | + vheight 320; | ||
| 166 | + vthreads 2; | ||
| 167 | + vprofile baseline; | ||
| 168 | + vpreset superfast; | ||
| 169 | + vparams { | ||
| 170 | + } | ||
| 171 | + acodec libaacplus; | ||
| 172 | + abitrate 45; | ||
| 173 | + asample_rate 44100; | ||
| 174 | + achannels 2; | ||
| 175 | + aparams { | ||
| 176 | + } | ||
| 177 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | +} | ||
| 181 | +# the drawtext filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#drawtext-1 | ||
| 182 | +vhost drawtext.transcode.vhost.com { | ||
| 183 | + transcode { | ||
| 184 | + enabled on; | ||
| 185 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 186 | + engine drawtext { | ||
| 187 | + enabled on; | ||
| 188 | + vfilter { | ||
| 189 | + vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | ||
| 190 | + } | ||
| 191 | + vcodec libx264; | ||
| 192 | + vbitrate 300; | ||
| 193 | + vfps 20; | ||
| 194 | + vwidth 768; | ||
| 195 | + vheight 320; | ||
| 196 | + vthreads 2; | ||
| 197 | + vprofile baseline; | ||
| 198 | + vpreset superfast; | ||
| 199 | + vparams { | ||
| 200 | + } | ||
| 201 | + acodec libaacplus; | ||
| 202 | + abitrate 45; | ||
| 203 | + asample_rate 44100; | ||
| 204 | + achannels 2; | ||
| 205 | + aparams { | ||
| 206 | + } | ||
| 207 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | +} | ||
| 211 | +# the crop filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#crop | ||
| 212 | +vhost crop.transcode.vhost.com { | ||
| 213 | + transcode { | ||
| 214 | + enabled on; | ||
| 215 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 216 | + engine crop { | ||
| 217 | + enabled on; | ||
| 218 | + vfilter { | ||
| 219 | + vf 'crop=in_w-20:in_h-160:10:80'; | ||
| 220 | + } | ||
| 221 | + vcodec libx264; | ||
| 222 | + vbitrate 300; | ||
| 223 | + vfps 20; | ||
| 224 | + vwidth 768; | ||
| 225 | + vheight 320; | ||
| 226 | + vthreads 2; | ||
| 227 | + vprofile baseline; | ||
| 228 | + vpreset superfast; | ||
| 229 | + vparams { | ||
| 230 | + } | ||
| 231 | + acodec libaacplus; | ||
| 232 | + abitrate 45; | ||
| 233 | + asample_rate 44100; | ||
| 234 | + achannels 2; | ||
| 235 | + aparams { | ||
| 236 | + } | ||
| 237 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | +} | ||
| 241 | +# the logo filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#overlay | ||
| 242 | +vhost logo.transcode.vhost.com { | ||
| 243 | + transcode { | ||
| 244 | + enabled on; | ||
| 245 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 246 | + engine logo { | ||
| 247 | + enabled on; | ||
| 248 | + vfilter { | ||
| 249 | + i ./doc/ffmpeg-logo.png; | ||
| 250 | + filter_complex 'overlay=10:10'; | ||
| 251 | + } | ||
| 252 | + vcodec libx264; | ||
| 253 | + vbitrate 300; | ||
| 254 | + vfps 20; | ||
| 255 | + vwidth 768; | ||
| 256 | + vheight 320; | ||
| 257 | + vthreads 2; | ||
| 258 | + vprofile baseline; | ||
| 259 | + vpreset superfast; | ||
| 260 | + vparams { | ||
| 261 | + } | ||
| 262 | + acodec libaacplus; | ||
| 263 | + abitrate 45; | ||
| 264 | + asample_rate 44100; | ||
| 265 | + achannels 2; | ||
| 266 | + aparams { | ||
| 267 | + } | ||
| 268 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 269 | + } | ||
| 270 | + } | ||
| 271 | +} | ||
| 272 | +# audio transcode only. | ||
| 273 | +# for example, FMLE publish audio codec in mp3, and donot support HLS output, | ||
| 274 | +# we can transcode the audio to aac and copy video to the new stream with HLS. | ||
| 275 | +vhost audio.transcode.vhost.com { | ||
| 276 | + transcode { | ||
| 277 | + enabled on; | ||
| 278 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 279 | + engine acodec { | ||
| 280 | + enabled on; | ||
| 281 | + vcodec copy; | ||
| 282 | + acodec libaacplus; | ||
| 283 | + abitrate 45; | ||
| 284 | + asample_rate 44100; | ||
| 285 | + achannels 2; | ||
| 286 | + aparams { | ||
| 287 | + } | ||
| 288 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 289 | + } | ||
| 290 | + } | ||
| 291 | +} | ||
| 292 | +# ffmpeg-copy(forward implements by ffmpeg). | ||
| 293 | +# copy the video and audio to a new stream. | ||
| 294 | +vhost copy.transcode.vhost.com { | ||
| 295 | + transcode { | ||
| 296 | + enabled on; | ||
| 297 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 298 | + engine copy { | ||
| 299 | + enabled on; | ||
| 300 | + vcodec copy; | ||
| 301 | + acodec copy; | ||
| 302 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 303 | + } | ||
| 304 | + } | ||
| 305 | +} | ||
| 306 | +# transcode all app and stream of vhost | ||
| 307 | +vhost all.transcode.vhost.com { | ||
| 308 | + # the streaming transcode configs. | ||
| 309 | + transcode { | ||
| 310 | + # whether the transcode enabled. | ||
| 311 | + # if off, donot transcode. | ||
| 312 | + # default: off. | ||
| 313 | + enabled on; | ||
| 314 | + # the ffmpeg | ||
| 315 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 316 | + # the transcode engine for matched stream. | ||
| 317 | + # all matched stream will transcoded to the following stream. | ||
| 318 | + # the transcode set name(ie. hd) is optional and not used. | ||
| 319 | + engine ffsuper { | ||
| 320 | + # whether the engine is enabled | ||
| 321 | + # default: off. | ||
| 322 | + enabled on; | ||
| 323 | + # ffmpeg filters, follows the main input. | ||
| 324 | + vfilter { | ||
| 325 | + # the logo input file. | ||
| 326 | + i ./doc/ffmpeg-logo.png; | ||
| 327 | + # the ffmpeg complex filter. | ||
| 328 | + # for filters, @see: http://ffmpeg.org/ffmpeg-filters.html | ||
| 329 | + filter_complex 'overlay=10:10'; | ||
| 330 | + } | ||
| 331 | + # video encoder name. can be: | ||
| 332 | + # libx264: use h.264(libx264) video encoder. | ||
| 333 | + # copy: donot encoder the video stream, copy it. | ||
| 334 | + vcodec libx264; | ||
| 335 | + # video bitrate, in kbps | ||
| 336 | + vbitrate 1500; | ||
| 337 | + # video framerate. | ||
| 338 | + vfps 25; | ||
| 339 | + # video width, must be even numbers. | ||
| 340 | + vwidth 768; | ||
| 341 | + # video height, must be even numbers. | ||
| 342 | + vheight 320; | ||
| 343 | + # the max threads for ffmpeg to used. | ||
| 344 | + vthreads 12; | ||
| 345 | + # x264 profile, @see x264 -help, can be: | ||
| 346 | + # high,main,baseline | ||
| 347 | + vprofile main; | ||
| 348 | + # x264 preset, @see x264 -help, can be: | ||
| 349 | + # ultrafast,superfast,veryfast,faster,fast | ||
| 350 | + # medium,slow,slower,veryslow,placebo | ||
| 351 | + vpreset medium; | ||
| 352 | + # other x264 or ffmpeg video params | ||
| 353 | + vparams { | ||
| 354 | + # ffmpeg options, @see: http://ffmpeg.org/ffmpeg.html | ||
| 355 | + t 100; | ||
| 356 | + # 264 params, @see: http://ffmpeg.org/ffmpeg-codecs.html#libx264 | ||
| 357 | + coder 1; | ||
| 358 | + b_strategy 2; | ||
| 359 | + bf 3; | ||
| 360 | + refs 10; | ||
| 361 | + } | ||
| 362 | + # audio encoder name. can be: | ||
| 363 | + # libaacplus: use aac(libaacplus) audio encoder. | ||
| 364 | + # copy: donot encoder the audio stream, copy it. | ||
| 365 | + acodec libaacplus; | ||
| 366 | + # audio bitrate, in kbps. [16, 72] for libaacplus. | ||
| 367 | + abitrate 70; | ||
| 368 | + # audio sample rate. for flv/rtmp, it must be: | ||
| 369 | + # 44100,22050,11025,5512 | ||
| 370 | + asample_rate 44100; | ||
| 371 | + # audio channel, 1 for mono, 2 for stereo. | ||
| 372 | + achannels 2; | ||
| 373 | + # other ffmpeg audio params | ||
| 374 | + aparams { | ||
| 375 | + # audio params, @see: http://ffmpeg.org/ffmpeg-codecs.html#Audio-Encoders | ||
| 376 | + profile:a aac_low; | ||
| 377 | + } | ||
| 378 | + # output stream. variables: | ||
| 379 | + # [vhost] the input stream vhost. | ||
| 380 | + # [port] the intput stream port. | ||
| 381 | + # [app] the input stream app. | ||
| 382 | + # [stream] the input stream name. | ||
| 383 | + # [engine] the tanscode engine name. | ||
| 384 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 385 | + } | ||
| 386 | + engine ffhd { | ||
| 387 | + enabled on; | ||
| 388 | + vcodec libx264; | ||
| 389 | + vbitrate 1200; | ||
| 390 | + vfps 25; | ||
| 391 | + vwidth 1382; | ||
| 392 | + vheight 576; | ||
| 393 | + vthreads 6; | ||
| 394 | + vprofile main; | ||
| 395 | + vpreset medium; | ||
| 396 | + vparams { | ||
| 397 | + } | ||
| 398 | + acodec libaacplus; | ||
| 399 | + abitrate 70; | ||
| 400 | + asample_rate 44100; | ||
| 401 | + achannels 2; | ||
| 402 | + aparams { | ||
| 403 | + } | ||
| 404 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 405 | + } | ||
| 406 | + engine ffsd { | ||
| 407 | + enabled on; | ||
| 408 | + vcodec libx264; | ||
| 409 | + vbitrate 800; | ||
| 410 | + vfps 25; | ||
| 411 | + vwidth 1152; | ||
| 412 | + vheight 480; | ||
| 413 | + vthreads 4; | ||
| 414 | + vprofile main; | ||
| 415 | + vpreset fast; | ||
| 416 | + vparams { | ||
| 417 | + } | ||
| 418 | + acodec libaacplus; | ||
| 419 | + abitrate 60; | ||
| 420 | + asample_rate 44100; | ||
| 421 | + achannels 2; | ||
| 422 | + aparams { | ||
| 423 | + } | ||
| 424 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 425 | + } | ||
| 426 | + engine fffast { | ||
| 427 | + enabled on; | ||
| 428 | + vcodec libx264; | ||
| 429 | + vbitrate 300; | ||
| 430 | + vfps 20; | ||
| 431 | + vwidth 768; | ||
| 432 | + vheight 320; | ||
| 433 | + vthreads 2; | ||
| 434 | + vprofile baseline; | ||
| 435 | + vpreset superfast; | ||
| 436 | + vparams { | ||
| 437 | + } | ||
| 438 | + acodec libaacplus; | ||
| 439 | + abitrate 45; | ||
| 440 | + asample_rate 44100; | ||
| 441 | + achannels 2; | ||
| 442 | + aparams { | ||
| 443 | + } | ||
| 444 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 445 | + } | ||
| 446 | + engine vcopy { | ||
| 447 | + enabled on; | ||
| 448 | + vcodec copy; | ||
| 449 | + acodec libaacplus; | ||
| 450 | + abitrate 45; | ||
| 451 | + asample_rate 44100; | ||
| 452 | + achannels 2; | ||
| 453 | + aparams { | ||
| 454 | + } | ||
| 455 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 456 | + } | ||
| 457 | + engine acopy { | ||
| 458 | + enabled on; | ||
| 459 | + vcodec libx264; | ||
| 460 | + vbitrate 300; | ||
| 461 | + vfps 20; | ||
| 462 | + vwidth 768; | ||
| 463 | + vheight 320; | ||
| 464 | + vthreads 2; | ||
| 465 | + vprofile baseline; | ||
| 466 | + vpreset superfast; | ||
| 467 | + vparams { | ||
| 468 | + } | ||
| 469 | + acodec copy; | ||
| 470 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 471 | + } | ||
| 472 | + engine copy { | ||
| 473 | + enabled on; | ||
| 474 | + vcodec copy; | ||
| 475 | + acodec copy; | ||
| 476 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 477 | + } | ||
| 478 | + } | ||
| 479 | +} | ||
| 480 | +# transcode all stream using the empty ffmpeg demo, donothing. | ||
| 481 | +vhost ffempty.transcode.vhost.com { | ||
| 482 | + transcode { | ||
| 483 | + enabled on; | ||
| 484 | + ffmpeg ./objs/research/ffempty; | ||
| 485 | + engine empty { | ||
| 486 | + enabled on; | ||
| 487 | + vcodec libx264; | ||
| 488 | + vbitrate 300; | ||
| 489 | + vfps 20; | ||
| 490 | + vwidth 768; | ||
| 491 | + vheight 320; | ||
| 492 | + vthreads 2; | ||
| 493 | + vprofile baseline; | ||
| 494 | + vpreset superfast; | ||
| 495 | + vparams { | ||
| 496 | + } | ||
| 497 | + acodec libaacplus; | ||
| 498 | + abitrate 45; | ||
| 499 | + asample_rate 44100; | ||
| 500 | + achannels 2; | ||
| 501 | + aparams { | ||
| 502 | + } | ||
| 503 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 504 | + } | ||
| 505 | + } | ||
| 506 | +} | ||
| 507 | +# transcode all app and stream of app | ||
| 508 | +vhost app.transcode.vhost.com { | ||
| 509 | + # the streaming transcode configs. | ||
| 510 | + # if app specified, transcode all streams of app. | ||
| 511 | + transcode live { | ||
| 512 | + enabled on; | ||
| 513 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 514 | + engine { | ||
| 515 | + enabled off; | ||
| 516 | + } | ||
| 517 | + } | ||
| 518 | +} | ||
| 519 | +# transcode specified stream. | ||
| 520 | +vhost stream.transcode.vhost.com { | ||
| 521 | + # the streaming transcode configs. | ||
| 522 | + # if stream specified, transcode the matched stream. | ||
| 523 | + transcode live/livestream { | ||
| 524 | + enabled on; | ||
| 525 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 526 | + engine { | ||
| 527 | + enabled off; | ||
| 528 | + } | ||
| 529 | + } | ||
| 530 | +} | ||
| 531 | + | ||
| 532 | +# the vhost which forward publish streams. | ||
| 533 | +vhost same.vhost.forward.vhost.com { | ||
| 534 | + # forward all publish stream to the specified server. | ||
| 535 | + # this used to split/forward the current stream for cluster active-standby, | ||
| 536 | + # active-active for cdn to build high available fault tolerance system. | ||
| 537 | + # format: {ip}:{port} {ip_N}:{port_N} | ||
| 538 | + # or specify the vhost by params, @see: change.vhost.forward.vhost.com | ||
| 539 | + # if vhost not specified, use the request vhost instead. | ||
| 540 | + forward 127.0.0.1:1936 127.0.0.1:1937; | ||
| 541 | +} | ||
| 542 | +# TODO: FIXME: change the forward schema with vhost. | ||
| 543 | +# [plan] the vhost which forward publish streams to other vhosts. | ||
| 544 | +vhost change.vhost.forward.vhost.com { | ||
| 545 | + forward 127.0.0.1:1936 127.0.0.1:1937 { | ||
| 546 | + # specify the vhost to override the vhost in client request. | ||
| 547 | + vhost forward2.vhost.com; | ||
| 548 | + # specify the refer(pageUrl) to override the refer in client request. | ||
| 549 | + refer http://srs/index.html; | ||
| 550 | + } | ||
| 551 | + forward 127.0.0.1:1938 { | ||
| 552 | + vhost forward3.vhost.com; | ||
| 553 | + } | ||
| 554 | +} | ||
| 555 | + | ||
| 556 | +# the vhost disabled. | ||
| 557 | +vhost removed.vhost.com { | ||
| 558 | + # whether the vhost is enabled. | ||
| 559 | + # if off, all request access denied. | ||
| 560 | + # default: on | ||
| 561 | + enabled off; | ||
| 562 | +} | ||
| 563 | + | ||
| 564 | +# the vhost with hls specified. | ||
| 565 | +vhost with-hls.vhost.com { | ||
| 566 | + hls { | ||
| 567 | + # whether the hls is enabled. | ||
| 568 | + # if off, donot write hls(ts and m3u8) when publish. | ||
| 569 | + # default: off | ||
| 570 | + enabled on; | ||
| 571 | + # the hls output path. | ||
| 572 | + # the app dir is auto created under the hls_path. | ||
| 573 | + # for example, for rtmp stream: | ||
| 574 | + # rtmp://127.0.0.1/live/livestream | ||
| 575 | + # http://127.0.0.1/live/livestream.m3u8 | ||
| 576 | + # where hls_path is /hls, srs will create the following files: | ||
| 577 | + # /hls/live the app dir for all streams. | ||
| 578 | + # /hls/live/livestream.m3u8 the HLS m3u8 file. | ||
| 579 | + # /hls/live/livestream-1.ts the HLS media/ts file. | ||
| 580 | + # in a word, the hls_path is for vhost. | ||
| 581 | + # default: ./objs/nginx/html | ||
| 582 | + hls_path /data/nginx/html; | ||
| 583 | + # the hls fragment in seconds, the duration of a piece of ts. | ||
| 584 | + # default: 10 | ||
| 585 | + hls_fragment 10; | ||
| 586 | + # the hls window in seconds, the number of ts in m3u8. | ||
| 587 | + # default: 60 | ||
| 588 | + hls_window 60; | ||
| 589 | + } | ||
| 590 | +} | ||
| 591 | +# the vhost with hls disabled. | ||
| 592 | +vhost no-hls.vhost.com { | ||
| 593 | + hls { | ||
| 594 | + # whether the hls is enabled. | ||
| 595 | + # if off, donot write hls(ts and m3u8) when publish. | ||
| 596 | + # default: off | ||
| 597 | + enabled off; | ||
| 598 | + } | ||
| 599 | +} | ||
| 600 | + | ||
| 601 | +# the vhost for min delay, donot cache any stream. | ||
| 602 | +vhost min.delay.com { | ||
| 603 | + # whether cache the last gop. | ||
| 604 | + # if on, cache the last gop and dispatch to client, | ||
| 605 | + # to enable fast startup for client, client play immediately. | ||
| 606 | + # if off, send the latest media data to client, | ||
| 607 | + # client need to wait for the next Iframe to decode and show the video. | ||
| 608 | + # set to off if requires min delay; | ||
| 609 | + # set to on if requires client fast startup. | ||
| 610 | + # default: on | ||
| 611 | + gop_cache off; | ||
| 612 | + # the max live queue length in seconds. | ||
| 613 | + # if the messages in the queue exceed the max length, | ||
| 614 | + # drop the old whole gop. | ||
| 615 | + # default: 30 | ||
| 616 | + queue_length 10; | ||
| 617 | +} | ||
| 618 | + | ||
| 619 | +# the vhost for antisuck. | ||
| 620 | +vhost refer.anti_suck.com { | ||
| 621 | + # the common refer for play and publish. | ||
| 622 | + # if the page url of client not in the refer, access denied. | ||
| 623 | + # if not specified this field, allow all. | ||
| 624 | + # default: not specified. | ||
| 625 | + refer github.com github.io; | ||
| 626 | + # refer for publish clients specified. | ||
| 627 | + # the common refer is not overrided by this. | ||
| 628 | + # if not specified this field, allow all. | ||
| 629 | + # default: not specified. | ||
| 630 | + refer_publish github.com github.io; | ||
| 631 | + # refer for play clients specified. | ||
| 632 | + # the common refer is not overrided by this. | ||
| 633 | + # if not specified this field, allow all. | ||
| 634 | + # default: not specified. | ||
| 635 | + refer_play github.com github.io; | ||
| 636 | +} | ||
| 637 | + | ||
| 638 | +# config for the pithy print, | ||
| 639 | +# which always print constant message specified by interval, | ||
| 640 | +# whatever the clients in concurrency. | ||
| 641 | +pithy_print { | ||
| 642 | + # shared print interval for all publish clients, in milliseconds. | ||
| 643 | + # if not specified, set to 1100. | ||
| 644 | + publish 2000; | ||
| 645 | + # shared print interval for all play clients, in milliseconds. | ||
| 646 | + # if not specified, set to 1300. | ||
| 647 | + play 3000; | ||
| 648 | + # shared print interval for all forwarders, in milliseconds. | ||
| 649 | + # if not specified, set to 2000. | ||
| 650 | + forwarder 3000; | ||
| 651 | + # shared print interval for all encoders, in milliseconds. | ||
| 652 | + # if not specified, set to 2000. | ||
| 653 | + encoder 3000; | ||
| 654 | + # shared print interval for all hls, in milliseconds. | ||
| 655 | + # if not specified, set to 2000. | ||
| 656 | + hls 3000; | ||
| 657 | +} |
| 1 | -# the listen ports, split by space. | ||
| 2 | listen 1935; | 1 | listen 1935; |
| 3 | -# the default chunk size is 128, max is 65536, | ||
| 4 | -# some client does not support chunk size change, | ||
| 5 | -# however, most clients supports it and it can improve | ||
| 6 | -# performance about 10%. | ||
| 7 | -# default: 60000 | ||
| 8 | -chunk_size 60000; | ||
| 9 | -# the logs dir. | ||
| 10 | -# if enabled ffmpeg, each stracoding stream will create a log file. | ||
| 11 | -# default: ./objs/logs | ||
| 12 | -log_dir ./objs/logs; | ||
| 13 | -# the max connections. | ||
| 14 | -# if exceed the max connections, server will drop the new connection. | ||
| 15 | -# default: 2000 | ||
| 16 | -max_connections 2000; | ||
| 17 | -# vhost list, the __defaultVhost__ is the default vhost | ||
| 18 | -# for example, user use ip to access the stream: rtmp://192.168.1.2/live/livestream. | ||
| 19 | -# for which cannot identify the required vhost. | ||
| 20 | vhost __defaultVhost__ { | 2 | vhost __defaultVhost__ { |
| 21 | - enabled on; | ||
| 22 | - gop_cache on; | ||
| 23 | } | 3 | } |
| 24 | - | ||
| 25 | -# vhost for bandwidth check | ||
| 26 | -# generally, the bandcheck vhost must be: bandcheck.srs.com, | ||
| 27 | -# or need to modify the vhost of client. | ||
| 28 | -vhost bandcheck.srs.com { | ||
| 29 | - enabled on; | ||
| 30 | - chunk_size 65000; | ||
| 31 | - # bandwidth check config. | ||
| 32 | - bandcheck { | ||
| 33 | - # whether support bandwidth check, | ||
| 34 | - # default: off. | ||
| 35 | - enabled on; | ||
| 36 | - # the key for server to valid, | ||
| 37 | - # if invalid key, server disconnect and abort the bandwidth check. | ||
| 38 | - key "35c9b402c12a7246868752e2878f7e0e"; | ||
| 39 | - # the interval in seconds for bandwidth check, | ||
| 40 | - # server donot allow new test request. | ||
| 41 | - # default: 30 | ||
| 42 | - interval 30; | ||
| 43 | - # the max available check bandwidth in kbps. | ||
| 44 | - # to avoid attack of bandwidth check. | ||
| 45 | - # default: 1000 | ||
| 46 | - limit_kbps 4000; | ||
| 47 | - } | ||
| 48 | -} | ||
| 49 | - | ||
| 50 | -# set the chunk size of vhost. | ||
| 51 | -vhost chunksize.vhost.com { | ||
| 52 | - # the default chunk size is 128, max is 65536, | ||
| 53 | - # some client does not support chunk size change, | ||
| 54 | - # vhost chunk size will override the global value. | ||
| 55 | - # default: global chunk size. | ||
| 56 | - chunk_size 128; | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -# the http hook callback vhost, srs will invoke the hooks for specified events. | ||
| 60 | -vhost hooks.callback.vhost.com { | ||
| 61 | - http_hooks { | ||
| 62 | - # whether the http hooks enalbe. | ||
| 63 | - # default off. | ||
| 64 | - enabled on; | ||
| 65 | - # when client connect to vhost/app, call the hook, | ||
| 66 | - # the request in the POST data string is a object encode by json: | ||
| 67 | - # { | ||
| 68 | - # "action": "on_connect", | ||
| 69 | - # "client_id": 1985, | ||
| 70 | - # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 71 | - # "pageUrl": "http://www.test.com/live.html" | ||
| 72 | - # } | ||
| 73 | - # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 74 | - # an int value specifies the error code(0 corresponding to success): | ||
| 75 | - # 0 | ||
| 76 | - # support multiple api hooks, format: | ||
| 77 | - # on_connect http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 78 | - on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; | ||
| 79 | - # when client close/disconnect to vhost/app/stream, call the hook, | ||
| 80 | - # the request in the POST data string is a object encode by json: | ||
| 81 | - # { | ||
| 82 | - # "action": "on_close", | ||
| 83 | - # "client_id": 1985, | ||
| 84 | - # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live" | ||
| 85 | - # } | ||
| 86 | - # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 87 | - # an int value specifies the error code(0 corresponding to success): | ||
| 88 | - # 0 | ||
| 89 | - # support multiple api hooks, format: | ||
| 90 | - # on_close http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 91 | - on_close http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; | ||
| 92 | - # when client(encoder) publish to vhost/app/stream, call the hook, | ||
| 93 | - # the request in the POST data string is a object encode by json: | ||
| 94 | - # { | ||
| 95 | - # "action": "on_publish", | ||
| 96 | - # "client_id": 1985, | ||
| 97 | - # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 98 | - # "stream": "livestream" | ||
| 99 | - # } | ||
| 100 | - # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 101 | - # an int value specifies the error code(0 corresponding to success): | ||
| 102 | - # 0 | ||
| 103 | - # support multiple api hooks, format: | ||
| 104 | - # on_publish http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 105 | - on_publish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; | ||
| 106 | - # when client(encoder) stop publish to vhost/app/stream, call the hook, | ||
| 107 | - # the request in the POST data string is a object encode by json: | ||
| 108 | - # { | ||
| 109 | - # "action": "on_unpublish", | ||
| 110 | - # "client_id": 1985, | ||
| 111 | - # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 112 | - # "stream": "livestream" | ||
| 113 | - # } | ||
| 114 | - # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 115 | - # an int value specifies the error code(0 corresponding to success): | ||
| 116 | - # 0 | ||
| 117 | - # support multiple api hooks, format: | ||
| 118 | - # on_unpublish http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 119 | - on_unpublish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; | ||
| 120 | - # when client start to play vhost/app/stream, call the hook, | ||
| 121 | - # the request in the POST data string is a object encode by json: | ||
| 122 | - # { | ||
| 123 | - # "action": "on_play", | ||
| 124 | - # "client_id": 1985, | ||
| 125 | - # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 126 | - # "stream": "livestream" | ||
| 127 | - # } | ||
| 128 | - # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 129 | - # an int value specifies the error code(0 corresponding to success): | ||
| 130 | - # 0 | ||
| 131 | - # support multiple api hooks, format: | ||
| 132 | - # on_play http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 133 | - on_play http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; | ||
| 134 | - # when client stop to play vhost/app/stream, call the hook, | ||
| 135 | - # the request in the POST data string is a object encode by json: | ||
| 136 | - # { | ||
| 137 | - # "action": "on_stop", | ||
| 138 | - # "client_id": 1985, | ||
| 139 | - # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | ||
| 140 | - # "stream": "livestream" | ||
| 141 | - # } | ||
| 142 | - # if valid, the hook must return HTTP code 200(Stauts OK) and response | ||
| 143 | - # an int value specifies the error code(0 corresponding to success): | ||
| 144 | - # 0 | ||
| 145 | - # support multiple api hooks, format: | ||
| 146 | - # on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 147 | - on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; | ||
| 148 | - } | ||
| 149 | -} | ||
| 150 | - | ||
| 151 | -# the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction | ||
| 152 | -vhost mirror.transcode.vhost.com { | ||
| 153 | - transcode { | ||
| 154 | - enabled on; | ||
| 155 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 156 | - engine mirror { | ||
| 157 | - enabled on; | ||
| 158 | - vfilter { | ||
| 159 | - vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; | ||
| 160 | - } | ||
| 161 | - vcodec libx264; | ||
| 162 | - vbitrate 300; | ||
| 163 | - vfps 20; | ||
| 164 | - vwidth 768; | ||
| 165 | - vheight 320; | ||
| 166 | - vthreads 2; | ||
| 167 | - vprofile baseline; | ||
| 168 | - vpreset superfast; | ||
| 169 | - vparams { | ||
| 170 | - } | ||
| 171 | - acodec libaacplus; | ||
| 172 | - abitrate 45; | ||
| 173 | - asample_rate 44100; | ||
| 174 | - achannels 2; | ||
| 175 | - aparams { | ||
| 176 | - } | ||
| 177 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 178 | - } | ||
| 179 | - } | ||
| 180 | -} | ||
| 181 | -# the drawtext filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#drawtext-1 | ||
| 182 | -vhost drawtext.transcode.vhost.com { | ||
| 183 | - transcode { | ||
| 184 | - enabled on; | ||
| 185 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 186 | - engine drawtext { | ||
| 187 | - enabled on; | ||
| 188 | - vfilter { | ||
| 189 | - vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | ||
| 190 | - } | ||
| 191 | - vcodec libx264; | ||
| 192 | - vbitrate 300; | ||
| 193 | - vfps 20; | ||
| 194 | - vwidth 768; | ||
| 195 | - vheight 320; | ||
| 196 | - vthreads 2; | ||
| 197 | - vprofile baseline; | ||
| 198 | - vpreset superfast; | ||
| 199 | - vparams { | ||
| 200 | - } | ||
| 201 | - acodec libaacplus; | ||
| 202 | - abitrate 45; | ||
| 203 | - asample_rate 44100; | ||
| 204 | - achannels 2; | ||
| 205 | - aparams { | ||
| 206 | - } | ||
| 207 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | -} | ||
| 211 | -# the crop filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#crop | ||
| 212 | -vhost crop.transcode.vhost.com { | ||
| 213 | - transcode { | ||
| 214 | - enabled on; | ||
| 215 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 216 | - engine crop { | ||
| 217 | - enabled on; | ||
| 218 | - vfilter { | ||
| 219 | - vf 'crop=in_w-20:in_h-160:10:80'; | ||
| 220 | - } | ||
| 221 | - vcodec libx264; | ||
| 222 | - vbitrate 300; | ||
| 223 | - vfps 20; | ||
| 224 | - vwidth 768; | ||
| 225 | - vheight 320; | ||
| 226 | - vthreads 2; | ||
| 227 | - vprofile baseline; | ||
| 228 | - vpreset superfast; | ||
| 229 | - vparams { | ||
| 230 | - } | ||
| 231 | - acodec libaacplus; | ||
| 232 | - abitrate 45; | ||
| 233 | - asample_rate 44100; | ||
| 234 | - achannels 2; | ||
| 235 | - aparams { | ||
| 236 | - } | ||
| 237 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 238 | - } | ||
| 239 | - } | ||
| 240 | -} | ||
| 241 | -# the logo filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#overlay | ||
| 242 | -vhost logo.transcode.vhost.com { | ||
| 243 | - transcode { | ||
| 244 | - enabled on; | ||
| 245 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 246 | - engine logo { | ||
| 247 | - enabled on; | ||
| 248 | - vfilter { | ||
| 249 | - i ./doc/ffmpeg-logo.png; | ||
| 250 | - filter_complex 'overlay=10:10'; | ||
| 251 | - } | ||
| 252 | - vcodec libx264; | ||
| 253 | - vbitrate 300; | ||
| 254 | - vfps 20; | ||
| 255 | - vwidth 768; | ||
| 256 | - vheight 320; | ||
| 257 | - vthreads 2; | ||
| 258 | - vprofile baseline; | ||
| 259 | - vpreset superfast; | ||
| 260 | - vparams { | ||
| 261 | - } | ||
| 262 | - acodec libaacplus; | ||
| 263 | - abitrate 45; | ||
| 264 | - asample_rate 44100; | ||
| 265 | - achannels 2; | ||
| 266 | - aparams { | ||
| 267 | - } | ||
| 268 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 269 | - } | ||
| 270 | - } | ||
| 271 | -} | ||
| 272 | -# audio transcode only. | ||
| 273 | -# for example, FMLE publish audio codec in mp3, and donot support HLS output, | ||
| 274 | -# we can transcode the audio to aac and copy video to the new stream with HLS. | ||
| 275 | -vhost audio.transcode.vhost.com { | ||
| 276 | - transcode { | ||
| 277 | - enabled on; | ||
| 278 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 279 | - engine acodec { | ||
| 280 | - enabled on; | ||
| 281 | - vcodec copy; | ||
| 282 | - acodec libaacplus; | ||
| 283 | - abitrate 45; | ||
| 284 | - asample_rate 44100; | ||
| 285 | - achannels 2; | ||
| 286 | - aparams { | ||
| 287 | - } | ||
| 288 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 289 | - } | ||
| 290 | - } | ||
| 291 | -} | ||
| 292 | -# ffmpeg-copy(forward implements by ffmpeg). | ||
| 293 | -# copy the video and audio to a new stream. | ||
| 294 | -vhost copy.transcode.vhost.com { | ||
| 295 | - transcode { | ||
| 296 | - enabled on; | ||
| 297 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 298 | - engine copy { | ||
| 299 | - enabled on; | ||
| 300 | - vcodec copy; | ||
| 301 | - acodec copy; | ||
| 302 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 303 | - } | ||
| 304 | - } | ||
| 305 | -} | ||
| 306 | -# transcode all app and stream of vhost | ||
| 307 | -vhost all.transcode.vhost.com { | ||
| 308 | - # the streaming transcode configs. | ||
| 309 | - transcode { | ||
| 310 | - # whether the transcode enabled. | ||
| 311 | - # if off, donot transcode. | ||
| 312 | - # default: off. | ||
| 313 | - enabled on; | ||
| 314 | - # the ffmpeg | ||
| 315 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 316 | - # the transcode engine for matched stream. | ||
| 317 | - # all matched stream will transcoded to the following stream. | ||
| 318 | - # the transcode set name(ie. hd) is optional and not used. | ||
| 319 | - engine ffsuper { | ||
| 320 | - # whether the engine is enabled | ||
| 321 | - # default: off. | ||
| 322 | - enabled on; | ||
| 323 | - # ffmpeg filters, follows the main input. | ||
| 324 | - vfilter { | ||
| 325 | - # the logo input file. | ||
| 326 | - i ./doc/ffmpeg-logo.png; | ||
| 327 | - # the ffmpeg complex filter. | ||
| 328 | - # for filters, @see: http://ffmpeg.org/ffmpeg-filters.html | ||
| 329 | - filter_complex 'overlay=10:10'; | ||
| 330 | - } | ||
| 331 | - # video encoder name. can be: | ||
| 332 | - # libx264: use h.264(libx264) video encoder. | ||
| 333 | - # copy: donot encoder the video stream, copy it. | ||
| 334 | - vcodec libx264; | ||
| 335 | - # video bitrate, in kbps | ||
| 336 | - vbitrate 1500; | ||
| 337 | - # video framerate. | ||
| 338 | - vfps 25; | ||
| 339 | - # video width, must be even numbers. | ||
| 340 | - vwidth 768; | ||
| 341 | - # video height, must be even numbers. | ||
| 342 | - vheight 320; | ||
| 343 | - # the max threads for ffmpeg to used. | ||
| 344 | - vthreads 12; | ||
| 345 | - # x264 profile, @see x264 -help, can be: | ||
| 346 | - # high,main,baseline | ||
| 347 | - vprofile main; | ||
| 348 | - # x264 preset, @see x264 -help, can be: | ||
| 349 | - # ultrafast,superfast,veryfast,faster,fast | ||
| 350 | - # medium,slow,slower,veryslow,placebo | ||
| 351 | - vpreset medium; | ||
| 352 | - # other x264 or ffmpeg video params | ||
| 353 | - vparams { | ||
| 354 | - # ffmpeg options, @see: http://ffmpeg.org/ffmpeg.html | ||
| 355 | - t 100; | ||
| 356 | - # 264 params, @see: http://ffmpeg.org/ffmpeg-codecs.html#libx264 | ||
| 357 | - coder 1; | ||
| 358 | - b_strategy 2; | ||
| 359 | - bf 3; | ||
| 360 | - refs 10; | ||
| 361 | - } | ||
| 362 | - # audio encoder name. can be: | ||
| 363 | - # libaacplus: use aac(libaacplus) audio encoder. | ||
| 364 | - # copy: donot encoder the audio stream, copy it. | ||
| 365 | - acodec libaacplus; | ||
| 366 | - # audio bitrate, in kbps. [16, 72] for libaacplus. | ||
| 367 | - abitrate 70; | ||
| 368 | - # audio sample rate. for flv/rtmp, it must be: | ||
| 369 | - # 44100,22050,11025,5512 | ||
| 370 | - asample_rate 44100; | ||
| 371 | - # audio channel, 1 for mono, 2 for stereo. | ||
| 372 | - achannels 2; | ||
| 373 | - # other ffmpeg audio params | ||
| 374 | - aparams { | ||
| 375 | - # audio params, @see: http://ffmpeg.org/ffmpeg-codecs.html#Audio-Encoders | ||
| 376 | - profile:a aac_low; | ||
| 377 | - } | ||
| 378 | - # output stream. variables: | ||
| 379 | - # [vhost] the input stream vhost. | ||
| 380 | - # [port] the intput stream port. | ||
| 381 | - # [app] the input stream app. | ||
| 382 | - # [stream] the input stream name. | ||
| 383 | - # [engine] the tanscode engine name. | ||
| 384 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 385 | - } | ||
| 386 | - engine ffhd { | ||
| 387 | - enabled on; | ||
| 388 | - vcodec libx264; | ||
| 389 | - vbitrate 1200; | ||
| 390 | - vfps 25; | ||
| 391 | - vwidth 1382; | ||
| 392 | - vheight 576; | ||
| 393 | - vthreads 6; | ||
| 394 | - vprofile main; | ||
| 395 | - vpreset medium; | ||
| 396 | - vparams { | ||
| 397 | - } | ||
| 398 | - acodec libaacplus; | ||
| 399 | - abitrate 70; | ||
| 400 | - asample_rate 44100; | ||
| 401 | - achannels 2; | ||
| 402 | - aparams { | ||
| 403 | - } | ||
| 404 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 405 | - } | ||
| 406 | - engine ffsd { | ||
| 407 | - enabled on; | ||
| 408 | - vcodec libx264; | ||
| 409 | - vbitrate 800; | ||
| 410 | - vfps 25; | ||
| 411 | - vwidth 1152; | ||
| 412 | - vheight 480; | ||
| 413 | - vthreads 4; | ||
| 414 | - vprofile main; | ||
| 415 | - vpreset fast; | ||
| 416 | - vparams { | ||
| 417 | - } | ||
| 418 | - acodec libaacplus; | ||
| 419 | - abitrate 60; | ||
| 420 | - asample_rate 44100; | ||
| 421 | - achannels 2; | ||
| 422 | - aparams { | ||
| 423 | - } | ||
| 424 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 425 | - } | ||
| 426 | - engine fffast { | ||
| 427 | - enabled on; | ||
| 428 | - vcodec libx264; | ||
| 429 | - vbitrate 300; | ||
| 430 | - vfps 20; | ||
| 431 | - vwidth 768; | ||
| 432 | - vheight 320; | ||
| 433 | - vthreads 2; | ||
| 434 | - vprofile baseline; | ||
| 435 | - vpreset superfast; | ||
| 436 | - vparams { | ||
| 437 | - } | ||
| 438 | - acodec libaacplus; | ||
| 439 | - abitrate 45; | ||
| 440 | - asample_rate 44100; | ||
| 441 | - achannels 2; | ||
| 442 | - aparams { | ||
| 443 | - } | ||
| 444 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 445 | - } | ||
| 446 | - engine vcopy { | ||
| 447 | - enabled on; | ||
| 448 | - vcodec copy; | ||
| 449 | - acodec libaacplus; | ||
| 450 | - abitrate 45; | ||
| 451 | - asample_rate 44100; | ||
| 452 | - achannels 2; | ||
| 453 | - aparams { | ||
| 454 | - } | ||
| 455 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 456 | - } | ||
| 457 | - engine acopy { | ||
| 458 | - enabled on; | ||
| 459 | - vcodec libx264; | ||
| 460 | - vbitrate 300; | ||
| 461 | - vfps 20; | ||
| 462 | - vwidth 768; | ||
| 463 | - vheight 320; | ||
| 464 | - vthreads 2; | ||
| 465 | - vprofile baseline; | ||
| 466 | - vpreset superfast; | ||
| 467 | - vparams { | ||
| 468 | - } | ||
| 469 | - acodec copy; | ||
| 470 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 471 | - } | ||
| 472 | - engine copy { | ||
| 473 | - enabled on; | ||
| 474 | - vcodec copy; | ||
| 475 | - acodec copy; | ||
| 476 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 477 | - } | ||
| 478 | - } | ||
| 479 | -} | ||
| 480 | -# transcode all stream using the empty ffmpeg demo, donothing. | ||
| 481 | -vhost ffempty.transcode.vhost.com { | ||
| 482 | - transcode { | ||
| 483 | - enabled on; | ||
| 484 | - ffmpeg ./objs/research/ffempty; | ||
| 485 | - engine empty { | ||
| 486 | - enabled on; | ||
| 487 | - vcodec libx264; | ||
| 488 | - vbitrate 300; | ||
| 489 | - vfps 20; | ||
| 490 | - vwidth 768; | ||
| 491 | - vheight 320; | ||
| 492 | - vthreads 2; | ||
| 493 | - vprofile baseline; | ||
| 494 | - vpreset superfast; | ||
| 495 | - vparams { | ||
| 496 | - } | ||
| 497 | - acodec libaacplus; | ||
| 498 | - abitrate 45; | ||
| 499 | - asample_rate 44100; | ||
| 500 | - achannels 2; | ||
| 501 | - aparams { | ||
| 502 | - } | ||
| 503 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 504 | - } | ||
| 505 | - } | ||
| 506 | -} | ||
| 507 | -# transcode all app and stream of app | ||
| 508 | -vhost app.transcode.vhost.com { | ||
| 509 | - # the streaming transcode configs. | ||
| 510 | - # if app specified, transcode all streams of app. | ||
| 511 | - transcode live { | ||
| 512 | - enabled on; | ||
| 513 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 514 | - engine { | ||
| 515 | - enabled off; | ||
| 516 | - } | ||
| 517 | - } | ||
| 518 | -} | ||
| 519 | -# transcode specified stream. | ||
| 520 | -vhost stream.transcode.vhost.com { | ||
| 521 | - # the streaming transcode configs. | ||
| 522 | - # if stream specified, transcode the matched stream. | ||
| 523 | - transcode live/livestream { | ||
| 524 | - enabled on; | ||
| 525 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 526 | - engine { | ||
| 527 | - enabled off; | ||
| 528 | - } | ||
| 529 | - } | ||
| 530 | -} | ||
| 531 | - | ||
| 532 | -# the vhost which forward publish streams. | ||
| 533 | -vhost same.vhost.forward.vhost.com { | ||
| 534 | - # forward all publish stream to the specified server. | ||
| 535 | - # this used to split/forward the current stream for cluster active-standby, | ||
| 536 | - # active-active for cdn to build high available fault tolerance system. | ||
| 537 | - # format: {ip}:{port} {ip_N}:{port_N} | ||
| 538 | - # or specify the vhost by params, @see: change.vhost.forward.vhost.com | ||
| 539 | - # if vhost not specified, use the request vhost instead. | ||
| 540 | - forward 127.0.0.1:1936 127.0.0.1:1937; | ||
| 541 | -} | ||
| 542 | -# TODO: FIXME: change the forward schema with vhost. | ||
| 543 | -# [plan] the vhost which forward publish streams to other vhosts. | ||
| 544 | -vhost change.vhost.forward.vhost.com { | ||
| 545 | - forward 127.0.0.1:1936 127.0.0.1:1937 { | ||
| 546 | - # specify the vhost to override the vhost in client request. | ||
| 547 | - vhost forward2.vhost.com; | ||
| 548 | - # specify the refer(pageUrl) to override the refer in client request. | ||
| 549 | - refer http://srs/index.html; | ||
| 550 | - } | ||
| 551 | - forward 127.0.0.1:1938 { | ||
| 552 | - vhost forward3.vhost.com; | ||
| 553 | - } | ||
| 554 | -} | ||
| 555 | - | ||
| 556 | -# the vhost disabled. | ||
| 557 | -vhost removed.vhost.com { | ||
| 558 | - # whether the vhost is enabled. | ||
| 559 | - # if off, all request access denied. | ||
| 560 | - # default: on | ||
| 561 | - enabled off; | ||
| 562 | -} | ||
| 563 | - | ||
| 564 | -# the vhost with hls specified. | ||
| 565 | -vhost with-hls.vhost.com { | ||
| 566 | - hls { | ||
| 567 | - # whether the hls is enabled. | ||
| 568 | - # if off, donot write hls(ts and m3u8) when publish. | ||
| 569 | - # default: off | ||
| 570 | - enabled on; | ||
| 571 | - # the hls output path. | ||
| 572 | - # the app dir is auto created under the hls_path. | ||
| 573 | - # for example, for rtmp stream: | ||
| 574 | - # rtmp://127.0.0.1/live/livestream | ||
| 575 | - # http://127.0.0.1/live/livestream.m3u8 | ||
| 576 | - # where hls_path is /hls, srs will create the following files: | ||
| 577 | - # /hls/live the app dir for all streams. | ||
| 578 | - # /hls/live/livestream.m3u8 the HLS m3u8 file. | ||
| 579 | - # /hls/live/livestream-1.ts the HLS media/ts file. | ||
| 580 | - # in a word, the hls_path is for vhost. | ||
| 581 | - # default: ./objs/nginx/html | ||
| 582 | - hls_path /data/nginx/html; | ||
| 583 | - # the hls fragment in seconds, the duration of a piece of ts. | ||
| 584 | - # default: 10 | ||
| 585 | - hls_fragment 10; | ||
| 586 | - # the hls window in seconds, the number of ts in m3u8. | ||
| 587 | - # default: 60 | ||
| 588 | - hls_window 60; | ||
| 589 | - } | ||
| 590 | -} | ||
| 591 | -# the vhost with hls disabled. | ||
| 592 | -vhost no-hls.vhost.com { | ||
| 593 | - hls { | ||
| 594 | - # whether the hls is enabled. | ||
| 595 | - # if off, donot write hls(ts and m3u8) when publish. | ||
| 596 | - # default: off | ||
| 597 | - enabled off; | ||
| 598 | - } | ||
| 599 | -} | ||
| 600 | - | ||
| 601 | -# the vhost for min delay, donot cache any stream. | ||
| 602 | -vhost min.delay.com { | ||
| 603 | - # whether cache the last gop. | ||
| 604 | - # if on, cache the last gop and dispatch to client, | ||
| 605 | - # to enable fast startup for client, client play immediately. | ||
| 606 | - # if off, send the latest media data to client, | ||
| 607 | - # client need to wait for the next Iframe to decode and show the video. | ||
| 608 | - # set to off if requires min delay; | ||
| 609 | - # set to on if requires client fast startup. | ||
| 610 | - # default: on | ||
| 611 | - gop_cache off; | ||
| 612 | - # the max live queue length in seconds. | ||
| 613 | - # if the messages in the queue exceed the max length, | ||
| 614 | - # drop the old whole gop. | ||
| 615 | - # default: 30 | ||
| 616 | - queue_length 10; | ||
| 617 | -} | ||
| 618 | - | ||
| 619 | -# the vhost for antisuck. | ||
| 620 | -vhost refer.anti_suck.com { | ||
| 621 | - # the common refer for play and publish. | ||
| 622 | - # if the page url of client not in the refer, access denied. | ||
| 623 | - # if not specified this field, allow all. | ||
| 624 | - # default: not specified. | ||
| 625 | - refer github.com github.io; | ||
| 626 | - # refer for publish clients specified. | ||
| 627 | - # the common refer is not overrided by this. | ||
| 628 | - # if not specified this field, allow all. | ||
| 629 | - # default: not specified. | ||
| 630 | - refer_publish github.com github.io; | ||
| 631 | - # refer for play clients specified. | ||
| 632 | - # the common refer is not overrided by this. | ||
| 633 | - # if not specified this field, allow all. | ||
| 634 | - # default: not specified. | ||
| 635 | - refer_play github.com github.io; | ||
| 636 | -} | ||
| 637 | - | ||
| 638 | -# config for the pithy print, | ||
| 639 | -# which always print constant message specified by interval, | ||
| 640 | -# whatever the clients in concurrency. | ||
| 641 | -pithy_print { | ||
| 642 | - # shared print interval for all publish clients, in milliseconds. | ||
| 643 | - # if not specified, set to 1100. | ||
| 644 | - publish 2000; | ||
| 645 | - # shared print interval for all play clients, in milliseconds. | ||
| 646 | - # if not specified, set to 1300. | ||
| 647 | - play 3000; | ||
| 648 | - # shared print interval for all forwarders, in milliseconds. | ||
| 649 | - # if not specified, set to 2000. | ||
| 650 | - forwarder 3000; | ||
| 651 | - # shared print interval for all encoders, in milliseconds. | ||
| 652 | - # if not specified, set to 2000. | ||
| 653 | - encoder 3000; | ||
| 654 | - # shared print interval for all hls, in milliseconds. | ||
| 655 | - # if not specified, set to 2000. | ||
| 656 | - hls 3000; | ||
| 657 | -} | ||
| 658 | -# vhost list, the __defaultVhost__ is the default vhost | ||
| 659 | -# for example, user use ip to access the stream: rtmp://192.168.1.2/live/livestream. | ||
| 660 | -# for which cannot identify the required vhost. | ||
| 661 | -# for default demo. | ||
| 662 | -vhost demo.srs.com { | ||
| 663 | - chunk_size 60000; | ||
| 664 | - enabled on; | ||
| 665 | - gop_cache on; | ||
| 666 | - queue_length 30; | ||
| 667 | - forward 127.0.0.1:19350; | ||
| 668 | - bandcheck { | ||
| 669 | - enabled off; | ||
| 670 | - } | ||
| 671 | - hls { | ||
| 672 | - enabled on; | ||
| 673 | - hls_path ./objs/nginx/html; | ||
| 674 | - hls_fragment 5; | ||
| 675 | - hls_window 30; | ||
| 676 | - } | ||
| 677 | - http_hooks { | ||
| 678 | - enabled on; | ||
| 679 | - on_connect http://127.0.0.1:8085/api/v1/clients; | ||
| 680 | - on_close http://127.0.0.1:8085/api/v1/clients; | ||
| 681 | - on_publish http://127.0.0.1:8085/api/v1/streams; | ||
| 682 | - on_unpublish http://127.0.0.1:8085/api/v1/streams; | ||
| 683 | - on_play http://127.0.0.1:8085/api/v1/sessions; | ||
| 684 | - on_stop http://127.0.0.1:8085/api/v1/sessions; | ||
| 685 | - } | ||
| 686 | - transcode { | ||
| 687 | - enabled on; | ||
| 688 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 689 | - engine ld { | ||
| 690 | - enabled on; | ||
| 691 | - vfilter { | ||
| 692 | - vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontsize=30:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | ||
| 693 | - } | ||
| 694 | - vcodec libx264; | ||
| 695 | - vbitrate 300; | ||
| 696 | - vfps 20; | ||
| 697 | - vwidth 768; | ||
| 698 | - vheight 320; | ||
| 699 | - vthreads 1; | ||
| 700 | - vprofile baseline; | ||
| 701 | - vpreset superfast; | ||
| 702 | - vparams { | ||
| 703 | - } | ||
| 704 | - acodec libaacplus; | ||
| 705 | - abitrate 45; | ||
| 706 | - asample_rate 44100; | ||
| 707 | - achannels 2; | ||
| 708 | - aparams { | ||
| 709 | - } | ||
| 710 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 711 | - } | ||
| 712 | - engine sd { | ||
| 713 | - enabled on; | ||
| 714 | - vfilter { | ||
| 715 | - vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; | ||
| 716 | - } | ||
| 717 | - vcodec libx264; | ||
| 718 | - vbitrate 500; | ||
| 719 | - vfps 20; | ||
| 720 | - vwidth 768; | ||
| 721 | - vheight 320; | ||
| 722 | - vthreads 1; | ||
| 723 | - vprofile main; | ||
| 724 | - vpreset fast; | ||
| 725 | - vparams { | ||
| 726 | - } | ||
| 727 | - acodec libaacplus; | ||
| 728 | - abitrate 40; | ||
| 729 | - asample_rate 44100; | ||
| 730 | - achannels 2; | ||
| 731 | - aparams { | ||
| 732 | - } | ||
| 733 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 734 | - } | ||
| 735 | - } | ||
| 736 | -} | ||
| 737 | -# for the players site, to play or publish. | ||
| 738 | -# the flash player publisher need to transcode to support hls, | ||
| 739 | -# we add players_hls vhost to support it. | ||
| 740 | -vhost players { | ||
| 741 | - enabled on; | ||
| 742 | - gop_cache on; | ||
| 743 | - transcode { | ||
| 744 | - enabled on; | ||
| 745 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 746 | - engine hls { | ||
| 747 | - enabled on; | ||
| 748 | - vfilter { | ||
| 749 | - vf 'drawtext=text=SRS(SimpleRtmpServer):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | ||
| 750 | - } | ||
| 751 | - vcodec libx264; | ||
| 752 | - vbitrate 300; | ||
| 753 | - vfps 20; | ||
| 754 | - vwidth 768; | ||
| 755 | - vheight 320; | ||
| 756 | - vthreads 1; | ||
| 757 | - vprofile baseline; | ||
| 758 | - vpreset superfast; | ||
| 759 | - vparams { | ||
| 760 | - g 100; | ||
| 761 | - } | ||
| 762 | - acodec libaacplus; | ||
| 763 | - abitrate 30; | ||
| 764 | - asample_rate 44100; | ||
| 765 | - achannels 2; | ||
| 766 | - aparams { | ||
| 767 | - } | ||
| 768 | - output rtmp://127.0.0.1:[port]/[app]?vhost=players_pub/[stream]; | ||
| 769 | - } | ||
| 770 | - } | ||
| 771 | -} | ||
| 772 | -vhost players_pub { | ||
| 773 | - hls { | ||
| 774 | - enabled on; | ||
| 775 | - hls_path ./objs/nginx/html; | ||
| 776 | - hls_fragment 5; | ||
| 777 | - hls_window 30; | ||
| 778 | - } | ||
| 779 | -} | ||
| 780 | -# rtmp only, no hls, for chat(low latecy) | ||
| 781 | -vhost players_pub_rtmp { | ||
| 782 | - gop_cache off; | ||
| 783 | - hls { | ||
| 784 | - enabled off; | ||
| 785 | - } | ||
| 786 | -} | ||
| 787 | - | ||
| 788 | -# for development | ||
| 789 | -vhost dev { | ||
| 790 | - enabled on; | ||
| 791 | - gop_cache on; | ||
| 792 | - queue_length 10; | ||
| 793 | - #forward 127.0.0.1:19350; | ||
| 794 | - hls { | ||
| 795 | - enabled off; | ||
| 796 | - hls_path ./objs/nginx/html; | ||
| 797 | - hls_fragment 5; | ||
| 798 | - hls_window 30; | ||
| 799 | - } | ||
| 800 | - http_hooks { | ||
| 801 | - enabled off; | ||
| 802 | - on_connect http://127.0.0.1:8085/api/v1/clients; | ||
| 803 | - on_close http://127.0.0.1:8085/api/v1/clients; | ||
| 804 | - on_publish http://127.0.0.1:8085/api/v1/streams; | ||
| 805 | - on_unpublish http://127.0.0.1:8085/api/v1/streams; | ||
| 806 | - on_play http://127.0.0.1:8085/api/v1/sessions; | ||
| 807 | - on_stop http://127.0.0.1:8085/api/v1/sessions; | ||
| 808 | - } | ||
| 809 | - transcode { | ||
| 810 | - enabled off; | ||
| 811 | - ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 812 | - engine dev { | ||
| 813 | - enabled on; | ||
| 814 | - vfilter { | ||
| 815 | - } | ||
| 816 | - vcodec libx264; | ||
| 817 | - vbitrate 300; | ||
| 818 | - vfps 20; | ||
| 819 | - vwidth 768; | ||
| 820 | - vheight 320; | ||
| 821 | - vthreads 1; | ||
| 822 | - vprofile baseline; | ||
| 823 | - vpreset superfast; | ||
| 824 | - vparams { | ||
| 825 | - } | ||
| 826 | - acodec libaacplus; | ||
| 827 | - abitrate 45; | ||
| 828 | - asample_rate 44100; | ||
| 829 | - achannels 2; | ||
| 830 | - aparams { | ||
| 831 | - } | ||
| 832 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 833 | - } | ||
| 834 | - engine dev_acodec { | ||
| 835 | - enabled on; | ||
| 836 | - vcodec copy; | ||
| 837 | - acodec libaacplus; | ||
| 838 | - abitrate 45; | ||
| 839 | - asample_rate 44100; | ||
| 840 | - achannels 2; | ||
| 841 | - aparams { | ||
| 842 | - } | ||
| 843 | - output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | ||
| 844 | - } | ||
| 845 | - } | ||
| 846 | -} | ||
| 847 | - | ||
| 848 | - |
| @@ -2,10 +2,10 @@ | @@ -2,10 +2,10 @@ | ||
| 2 | src_dir='src' | 2 | src_dir='src' |
| 3 | if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi | 3 | if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi |
| 4 | 4 | ||
| 5 | -cmd="nohup ./objs/srs -c conf/srs.19350.conf > ./objs/logs/srs.19350.log 2>&1 &" | 5 | +cmd="nohup ./objs/srs -c conf/demo.19350.conf > ./objs/logs/demo.19350.log 2>&1 &" |
| 6 | echo "启动SRS转发服务器:$cmd" | 6 | echo "启动SRS转发服务器:$cmd" |
| 7 | -pids=`ps aux|grep srs|grep "./objs"|grep "srs.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done | ||
| 8 | -nohup ./objs/srs -c conf/srs.19350.conf > ./objs/logs/srs.19350.log 2>&1 & | 7 | +pids=`ps aux|grep srs|grep "./objs"|grep "demo.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done |
| 8 | +nohup ./objs/srs -c conf/demo.19350.conf > ./objs/logs/demo.19350.log 2>&1 & | ||
| 9 | ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi | 9 | ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi |
| 10 | 10 | ||
| 11 | echo "启动SRS转发服务器成功" | 11 | echo "启动SRS转发服务器成功" |
| @@ -2,10 +2,10 @@ | @@ -2,10 +2,10 @@ | ||
| 2 | src_dir='src' | 2 | src_dir='src' |
| 3 | if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi | 3 | if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi |
| 4 | 4 | ||
| 5 | -cmd="nohup ./objs/srs -c conf/srs.conf >./objs/logs/srs.log 2>&1 &" | 5 | +cmd="nohup ./objs/srs -c conf/demo.conf >./objs/logs/demo.log 2>&1 &" |
| 6 | echo "启动SRS服务器:$cmd" | 6 | echo "启动SRS服务器:$cmd" |
| 7 | -pids=`ps aux|grep srs|grep "./objs"|grep "srs.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done | ||
| 8 | -nohup ./objs/srs -c conf/srs.conf >./objs/logs/srs.log 2>&1 & | 7 | +pids=`ps aux|grep srs|grep "./objs"|grep "demo.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done |
| 8 | +nohup ./objs/srs -c conf/demo.conf >./objs/logs/demo.log 2>&1 & | ||
| 9 | ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi | 9 | ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi |
| 10 | 10 | ||
| 11 | echo "启动SRS服务器成功" | 11 | echo "启动SRS服务器成功" |
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | echo "停止SRS服务器" | 3 | echo "停止SRS服务器" |
| 4 | -ps aux|grep srs|grep "./objs"|grep "srs.conf" | ||
| 5 | -pids=`ps aux|grep srs|grep "./objs"|grep "srs.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done | 4 | +ps aux|grep srs|grep "./objs"|grep "demo.conf" |
| 5 | +pids=`ps aux|grep srs|grep "./objs"|grep "demo.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done | ||
| 6 | 6 | ||
| 7 | echo "停止SRS转发服务器" | 7 | echo "停止SRS转发服务器" |
| 8 | -ps aux|grep srs|grep "./objs"|grep "srs.19350.conf" | ||
| 9 | -pids=`ps aux|grep srs|grep "./objs"|grep "srs.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done | 8 | +ps aux|grep srs|grep "./objs"|grep "demo.19350.conf" |
| 9 | +pids=`ps aux|grep srs|grep "./objs"|grep "demo.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done | ||
| 10 | 10 | ||
| 11 | # step 4(optinal): start nginx for HLS | 11 | # step 4(optinal): start nginx for HLS |
| 12 | echo "停止NGINX(HLS服务)" | 12 | echo "停止NGINX(HLS服务)" |
-
请 注册 或 登录 后发表评论