srs.conf 14.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
# the listen ports, split by space.
listen              1935;
# the default chunk size is 128, max is 65536,
# some client does not support chunk size change,
# however, most clients supports it and it can improve 
# performance about 10%.
# if not specified, set to 4096.
chunk_size          65000;
# vhost list, the __defaultVhost__ is the default vhost
# for which cannot identify the required vhost.
vhost __defaultVhost__ {
    enabled         on;
    gop_cache       on;
    hls             on;
    hls_path        ./objs/nginx/html;
    hls_fragment    5;
    hls_window      30;
    forward         127.0.0.1:1936;
    transcode {
        enabled     on;
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        #ffmpeg      ./research/ffempty/ffempty;
        engine fast{
            enabled         on;
            vfilter {
                vf                  'drawtext=text=SRS';
                #vf                  'crop=in_w-20:in_h-160:10:80';
                #i                   ./doc/ffmpeg-logo.png;
                #filter_complex      'overlay=10:10';
            }
            vcodec          libx264;
            vbitrate        300;
            vfps            20;
            vwidth          480;
            vheight         320;
            vthreads        1;
            vprofile        baseline;
            vpreset         superfast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        30;
            asample_rate    44100;
            achannels       2;
            aparams {
                profile:a   aac_low;
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_fast;
        }
        engine sd{
            enabled         off;
            vfilter {
                vf                  'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2';
            }
            vcodec          libx264;
            vbitrate        500;
            vfps            20;
            vwidth          720;
            vheight         480;
            vthreads        1;
            vprofile        main;
            vpreset         fast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        40;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_sd;
        }
    }
}
# transcode all app and stream of vhost
vhost all.transcode.vhost.com {
    # the streaming transcode configs.
    transcode {
        # whether the transcode enabled.
        # if off, donot transcode.
        # default: off.
        enabled     on;
        # the ffmpeg 
        ffmpeg ./objs/ffmpeg/bin/ffmpeg;
        # the transcode engine for matched stream.
        # all matched stream will transcoded to the following stream.
        # the transcode set name(ie. hd) is optional and not used.
        engine super{
            # whether the engine is enabled
            # default: off.
            enabled         on;
            # ffmpeg filters, follows the main input.
            vfilter {
                # the logo input file.
                i               ./doc/ffmpeg-logo.png;
                # the ffmpeg complex filter.
                # for filters, @see: http://ffmpeg.org/ffmpeg-filters.html
                filter_complex      'overlay=10:10';
            }
            # video encoder name
            vcodec          libx264;
            # video bitrate, in kbps
            vbitrate        1500;
            # video framerate.
            vfps            25;
            # video width, must be even numbers.
            vwidth          1280;
            # video height, must be even numbers.
            vheight         720;
            # the max threads for ffmpeg to used.
            vthreads        12;
            # x264 profile, @see x264 -help, can be:
            # high,main,baseline
            vprofile        main;
            # x264 preset, @see x264 -help, can be: 
            # ultrafast,superfast,veryfast,faster,fast
            # medium,slow,slower,veryslow,placebo
            vpreset         medium;
            # other x264 or ffmpeg video params
            vparams {
                # ffmpeg options, @see: http://ffmpeg.org/ffmpeg.html
                t               100;
                # 264 params, @see: http://ffmpeg.org/ffmpeg-codecs.html#libx264
                coder           1;
                b_strategy      2;
                bf              3;
                refs            10;
            }
            # audio encoder name
            acodec          libaacplus;
            # audio bitrate, in kbps. [16, 72] for libaacplus.
            abitrate        70;
            # audio sample rate. for flv/rtmp, it must be:
            # 44100,22050,11025,5512
            asample_rate    44100;
            # audio channel, 1 for mono, 2 for stereo.
            achannels       2;
            # other ffmpeg audio params
            aparams {
            }
            # output stream. variables:
            # [vhost] the input stream vhost.
            # [port] the intput stream port.
            # [app] the input stream app.
            # [stream] the input stream name.
            output          rtmp://[vhost]:[port]/[app]/[stream]_super;
        }
        engine hd{
            enabled         on;
            vcodec          libx264;
            vbitrate        1200;
            vfps            25;
            vwidth          1024;
            vheight         576;
            vthreads        6;
            vprofile        main;
            vpreset         medium;
            vparams {
            }
            acodec          libaacplus;
            abitrate        70;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_hd;
        }
        engine sd{
            enabled         on;
            vcodec          libx264;
            vbitrate        800;
            vfps            25;
            vwidth          720;
            vheight         480;
            vthreads        4;
            vprofile        main;
            vpreset         fast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        60;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_sd;
        }
        engine fast{
            enabled     on;
            vcodec          libx264;
            vbitrate        300;
            vfps            20;
            vwidth          480;
            vheight         320;
            vthreads        2;
            vprofile        baseline;
            vpreset         superfast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        30;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_fast;
        }
    }
}
# the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction
vhost mirror.transcode.vhost.com {
    transcode {
        enabled     on;
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine mirror{
            enabled         on;
            vfilter {
                vf                  'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2';
            }
            vcodec          libx264;
            vbitrate        300;
            vfps            20;
            vwidth          480;
            vheight         320;
            vthreads        2;
            vprofile        baseline;
            vpreset         superfast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        30;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_mirror;
        }
    }
}
# the logo filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#crop
vhost crop.transcode.vhost.com {
    transcode {
        enabled     on;
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine crop{
            enabled         on;
            vfilter {
                vf                  'crop=in_w-20:in_h-160:10:80';
            }
            vcodec          libx264;
            vbitrate        300;
            vfps            20;
            vwidth          480;
            vheight         320;
            vthreads        2;
            vprofile        baseline;
            vpreset         superfast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        30;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_crop;
        }
    }
}
# the crop filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#crop
vhost logo.transcode.vhost.com {
    transcode {
        enabled     on;
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine logo{
            enabled         on;
            vfilter {
                vf                  'crop=200:100:10:10';
            }
            vcodec          libx264;
            vbitrate        300;
            vfps            20;
            vwidth          480;
            vheight         320;
            vthreads        2;
            vprofile        baseline;
            vpreset         superfast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        30;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_logo;
        }
    }
}
# transcode all stream using the empty ffmpeg demo, donothing.
vhost ffempty.transcode.vhost.com {
    transcode {
        enabled     on;
        ffmpeg ./research/ffempty/ffempty;
        engine empty{
            enabled         on;
            vcodec          libx264;
            vbitrate        300;
            vfps            20;
            vwidth          480;
            vheight         320;
            vthreads        2;
            vprofile        baseline;
            vpreset         superfast;
            vparams {
            }
            acodec          libaacplus;
            abitrate        30;
            asample_rate    44100;
            achannels       2;
            aparams {
            }
            output          rtmp://[vhost]:[port]/[app]/[stream]_empty;
        }
    }
}
# transcode all app and stream of app
vhost app.transcode.vhost.com {
    # the streaming transcode configs.
    # if app specified, transcode all streams of app.
    transcode live {
        enabled     on;
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine fd{
            enabled     off;
        }
    }
}
# transcode specified stream.
vhost stream.transcode.vhost.com {
    # the streaming transcode configs.
    # if stream specified, transcode the matched stream.
    transcode live/livestream {
        enabled     on;
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine fd{
            enabled     off;
        }
    }
}
# the vhost which forward publish streams.
vhost forward.vhost.com {
    # forward all publish stream to the specified server.
    # this used to split/forward the current stream for cluster active-standby,
    # active-active for cdn to build high available fault tolerance system.
    # format: {ip}:{port} {ip_N}:{port_N}
    forward         127.0.0.1:1936 127.0.0.1:1937;
}
# the vhost disabled.
vhost removed.vhost.com {
    # whether the vhost is enabled.
    # if off, all request access denied.
    # default: on
    enabled         off;
}
# the vhost with hls specified.
vhost no-hls.vhost.com {
    # whether the hls is enabled.
    # if off, donot write hls(ts and m3u8) when publish.
    # default: on
    hls             on;
    # the hls output path.
    # the app dir is auto created under the hls_path.
    # for example, for rtmp stream:
    #   rtmp://127.0.0.1/live/livestream
    #   http://127.0.0.1/live/livestream.m3u8
    # where hls_path is /hls, srs will create the following files:
    #   /hls/live       the app dir for all streams.
    #   /hls/live/livestream.m3u8   the HLS m3u8 file.
    #   /hls/live/livestream-1.ts   the HLS media/ts file.
    # in a word, the hls_path is for vhost.
    # default: ./objs/nginx/html
    hls_path        /data/nginx/html;
    # the hls fragment in seconds, the duration of a piece of ts.
    # default: 10
    hls_fragment    10;
    # the hls window in seconds, the number of ts in m3u8.
    # default: 60
    hls_window      60;
}
# the vhost with hls disabled.
vhost no-hls.vhost.com {
    # whether the hls is enabled.
    # if off, donot write hls(ts and m3u8) when publish.
    # default: on
    hls             off;
}
# the vhost for min delay, donot cache any stream.
vhost min.delay.com {
    # whether cache the last gop.
    # if on, cache the last gop and dispatch to client,
    #   to enable fast startup for client, client play immediately.
    # if off, send the latest media data to client,
    #   client need to wait for the next Iframe to decode and show the video.
    # set to off if requires min delay;
    # set to on if requires client fast startup.
    # default: on
    gop_cache       off;
}
# the vhost for antisuck.
vhost refer.anti_suck.com {
    # the common refer for play and publish.
    # if the page url of client not in the refer, access denied.
    # if not specified this field, allow all.
    # default: not specified.
    refer           github.com github.io;
    # refer for publish clients specified.
    # the common refer is not overrided by this.
    # if not specified this field, allow all.
    # default: not specified.
    refer_publish   github.com github.io;
    # refer for play clients specified.
    # the common refer is not overrided by this.
    # if not specified this field, allow all.
    # default: not specified.
    refer_play      github.com github.io;
}
# config for the pithy print,
# which always print constant message specified by interval,
# whatever the clients in concurrency.
pithy_print {
    # shared print interval for all publish clients, in milliseconds.
    # if not specified, set to 1100.
    publish         2000;
    # shared print interval for all play clients, in milliseconds.
    # if not specified, set to 1300.
    play            3000;
    # shared print interval for all forwarders, in milliseconds.
    # if not specified, set to 2000.
    forwarder       3000;
}