{"id":255764,"date":"2017-05-07T20:15:19","date_gmt":"2017-05-07T12:15:19","guid":{"rendered":"http:\/\/blog.zhenglei.net\/?p=255764"},"modified":"2017-05-07T21:04:49","modified_gmt":"2017-05-07T13:04:49","slug":"crtmpserver%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/blog.zhenglei.net\/?p=255764","title":{"rendered":"crtmpserver\u914d\u7f6e\u6587\u4ef6\u8be6\u89e3"},"content":{"rendered":"<p><a href=\"http:\/\/www.cnblogs.com\/zjoch\/p\/3277198.html\">http:\/\/www.cnblogs.com\/zjoch\/p\/3277198.html<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1><span style=\"color: #ff0000\"><strong>crtmpserver<\/strong><strong>\u914d\u7f6e\u6587\u4ef6\u8be6\u89e3 <\/strong><\/span><\/h1>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"color: #0000ff\">Configuration file<\/span><\/strong><\/p>\n<p><strong><span style=\"color: #0000ff\">\u914d\u7f6e\u6587\u4ef6<\/span><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The configuration file is actually a lua script which must contain an<\/p>\n<p>object called configuration.<\/p>\n<p>This will be read by the server and used to fully configure the server.<\/p>\n<p>Besides this object called<\/p>\n<p>configuration you can have functions, include other lua libraries, etc.<\/p>\n<p>In the end, you have to<\/p>\n<p>make the configuration object available. The rest of this section will<\/p>\n<p>explain the structue of<\/p>\n<p>configuration object in great detail. But first, let&#8217;s take an bird-eye<\/p>\n<p>view.<\/p>\n<p>&nbsp;<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2aLua\u811a\u672c\uff0c\u5b83\u5305\u542b\u81f3\u5c11\u4e00\u4e2aconfiguration\u7684\u5bf9\u8c61\uff0c<\/p>\n<p>\u4ece\u800c\u4e3a\u7a0b\u5e8f\u63d0\u4f9b\u7075\u6d3b\u7684\u6269\u5c55\u548c\u5b9a\u5236\u529f\u80fd\u3002<\/p>\n<p>\u9664\u4e86configuration\u5bf9\u8c61\u5916\uff0c\u8fd8\u53ef\u4ee5\u6709\u51fd\u6570\uff0cLua\u5e93\u7b49\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1><span style=\"color: #0000ff\"><strong>Main structure<\/strong><\/span><\/h1>\n<h1><span style=\"color: #0000ff\"><strong>\u4e3b\u7ed3\u6784<\/strong><\/span><\/h1>\n<p>&nbsp;<\/p>\n<p>configuration=<\/p>\n<p>{<\/p>\n<p>daemon=false,<\/p>\n<p>pathSeparator=&#8221;\/&#8221;,<\/p>\n<p>logAppenders=<\/p>\n<p>{<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>applications=<\/p>\n<p>{<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>configuration structure<\/strong><\/p>\n<p>key type\u00a0\u00a0\u00a0 mandatory\u00a0 description<\/p>\n<p>daemon boolean \u00a0\u00a0 yes \u00a0\u00a0\u00a0 true means the server will start in daemon mode.<\/p>\n<p>false means it will start in console mode (nice for development)<\/p>\n<p>true\u00a0 \u8868\u793a \u670d\u52a1\u4ee5\u540e\u53f0\u65b9\u5f0f\u542f\u52a8;<\/p>\n<p>false \u8868\u793a \u670d\u52a1\u4ee5\u63a7\u5236\u53f0\u6a21\u5f0f\u542f\u52a8(\u4ee5\u7528\u4e8e\u5f00\u53d1);<\/p>\n<p>pathSeparator string(1) yes \u00a0\u00a0\u00a0 This value will be used by the server to<\/p>\n<p>compose paths (like media files paths).<\/p>\n<p>Examples: on UNIX-like systems this is \/ while on windows is \\.<\/p>\n<p>Special care must be taken when you specify this values on windows<\/p>\n<p>because \\ is an escape sequence for lua so the value should be \u201c\\\\\u201d<\/p>\n<p>\u7528\u6765\u5206\u9694\u8def\u5f84;<\/p>\n<p>\u4f8b\u5982\uff0c\u5728UNIX-like\u662f \/, Windows\u662f \\\u00a0 ;<\/p>\n<p>logAppenders \u00a0 object yes \u00a0\u00a0\u00a0 Will hold a collection of log appenders. Each<\/p>\n<p>of log messages will pass through all the log appenders enumerated here.<\/p>\n<p>More details below<\/p>\n<p>\u914d\u7f6e\u65e5\u5fd7\u8ffd\u52a0\u7684\u5bb9\u5668 &lt;http:\/\/wiki.rtmpd.com\/documentation#logappenders&gt;<\/p>\n<p>applications \u00a0 object yes \u00a0\u00a0\u00a0 Will hold a collection of loaded applications.<\/p>\n<p>Besides that, it will also hold few other values. More detailsbelow<\/p>\n<p>\u914d\u7f6e\u52a0\u8f7d\u5404\u79cd\u5e94\u7528\u7684\u5bb9\u5668 &lt;http:\/\/wiki.rtmpd.com\/documentation#applications&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>When the server starts, the following sequence of operations is performed:<\/p>\n<p>\u670d\u52a1\u542f\u52a8\u65f6\uff0c\u5c06\u6309\u987a\u5e8f\u6267\u884c\u4e0b\u5217\u64cd\u4f5c:<\/p>\n<p>&nbsp;<\/p>\n<p>1.<\/p>\n<p>The configuration file is loaded. Part of the loading process, is<\/p>\n<p>the verification.<\/p>\n<p>If something is wrong with the syntax please read this<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u52a0\u8f7d\u540e\uff0c\u9996\u5148\u505a\u7684\u5c31\u662f\u5bf9\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u6821\u9a8c\uff0c<\/p>\n<p>\u5982\u679c\u914d\u7f6e\u6587\u4ef6\u6709\u9519\u8bef\uff0c\u5c06\u4f1a\u6709\u9519\u8bef\u63d0\u793a\u5e76\u505c\u6b62\u542f\u52a8\uff0c\u53ef\u8fdb\u884c\u4fee\u6539\u540e\u518d\u542f\u52a8<\/p>\n<p>&lt;http:\/\/wiki.rtmpd.com\/faq#qi_run_server_but_it_silently_shutdown_what_is_wrong&gt;<\/p>\n<p>2.<\/p>\n<p>daemon value is read. The server now will either fork to become daemon<\/p>\n<p>or continue as is in console mode<\/p>\n<p>\u8bfb\u53d6 daemon \u503c\uff0c\u5224\u65ad\u670d\u52a1\u662f\u4ee5\u540e\u53f0\u65b9\u5f0f\u542f\u52a8\u8fd8\u662f\u4ee5\u63a7\u5236\u53f0\u65b9\u5f0f\u542f\u52a8<\/p>\n<p>3.<\/p>\n<p>logAppenders is read. This is where all log appenders are configured<\/p>\n<p>and brought up to running state.<\/p>\n<p>Depending on the collection of your log appenders, you may (not) see<\/p>\n<p>further log messages<\/p>\n<p>\u8bfb\u53d6\u65e5\u5fd7\u8ffd\u52a0\u5668\uff0c\u7528\u6765\u914d\u7f6e\u65e5\u5fd7\u8bb0\u5f55\u5e76\u542f\u52a8\u5230\u8fd0\u884c\u72b6\u6001\uff0c<\/p>\n<p>\u4f9d\u636e\u65e5\u5fd7\u8ffd\u52a0\u5668\uff0c\u53ef\u4ee5\u770b\u5230\u66f4\u591a\u7684\u65e5\u5fd7\u4fe1\u606f<\/p>\n<p>4.<\/p>\n<p>applications is taken into consideration. Up until now, the server<\/p>\n<p>doesn&#8217;t do much.<\/p>\n<p>After this stage completes, all the applications are fully<\/p>\n<p>functional and the server is online and ready to do stuff<\/p>\n<p>\u6700\u540e\u7684\u5e94\u7528\u52a0\u8f7d\uff0c\u53ea\u5230\u8fd9\u4e00\u6b65\u5b8c\u6210\u540e\uff0c\u670d\u52a1\u548c\u5e94\u7528\u624d\u5728\u7ebf\uff0c\u5e76\u51c6\u5907\u5c31\u7eea\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"color: #0000ff\">\u65e5\u5fd7\u8ffd\u52a0\u5668<\/span><\/strong><\/p>\n<p><strong><span style=\"color: #0000ff\">logAppenders<\/span><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>This section contains a list of log appenders. The entire collection of<\/p>\n<p>appenders listed in this section<\/p>\n<p>is loaded inside the logger at config-time. All log messages will be<\/p>\n<p>than passed to all this log appenders.<\/p>\n<p>Depending on the log level, an appender may (not) log the message.<\/p>\n<p>\u201cLogging\u201d a message means \u201csaving\u201d<\/p>\n<p>it on the specified \u201cmedia\u201d (in the example below we have a console<\/p>\n<p>appender and a file).<\/p>\n<p>\u8fd9\u90e8\u5206\u5305\u542b\u4e86\u4e00\u4e2a\u65e5\u5fd7\u8ffd\u52a0\u5668\u7684\u5217\u8868\u3002<\/p>\n<p>\u6574\u4e2a\u65e5\u5fd7\u8ffd\u52a0\u5668\u7684\u6dfb\u52a0\u662f\u5728\u52a0\u8f7d\u65f6\u914d\u7f6e\uff0c<\/p>\n<p>\u4f9d\u636e\u65e5\u5fd7\u7ea7\u522b\uff0c\u8ffd\u52a0\u5668\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u6709\u65e5\u5fd7\u6d88\u606f\u8f93\u51fa\u5230\u6307\u5b9a\u76ee\u7684\u5904\uff1b<\/p>\n<p>logAppenders=<\/p>\n<p>{<\/p>\n<p>{<\/p>\n<p>name=&#8221;console appender&#8221;,<\/p>\n<p>type=&#8221;coloredConsole&#8221;,<\/p>\n<p>level=6<\/p>\n<p>},<\/p>\n<p>{<\/p>\n<p>name=&#8221;file appender&#8221;,<\/p>\n<p>type=&#8221;file&#8221;,<\/p>\n<p>level=6,<\/p>\n<p>fileName=&#8221;\/tmp\/crtmpserver.log&#8221;<\/p>\n<p>}<\/p>\n<p>},<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>logAppenders structure<\/strong><\/p>\n<p>key type\u00a0\u00a0\u00a0 mandatory\u00a0 description<\/p>\n<p>name \u00a0\u00a0 string yes \u00a0\u00a0\u00a0 The name of the appender. Is usually used inside<\/p>\n<p>pretty print routines<\/p>\n<p>\u8ffd\u52a0\u5668\u7684\u540d\u5b57.<\/p>\n<p>type \u00a0\u00a0 string yes \u00a0\u00a0\u00a0 The type of the appender. It can<\/p>\n<p>be console, coloredConsole or file. console and<\/p>\n<p>coloredConsole will output to console. The difference between them is<\/p>\n<p>that coloredConsole<\/p>\n<p>will also apply a color to the message, depending on the log level.<\/p>\n<p>Quite useful when eye-balling the console.<\/p>\n<p>file log appender will output everything on the specified file<\/p>\n<p>\u8ffd\u52a0\u5668\u7684\u7c7b\u578b<\/p>\n<p>\u53ef\u4ee5\u662f\u63a7\u5236\u53f0\uff0c\u5e26\u989c\u8272\u63a7\u5236\u53f0\u6216\u6587\u4ef6\uff1b<\/p>\n<p>\u63a7\u5236\u53f0\u548c\u5e26\u989c\u8272\u63a7\u5236\u53f0 \u90fd\u4f1a\u5c06\u65e5\u5fd7\u6d88\u606f\u8f93\u51fa\u5230\u63a7\u5236\u53f0\uff0c<\/p>\n<p>\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u5e26\u989c\u8272\u63a7\u5236\u53f0\u4f1a\u4f9d\u636e\u65e5\u5fd7\u7ea7\u522b\u8fdb\u884c\u989c\u8272\u6807\u8bb0\uff1b<\/p>\n<p>\u6587\u4ef6\u7c7b\u578b\u5219\u4f1a\u5c06\u6240\u6709\u6d88\u606f\u8f93\u51fa\u5230\u6307\u5b9a\u7684\u6587\u4ef6\uff1b<\/p>\n<p>level \u00a0 number yes \u00a0\u00a0\u00a0 The log level used. The values are presented just<\/p>\n<p>below. Any message having having a log level<\/p>\n<p>less or equal to this value will be logged. The rest are discarded.<\/p>\n<p>Example: setting level to 0, will only log FATAL errors.<\/p>\n<p>Setting it to 3, will only log FATAL, ERROR, WARNING and INFO<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff\"><strong>\u65e5\u5fd7\u7684\u7ea7\u522b<\/strong><\/span><\/p>\n<p>\u53ef\u89c1\u4e0b\u8868\u4e2d\u7684\u7ea7\u522b\u5b9a\u4e49\uff1b<\/p>\n<p>\u53ea\u6709\u5c0f\u4e8e\u6216\u7b49\u4e8e\u8fd9\u4e2a\u7ea7\u522b\u7684\u65e5\u5fd7\u6d88\u606f\u4f1a\u88ab\u8bb0\u5f55\uff0c\u9ad8\u4e8e\u8fd9\u4e2a\u7ea7\u522b\u5219\u90fd\u88ab\u4e22\u5f03\uff1b<\/p>\n<p>\u4f8b\u5982:<\/p>\n<p>\u7ea7\u522b\u4e3a0\u65f6\uff0c\u53ea\u8bb0\u5f55 FATAL \u6d88\u606f\uff1b<\/p>\n<p>\u7ea7\u522b\u4e3a3\u65f6\uff0c\u53ea\u8bb0\u5f55 FATAL, ERROR, WARNING, INFO \u6d88\u606f\uff1b<\/p>\n<p>fileName \u00a0 string yes \u00a0\u00a0\u00a0 If the type of appender is a file, this will<\/p>\n<p>contain the path of the file<\/p>\n<p>\u5982\u679c\u8ffd\u52a0\u5668\u7c7b\u578b\u4e3a\u6587\u4ef6\uff0c\u5219\u5728\u6b64\u5904\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u548c\u8def\u5f84<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Log levels<\/strong><\/p>\n<p>Name\u00a0\u00a0\u00a0 Value<\/p>\n<p>0 \u00a0 FATAL<\/p>\n<p>1 \u00a0 ERROR<\/p>\n<p>2 \u00a0 WARNING<\/p>\n<p>3 \u00a0 INFO<\/p>\n<p>4 \u00a0 DEBUG<\/p>\n<p>5 \u00a0 FINE<\/p>\n<p>6 \u00a0 FINEST<\/p>\n<p>&nbsp;<\/p>\n<p>Observation: When daemon mode is set to true, all console appenders will<\/p>\n<p>be ignored.<\/p>\n<p>(Read the explanation for daemon setting here<\/p>\n<p>&lt;http:\/\/wiki.rtmpd.com\/documentation#main_structure&gt;)<\/p>\n<p>\u6ce8\u610f:<\/p>\n<p>\u5f53\u4f7f\u7528\u540e\u53f0\u6a21\u5f0f\u65f6\uff0c\u6240\u6709\u7684\u63a7\u5236\u53f0\u8ffd\u52a0\u6d88\u606f\u5c06\u4f1a\u88ab\u5ffd\u7565\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff\"><strong>\u5e94\u7528<\/strong><\/span><\/p>\n<p><span style=\"color: #0000ff\"><strong>Applications<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>This section is where all the applications inside the server are placed.<\/p>\n<p>It holds the attributes of each application that the server will use to<\/p>\n<p>launch them.<\/p>\n<p>Each application may have specific attributes that it requires to<\/p>\n<p>execute its own functionality.<\/p>\n<p>\u8fd9\u90e8\u5206\u7528\u6765\u914d\u7f6e\u5404\u79cd\u5e94\u7528\uff0c\u5e76\u8bbe\u7f6e\u8fd9\u4e9b\u5e94\u7528\u7684\u5c5e\u6027\uff1b<\/p>\n<p>\u6bcf\u4e2a\u5e94\u7528\u7684\u5c5e\u6027\u90fd\u5bf9\u5e94\u4e86\u8fd9\u4e2a\u5e94\u7528\u7684\u6307\u5b9a\u529f\u80fd\uff1b<\/p>\n<p>applications=<\/p>\n<p>{<\/p>\n<p>rootDirectory=&#8221;applications&#8221;,<\/p>\n<p>{<\/p>\n<p>&#8212; settings for application 1<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>{<\/p>\n<p>&#8212; settings for application 2<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>{<\/p>\n<p>&#8212; settings for application 3<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff\"><strong>Applications Structure<\/strong><\/span><\/p>\n<p>key type\u00a0\u00a0\u00a0 mandatory\u00a0 description<\/p>\n<p>rootDirectory string true \u00a0\u00a0 The folder containing applications<\/p>\n<p>subfolders. If this path begins with a \/ or \\ (depending on the OS),<\/p>\n<p>than is treated as an absolute path. Otherwise is treated as a path<\/p>\n<p>relative to the run-time directory<\/p>\n<p>(the place where you started the server)<\/p>\n<p>\u8fd9\u4e2a\u76ee\u5f55\u5305\u542b\u4e86\u5e94\u7528\u7684\u5b50\u76ee\u5f55\uff1b<\/p>\n<p>\u5982\u679c\u8def\u5f84\u4ee5 \/ \u6216 \\ \u5f00\u59cb\uff0c \u5219\u89c6\u5176\u4e3a\u7edd\u5bf9\u8def\u5f84\uff0c\u5426\u5219\u89c6\u4e3a\u542f\u52a8\u670d\u52a1\u65f6\u6240\u5728\u7684\u76f8\u5bf9<\/p>\n<p>\u8def\u5f84\uff1b<\/p>\n<p>&nbsp;<\/p>\n<p>Following the rootDirectory, there is a collection of applications. Each<\/p>\n<p>application has<\/p>\n<p>its properties contained in an object. See details below<\/p>\n<p>rootDirectory \u4e4b\u540e\uff0c\u662f\u5e94\u7528\u7684\u96c6\u5408\uff1b\u6bcf\u4e2a\u5e94\u7528\u90fd\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6709\u7279\u5b9a\u5c5e\u6027\u7684\u5bf9\u8c61\uff1b<\/p>\n<p>\u7ec6\u8282\u5982\u4e0b\u6240\u793a\uff1b &lt;http:\/\/wiki.rtmpd.com\/documentation#application_definition&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff\"><strong>\u5e94\u7528\u5b9a\u4e49<\/strong><\/span><\/p>\n<p><span style=\"color: #0000ff\"><strong>Application Definition<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>This is where the settings of an application are defined. We will<\/p>\n<p>present only the<\/p>\n<p>settings common to all applications. Later on, we will also explain the<\/p>\n<p>settings particular to certain<\/p>\n<p>applications Since revision 790 there is a new cool feature:<\/p>\n<p>mediaStorage; with this feature<\/p>\n<p>basicaly an application may have multiple mediaFolder&#8217;s and .seek\/.meta<\/p>\n<p>files are now stored into<\/p>\n<p>separate folder from media file that are streamed.<\/p>\n<p>\u8fd9\u4e9b\u76ee\u5f55\u7528\u6765\u5b9a\u4e49\u5e94\u7528.<\/p>\n<p>\u81ea\u4ece790\u7248\u672c\u540e\uff0c\u6dfb\u52a0\u4e86\u4e00\u65b0\u7684\u529f\u80fd\uff1amediaStorage;<\/p>\n<p>\u8fd9\u4e2a\u529f\u80fd\u80fd\u4f7f\u5e94\u7528\u53ef\u4ee5\u6709\u591a\u4e2amediaFolder\uff0c<\/p>\n<p>\u5e76\u4e14\u53ef\u4ee5\u5c06.seek\/.meta\u6587\u4ef6\u548c\u5a92\u4f53\u6587\u4ef6\u5206\u5f00\u5b58\u50a8\u5728\u4e0d\u540c\u7684\u6587\u4ef6\u5939\u4e2d\uff1b<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>{<\/p>\n<p>name=&#8221;flvplayback&#8221;,<\/p>\n<p>protocol=&#8221;dynamiclinklibrary&#8221;,<\/p>\n<p>description=&#8221;FLV Playback Sample&#8221;,<\/p>\n<p>default=false,<\/p>\n<p>validateHandshake=true,<\/p>\n<p>enableCheckBandwidth=true,<\/p>\n<p>&#8212; this settings are now part of mediaStorage setting<\/p>\n<p>&#8212; keyframeSeek=true,<\/p>\n<p>&#8212; seekGranularity=1.5,<\/p>\n<p>&#8212; clientSideBuffer=12,<\/p>\n<p>&#8212; generateMetaFiles=true,<\/p>\n<p>&#8212; renameBadFiles=true,<\/p>\n<p>aliases=<\/p>\n<p>{<\/p>\n<p>&#8220;simpleLive&#8221;,<\/p>\n<p>&#8220;vod&#8221;,<\/p>\n<p>&#8220;live&#8221;,<\/p>\n<p>&#8220;WeeklyQuest&#8221;,<\/p>\n<p>&#8220;SOSample&#8221;,<\/p>\n<p>&#8220;oflaDemo&#8221;,<\/p>\n<p>&#8220;chat&#8221;,<\/p>\n<p>},<\/p>\n<p>acceptors =<\/p>\n<p>{<\/p>\n<p>{<\/p>\n<p>&#8212; acceptor 1<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>{<\/p>\n<p>&#8212; acceptor 2<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>{<\/p>\n<p>&#8212; acceptor n<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>},<\/p>\n<p>&#8212; new feature mediaStorage<\/p>\n<p>mediaStorage = {<\/p>\n<p>namedStorage1={<\/p>\n<p>description=&#8221;Main storage&#8221;,<\/p>\n<p>mediaFolder=&#8221;\/usr\/main_storage\/media&#8221;, &#8212; only this parameter IS<\/p>\n<p>MANDATORY<\/p>\n<p>metaFolder=&#8221;\/usr\/main_storage\/metadata&#8221;, &#8212; if you have static<\/p>\n<p>large file to stream it is good to know that for a file around 500MB<\/p>\n<p>&#8212; it&#8217;s .seek file has<\/p>\n<p>around 16MB; so it would be preffer to designate metafolder into a system<\/p>\n<p>&#8212; partition which has<\/p>\n<p>enough space&#8230; for no surprises&#8230; \ud83d\ude42<\/p>\n<p>statsFolder=&#8221;\/usr\/main_storage\/statsFolder&#8221;,<\/p>\n<p>enableStats=true,<\/p>\n<p>clientSideBuffer=16,<\/p>\n<p>keyframeSeek=false, &#8212; should crtmpdserver DO SEEK ONLY IN<\/p>\n<p>key-frame (true\/false)?<\/p>\n<p>&#8212; very useful to know in situations like<\/p>\n<p>play\/pause\/resume (meaning pause\/seek\/play)<\/p>\n<p>seekGranularity=1,<\/p>\n<p>generateMetaFiles=false,<\/p>\n<p>renameBadFiles=false,<\/p>\n<p>},<\/p>\n<p>&#8211;[[{<\/p>\n<p>&#8212; here is another example of storage; it does not start with<\/p>\n<p>name={&#8230;}<\/p>\n<p>description=&#8221;Second storage of same application&#8221;,<\/p>\n<p>mediaFolder=&#8221;\/usr\/second_storage\/media\/flv&#8221;,<\/p>\n<p>metaFolder=&#8221;\/usr\/second_storage\/metadata&#8221;,<\/p>\n<p>statsFolder=&#8221;\/usr\/second_storage\/statsFolder&#8221;,<\/p>\n<p>},]]&#8211;<\/p>\n<p>},<\/p>\n<p>externalStreams =<\/p>\n<p>{<\/p>\n<p>{<\/p>\n<p>&#8212; stream 1<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>{<\/p>\n<p>&#8212; stream 2<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>{<\/p>\n<p>&#8212; stream n<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>},<\/p>\n<p>},<\/p>\n<p>authentication=<\/p>\n<p>{<\/p>\n<p>&#8212; content removed for clarity<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Application Structure<\/strong><\/p>\n<p>key type\u00a0\u00a0\u00a0 mandatory\u00a0 description<\/p>\n<p>name \u00a0\u00a0 string yes \u00a0\u00a0\u00a0 Name of application.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"color: #0000ff\">\u5e94\u7528\u7684\u540d\u79f0<\/span><\/strong><\/p>\n<p>protocol \u00a0 string yes \u00a0\u00a0\u00a0 Type of application. The<\/p>\n<p>value dynamiclinklibrary means the application is a shared library.<\/p>\n<p>\u5e94\u7528\u7684\u7c7b\u578b<\/p>\n<p>\u503c\u4e3a dynamiclinklibrary \u610f\u5373 \u5e94\u7528\u662f\u4e00\u4e2a\u5171\u4eab\u5e93<\/p>\n<p>description \u00a0\u00a0 string no You can put a description of the application here.<\/p>\n<p>\u5e94\u7528\u7684\u63cf\u8ff0\u4fe1\u606f<\/p>\n<p>default \u00a0\u00a0 boolean \u00a0\u00a0 no This flag designates the default application.<\/p>\n<p>The default application is responsible in analyzing the connectrequest<\/p>\n<p>and distribute the future connection to the correct application.<\/p>\n<p>\u8fd9\u4e2a\u6807\u5fd7\u6307\u5b9a\u4e86\u9ed8\u8ba4\u5e94\u7528\uff1b<\/p>\n<p>\u9ed8\u8ba4\u5e94\u7528\u8d1f\u8d23\u5206\u6790\u8fde\u63a5\u8bf7\u6c42\u5e76\u5c06\u8fde\u63a5\u5206\u914d\u5230\u6b63\u786e\u7684\u5e94\u7528<\/p>\n<p>validateHandshake boolean \u00a0\u00a0 no Tells the server to validate the<\/p>\n<p>client&#8217;s handshake before going further.<\/p>\n<p>This is optional with a default value of true. If this is true and the<\/p>\n<p>handshake fails,<\/p>\n<p>the connection is dropped. If this is false, handshake validation will<\/p>\n<p>not be enforced<\/p>\n<p>and all the connections are accepted no matter if they are correctly<\/p>\n<p>hand shaking or not.<\/p>\n<p>\u901a\u77e5\u670d\u52a1\u5668\u5728\u8fdb\u884c\u4e0b\u4e00\u6b65\u524d\u8981\u5bf9\u5ba2\u6237\u7aef\u7684\u63e1\u624b\u8fdb\u884c\u9a8c\u8bc1\uff1b<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u9879\uff0c\u5176\u9ed8\u8ba4\u503c\u4e3a\u771f\u3002<\/p>\n<p>\u5982\u679c\u8fd9\u4e2a\u503c\u4e3a\u771f \u4e14 \u63e1\u624b\u5931\u8d25\uff0c\u670d\u52a1\u5668\u5c31\u653e\u5f03\u8fd9\u4e2a\u8fde\u63a5\u3002<\/p>\n<p>\u5982\u679c\u8fd9\u4e2a\u503c\u4e3a\u5047\uff0c\u5219\u4e0d\u4f1a\u8fdb\u884c\u5f3a\u5236\u7684\u63e1\u624b\u9a8c\u8bc1\uff0c\u6240\u6709\u7684\u8fde\u63a5\u90fd\u4f1a\u88ab\u63a5\u53d7\uff1b<\/p>\n<p>keyframeSeek \u00a0 boolean \u00a0\u00a0 no This instructs the streamer to seek only on<\/p>\n<p>key frames. In case of live streaming, this is discarded.<\/p>\n<p>\u8fd9\u4e2a\u5c5e\u6027\u6307\u5b9a\u4e86\u6d41\u751f\u6210\u5668\u53ea\u5728\u5173\u952e\u5e27\u641c\u7d22\uff0c<\/p>\n<p>\u5982\u679c\u662f\u76f4\u64ad\u6d41\uff0c\u5219\u5ffd\u7565\u8fd9\u4e2a\u503c<\/p>\n<p>seekGranularity \u00a0\u00a0 double no The seek resolution\/granularity value in<\/p>\n<p>seconds. Values are between 0.1 and 600.<\/p>\n<p>For example, if granularity is 10 seconds, and a seek to t=2:34 is<\/p>\n<p>desired, the seek<\/p>\n<p>will actually go to t=2:30.<\/p>\n<p>60seconds is recommended for full length movies and 1 second for video<\/p>\n<p>clips.<\/p>\n<p>\u641c\u7d22\u7684\u7cbe\u7ec6\u5ea6\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d, \u503c\u57df\u5b9a\u4e49\u5728 0.1 ~ 600;<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>\u5982\u679c\u7c92\u5ea6\u5b9a\u4e49\u4e3a10\u79d2\uff0c\u5e76\u671f\u671b\u5b9a\u4f4d\u5230 t= 2:34;<\/p>\n<p>\u5219\u5b9e\u9645\u4e0a\u662f\u4f1a\u5b9a\u4f4d\u5230 t= 2:30.<\/p>\n<p>60\u79d2\u88ab\u8ba4\u5b9a\u4e3a\u5b8c\u6574\u7684\u7535\u5f71\u957f\u5ea6\uff0c1\u79d2\u4e3a\u7535\u5f71\u7247\u65ad\uff1b<\/p>\n<p>clientSideBuffer \u00a0 double no The amount of client side buffer that will<\/p>\n<p>be maintained for each connection.<\/p>\n<p>Values are between 5 and30 seconds.<\/p>\n<p>\u6bcf\u4e2a\u8fde\u63a5\u5728\u5ba2\u6237\u7aef\u7684\u7f13\u51b2\u79d2\u6570\uff0c\u503c\u5b9a\u4e49\u57285 ~ 30 \u79d2\uff1b<\/p>\n<p>generateMetaFiles boolean \u00a0\u00a0 no This will generate seek\/meta files on<\/p>\n<p>application startup.<\/p>\n<p>\u5728\u5e94\u7528\u542f\u52a8\u524d\u751f\u6210 seek\/meta\u6587\u4ef6<\/p>\n<p>renameBadFiles boolean \u00a0\u00a0 no If this flag is true and the media file<\/p>\n<p>can&#8217;t be parsed, the media file will be renamed to *.bad.<\/p>\n<p>Otherwise it will be left alone.<\/p>\n<p>\u5982\u679c\u8fd9\u4e0a\u503c\u4e3a\u771f\u4e14\u5a92\u4f53\u6587\u4ef6\u662f\u4e0d\u80fd\u88ab\u89e3\u6790\u7684\uff0c\u5219\u5a92\u4f53\u6587\u4ef6\u88ab\u91cd\u547d\u540d\u4e3a *.bad\uff0c<\/p>\n<p>\u5426\u5219\u8fd9\u6837\u7684\u6587\u4ef6\u5c06\u4e0d\u505a\u5904\u7406<\/p>\n<p>aliases \u00a0\u00a0 object no The application will also be known by this name.<\/p>\n<p>\u5e94\u7528\u7684\u522b\u540d<\/p>\n<p>acceptors object no Acceptors hold the service that will be hosted to<\/p>\n<p>the server. An application can have its own acceptor,<\/p>\n<p>but this is not entirely required, and can be optional.<\/p>\n<p>\u63a5\u53d7\u5668\u4fdd\u6301\u8fd9\u4e2a\u670d\u52a1\u5e76\u8ba9\u670d\u52a1\u5668\u6258\u7ba1\uff1b<\/p>\n<p>\u5e94\u7528\u53ef\u4ee5\u6709\u5b83\u81ea\u5df1\u7684\u63a5\u53d7\u5668\uff0c\u4f46\u8fd9\u4e2a\u662f\u53ef\u9009\u7684\uff1b<\/p>\n<p>externalStreams \u00a0\u00a0 object no<\/p>\n<p>authentication object no<\/p>\n<p>mediaFolder \u00a0\u00a0 string yes \u00a0\u00a0\u00a0 When define mediaStorage this field is<\/p>\n<p>mandatory as it points out physical location of media files.<\/p>\n<p>\u5f53\u5b9a\u4e49\u4e86 mediaStorage\u65f6\uff0c\u8fd9\u4e2a\u57df\u7528\u6765\u6307\u5b9a\u5a92\u4f53\u6587\u4ef6\u7684\u7269\u7406\u4f4d\u7f6e\uff1b<\/p>\n<p>metaFolder string no It holds the location where .seek\/.meta files<\/p>\n<p>created from files inside mediaFolder are stored.<\/p>\n<p>\u6307\u5b9a\u7528\u6765\u5b58\u653e .seek\/.meta\u6587\u4ef6\u7684\u4f4d\u7f6e\uff1b<\/p>\n<p>statsFolder \u00a0\u00a0 string no Location for stats files.<\/p>\n<p>\u670d\u72b6\u6001\u6587\u4ef6\u7684\u4f4d\u7f6e<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Acceptor Structure<\/strong><\/p>\n<p>key type\u00a0\u00a0\u00a0 mandatory\u00a0 description<\/p>\n<p>ip string yes \u00a0\u00a0\u00a0 The IP where the service is located. 0.0.0.0 means all<\/p>\n<p>interfaces and all IPs.<\/p>\n<p>\u670d\u52a1\u6240\u5728\u7684IP, 0.0.0.0\u8868\u793a\u6240\u6709\u63a5\u53e3\u548c\u6240\u6709IP;<\/p>\n<p>port \u00a0\u00a0 string yes \u00a0\u00a0\u00a0 Port number that the service will listen to.<\/p>\n<p>\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7<\/p>\n<p>protocol \u00a0 string yes \u00a0\u00a0\u00a0 The protocol stack handled by<\/p>\n<p>the ip:port combination.<\/p>\n<p>\u5bf9\u5e94 ip:port\u7684\u670d\u52a1\u7684\u534f\u8bae<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.cnblogs.com\/zjoch\/p\/3277198.h &hellip; <a href=\"https:\/\/blog.zhenglei.net\/?p=255764\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,12,1],"tags":[357],"class_list":["post-255764","post","type-post","status-publish","format-standard","hentry","category-flash","category-streaming","category-uncategorized","tag-crtmpserver"],"_links":{"self":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/255764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=255764"}],"version-history":[{"count":3,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/255764\/revisions"}],"predecessor-version":[{"id":255767,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/255764\/revisions\/255767"}],"wp:attachment":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}