listen 1935 1936;
pid ./objs/srs.pid;
chunk_size 60000;
ff_log_dir ./objs;
srs_log_tank console;
srs_log_level trace;
srs_log_file ./objs/srs.log;
max_connections 1000;
daemon off;
utc_time off;
pithy_print_ms 10000;
heartbeat {
    enabled off;
    interval 9.3;
    url http://127.0.0.1:8085/api/v1/servers;
    device_id my-srs-device;
    summaries off;
}
stats {
    network 0;
    disk sda sdb xvda xvdb;
}
http_api {
    enabled on;
    listen 1985;
    crossdomain on;
    raw_api {
        enabled on;
        allow_reload on;
        allow_query on;
        allow_update on;
    }
}
http_server {
    enabled off;
    listen 8080;
    dir ./objs/nginx/html;
}
stream_caster {
    enabled off;
    caster mpegts_over_udp;
    output rtmp://127.0.0.1/live/livestream;
    listen 8935;
    rtp_port_min 57200;
    rtp_port_max 57300;
}
vhost __defaultVhost__;
vhost vhost.srs.com {
    enabled off;
    chunk_size 128;
    tcp_nodelay on;
    min_latency on;
    cluster {
        mode remote;
        origin 127.0.0.1:1935 localhost:1935;
        token_traverse off;
        vhost same.edge.srs.com;
        debug_srs_upnode off;
    }
    forward {
        enabled off;
        destination 127.0.0.1:1936 127.0.0.1:1937;
    }
    play {
        time_jitter full;
        mix_correct off;
        atc off;
        atc_auto off;
        mw_latency 100;
        gop_cache off;
        queue_length 10;
        send_min_interval 10.0;
        reduce_sequence_header on;
    }
    publish {
        mr off;
        mr_latency 350;
        firstpkt_timeout 20000;
        normal_timeout 7000;
    }
    refer {
        enabled off;
        all github.com github.io;
        publish github.com github.io;
        play github.com github.io;
    }
    bandcheck {
        enabled off;
        key 35c9b402c12a7246868752e2878f7e0e;
        interval 30;
        limit_kbps 4000;
    }
    security {
        enabled off;
        allow play all;
        allow publish all;
        deny publish all;
    }
    http_static {
        enabled off;
        mount [vhost]/hls;
        dir ./objs/nginx/html/hls;
    }
    http_remux {
        enabled off;
        fast_cache 30;
        mount [vhost]/[app]/[stream].flv;
        hstrs on;
    }
    http_hooks {
        enabled off;
        on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients;
        on_close http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients;
        on_publish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams;
        on_unpublish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams;
        on_play http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
        on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
        on_dvr http://127.0.0.1:8085/api/v1/dvrs http://localhost:8085/api/v1/dvrs;
        on_hls http://127.0.0.1:8085/api/v1/hls http://localhost:8085/api/v1/hls;
        on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream][ts_url];
    }
    exec {
        enabled off;
        publish ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv;
    }
    hls {
        enabled off;
        hls_fragment 10;
        hls_td_ratio 1.5;
        hls_aof_ratio 2.0;
        hls_window 60;
        hls_on_error ignore;
        hls_storage disk;
        hls_path ./objs/nginx/html;
        hls_m3u8_file [app]/[stream].m3u8;
        hls_ts_file [app]/[stream]-[seq].ts;
        hls_ts_floor off;
        hls_entry_prefix http://your-server;
        hls_mount [vhost]/[app]/[stream].m3u8;
        hls_acodec aac;
        hls_vcodec h264;
        hls_cleanup on;
        hls_dispose 0;
        hls_nb_notify 64;
        hls_wait_keyframe on;
    }
    hds {
        enabled off;
        hds_fragment 10;
        hds_window 60;
        hds_path ./objs/nginx/html;
    }
    dvr {
        enabled off;
        dvr_plan session;
        dvr_path ./objs/nginx/html/[app]/[stream].[timestamp].flv;
        dvr_duration 30;
        dvr_wait_keyframe on;
        time_jitter full;
    }
    ingest livestream {
        enabled off;
        input {
            type file;
            url ./doc/source.200kbps.768x320.flv;
        }
        ffmpeg ./objs/ffmpeg/bin/ffmpeg;
        engine {
            enabled off;
            iformat flv;
            vfilter {
                s 30;
                ss 300;
            }
            vcodec libx264;
            vbitrate 1500;
            vfps 25;
            vwidth 768;
            vheight 320;
            vthreads 12;
            vprofile main;
            vpreset medium;
            vparams {
                t 100;
                coder 1;
                b_strategy 2;
                bf 3;
                refs 10;
            }
            acodec libfdk_aac;
            abitrate 70;
            asample_rate 44100;
            achannels 2;
            aparams {
                profile:a aac_low;
            }
            oformat flv;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream];
        }
    }
    transcode live {
        enabled off;
        ffmpeg ./objs/ffmpeg/bin/ffmpeg;
        engine ffsuper {
            enabled off;
            iformat flv;
            vfilter {
                s 30;
                ss 300;
            }
            vcodec libx264;
            vbitrate 1500;
            vfps 25;
            vwidth 768;
            vheight 320;
            vthreads 12;
            vprofile main;
            vpreset medium;
            vparams {
                t 100;
                coder 1;
                b_strategy 2;
                bf 3;
                refs 10;
            }
            acodec libfdk_aac;
            abitrate 70;
            asample_rate 44100;
            achannels 2;
            aparams {
                profile:a aac_low;
            }
            oformat flv;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
    }
    transcode {
        enabled off;
        ffmpeg ./objs/ffmpeg/bin/ffmpeg;
        engine ffsuper {
            enabled off;
            iformat flv;
            vfilter {
                s 30;
                ss 300;
            }
            vcodec libx264;
            vbitrate 1500;
            vfps 25;
            vwidth 768;
            vheight 320;
            vthreads 12;
            vprofile main;
            vpreset medium;
            vparams {
                t 100;
                coder 1;
                b_strategy 2;
                bf 3;
                refs 10;
            }
            acodec libfdk_aac;
            abitrate 70;
            asample_rate 44100;
            achannels 2;
            aparams {
                profile:a aac_low;
            }
            oformat flv;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
        engine ffhd {
            enabled off;
            vcodec libx264;
            vbitrate 1200;
            vfps 25;
            vwidth 1382;
            vheight 576;
            vthreads 6;
            vprofile main;
            vpreset medium;
            vparams;
            acodec libfdk_aac;
            abitrate 70;
            asample_rate 44100;
            achannels 2;
            aparams;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
        engine ffsd {
            enabled off;
            vcodec libx264;
            vbitrate 800;
            vfps 25;
            vwidth 1152;
            vheight 480;
            vthreads 4;
            vprofile main;
            vpreset fast;
            vparams;
            acodec libfdk_aac;
            abitrate 60;
            asample_rate 44100;
            achannels 2;
            aparams;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
        engine fffast {
            enabled off;
            vcodec libx264;
            vbitrate 300;
            vfps 20;
            vwidth 768;
            vheight 320;
            vthreads 2;
            vprofile baseline;
            vpreset superfast;
            vparams;
            acodec libfdk_aac;
            abitrate 45;
            asample_rate 44100;
            achannels 2;
            aparams;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
        engine vcopy {
            enabled off;
            vcodec copy;
            acodec libfdk_aac;
            abitrate 45;
            asample_rate 44100;
            achannels 2;
            aparams;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
        engine acopy {
            enabled off;
            vcodec libx264;
            vbitrate 300;
            vfps 20;
            vwidth 768;
            vheight 320;
            vthreads 2;
            vprofile baseline;
            vpreset superfast;
            vparams;
            acodec copy;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
        engine copy {
            enabled off;
            vcodec copy;
            acodec copy;
            output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
        }
    }
}