正在显示
3 个修改的文件
包含
132 行增加
和
2 行删除
| @@ -15,7 +15,129 @@ vhost __defaultVhost__ { | @@ -15,7 +15,129 @@ vhost __defaultVhost__ { | ||
| 15 | hls_path ./objs/nginx/html; | 15 | hls_path ./objs/nginx/html; |
| 16 | hls_fragment 5; | 16 | hls_fragment 5; |
| 17 | hls_window 30; | 17 | hls_window 30; |
| 18 | - forward 127.0.0.1:1936; | 18 | + #forward 127.0.0.1:1936; |
| 19 | + transcode { | ||
| 20 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 21 | + engine fd{ | ||
| 22 | + vcodec libx264; | ||
| 23 | + vbitrate 300; | ||
| 24 | + vfps 20; | ||
| 25 | + vwidth 480; | ||
| 26 | + vheight 320; | ||
| 27 | + vthreads 2; | ||
| 28 | + vprofile baseline; | ||
| 29 | + vpreset superfast; | ||
| 30 | + vparams {} | ||
| 31 | + acodec libaacplus; | ||
| 32 | + abitrate 30; | ||
| 33 | + asample_rate 22050; | ||
| 34 | + achannels 2; | ||
| 35 | + aparams {} | ||
| 36 | + output rtmp://[vhost]:[port]/[app]/[stream]_fast; | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | +} | ||
| 40 | +# transcode all app and stream of vhost | ||
| 41 | +vhost all.transcode.vhost.com { | ||
| 42 | + transcode { | ||
| 43 | + # the ffmpeg | ||
| 44 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 45 | + # all matched stream will transcoded to the following stream. | ||
| 46 | + # the transcode set name(ie. hd) is optional and not used. | ||
| 47 | + engine super{ | ||
| 48 | + # video encoder name | ||
| 49 | + vcodec libx264; | ||
| 50 | + # video bitrate, in kbps | ||
| 51 | + vbitrate 1500; | ||
| 52 | + # video framerate. | ||
| 53 | + vfps 25; | ||
| 54 | + # video width, must be even numbers. | ||
| 55 | + vwidth 1280; | ||
| 56 | + # video height, must be even numbers. | ||
| 57 | + vheight 720; | ||
| 58 | + # the max threads for ffmpeg to used. | ||
| 59 | + vthreads 12; | ||
| 60 | + # x264 profile, @see x264 -help, can be: | ||
| 61 | + # high,main,baseline | ||
| 62 | + vprofile main; | ||
| 63 | + # x264 preset, @see x264 -help, can be: | ||
| 64 | + # ultrafast,superfast,veryfast,faster,fast | ||
| 65 | + # medium,slow,slower,veryslow,placebo | ||
| 66 | + vpreset medium; | ||
| 67 | + # other x264 or ffmpeg video params | ||
| 68 | + vparams { | ||
| 69 | + } | ||
| 70 | + # audio encoder name | ||
| 71 | + acodec libaacplus; | ||
| 72 | + # audio bitrate, in kbps. [16, 72] for libaacplus. | ||
| 73 | + abitrate 70; | ||
| 74 | + # audio sample rate. for flv/rtmp, it must be: | ||
| 75 | + # 44100,22050,11025,5512 | ||
| 76 | + asample_rate 44100; | ||
| 77 | + # audio channel, 1 for mono, 2 for stereo. | ||
| 78 | + achannels 2; | ||
| 79 | + # other ffmpeg audio params | ||
| 80 | + aparams { | ||
| 81 | + } | ||
| 82 | + # output stream. variables: | ||
| 83 | + # [vhost] the input stream vhost. | ||
| 84 | + # [port] the intput stream port. | ||
| 85 | + # [app] the input stream app. | ||
| 86 | + # [stream] the input stream name. | ||
| 87 | + output rtmp://[vhost]:[port]/[app]/[stream]_super; | ||
| 88 | + } | ||
| 89 | + engine hd{ | ||
| 90 | + vcodec libx264; | ||
| 91 | + vbitrate 1200; | ||
| 92 | + vfps 25; | ||
| 93 | + vwidth 1024; | ||
| 94 | + vheight 576; | ||
| 95 | + vthreads 6; | ||
| 96 | + vprofile main; | ||
| 97 | + vpreset medium; | ||
| 98 | + vparams {} | ||
| 99 | + acodec libaacplus; | ||
| 100 | + abitrate 70; | ||
| 101 | + asample_rate 44100; | ||
| 102 | + achannels 2; | ||
| 103 | + aparams {} | ||
| 104 | + output rtmp://[vhost]:[port]/[app]/[stream]_hd; | ||
| 105 | + } | ||
| 106 | + engine sd{ | ||
| 107 | + vcodec libx264; | ||
| 108 | + vbitrate 800; | ||
| 109 | + vfps 25; | ||
| 110 | + vwidth 720; | ||
| 111 | + vheight 480; | ||
| 112 | + vthreads 4; | ||
| 113 | + vprofile main; | ||
| 114 | + vpreset fast; | ||
| 115 | + vparams {} | ||
| 116 | + acodec libaacplus; | ||
| 117 | + abitrate 60; | ||
| 118 | + asample_rate 44100; | ||
| 119 | + achannels 2; | ||
| 120 | + aparams {} | ||
| 121 | + output rtmp://[vhost]:[port]/[app]/[stream]_sd; | ||
| 122 | + } | ||
| 123 | + engine fast{ | ||
| 124 | + vcodec libx264; | ||
| 125 | + vbitrate 300; | ||
| 126 | + vfps 20; | ||
| 127 | + vwidth 480; | ||
| 128 | + vheight 320; | ||
| 129 | + vthreads 2; | ||
| 130 | + vprofile baseline; | ||
| 131 | + vpreset superfast; | ||
| 132 | + vparams {} | ||
| 133 | + acodec libaacplus; | ||
| 134 | + abitrate 30; | ||
| 135 | + asample_rate 22050; | ||
| 136 | + achannels 2; | ||
| 137 | + aparams {} | ||
| 138 | + output rtmp://[vhost]:[port]/[app]/[stream]_fast; | ||
| 139 | + } | ||
| 140 | + } | ||
| 19 | } | 141 | } |
| 20 | # the vhost which forward publish streams. | 142 | # the vhost which forward publish streams. |
| 21 | vhost forward.vhost.com { | 143 | vhost forward.vhost.com { |
| @@ -109,3 +231,4 @@ pithy_print { | @@ -109,3 +231,4 @@ pithy_print { | ||
| 109 | forwarder 3000; | 231 | forwarder 3000; |
| 110 | } | 232 | } |
| 111 | 233 | ||
| 234 | + |
| @@ -58,7 +58,7 @@ bool is_common_space(char ch) | @@ -58,7 +58,7 @@ bool is_common_space(char ch) | ||
| 58 | return (ch == ' ' || ch == '\t' || ch == CR || ch == LF); | 58 | return (ch == ' ' || ch == '\t' || ch == CR || ch == LF); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | -#define CONF_BUFFER_SIZE 4096 | 61 | +#define CONF_BUFFER_SIZE 1024 * 1024 |
| 62 | 62 | ||
| 63 | SrsFileBuffer::SrsFileBuffer() | 63 | SrsFileBuffer::SrsFileBuffer() |
| 64 | { | 64 | { |
| @@ -369,6 +369,12 @@ int SrsConfDirective::refill_buffer(SrsFileBuffer* buffer, bool d_quoted, bool s | @@ -369,6 +369,12 @@ int SrsConfDirective::refill_buffer(SrsFileBuffer* buffer, bool d_quoted, bool s | ||
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | int size = FILE_SIZE(buffer->fd) - FILE_OFFSET(buffer->fd); | 371 | int size = FILE_SIZE(buffer->fd) - FILE_OFFSET(buffer->fd); |
| 372 | + if (size > CONF_BUFFER_SIZE) { | ||
| 373 | + ret = ERROR_SYSTEM_CONFIG_TOO_LARGE; | ||
| 374 | + srs_error("config file too large, max=%d, actual=%d, ret=%d", | ||
| 375 | + CONF_BUFFER_SIZE, size, ret); | ||
| 376 | + return ret; | ||
| 377 | + } | ||
| 372 | 378 | ||
| 373 | if (size <= 0) { | 379 | if (size <= 0) { |
| 374 | return ERROR_SYSTEM_CONFIG_EOF; | 380 | return ERROR_SYSTEM_CONFIG_EOF; |
| @@ -84,6 +84,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -84,6 +84,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 84 | #define ERROR_SYSTEM_CONFIG_EOF 409 | 84 | #define ERROR_SYSTEM_CONFIG_EOF 409 |
| 85 | #define ERROR_SYSTEM_STREAM_BUSY 410 | 85 | #define ERROR_SYSTEM_STREAM_BUSY 410 |
| 86 | #define ERROR_SYSTEM_IP_INVALID 411 | 86 | #define ERROR_SYSTEM_IP_INVALID 411 |
| 87 | +#define ERROR_SYSTEM_CONFIG_TOO_LARGE 412 | ||
| 87 | 88 | ||
| 88 | // see librtmp. | 89 | // see librtmp. |
| 89 | // failed when open ssl create the dh | 90 | // failed when open ssl create the dh |
-
请 注册 或 登录 后发表评论