# rpmt **Repository Path**: xiaobo0903/rpmt ## Basic Information - **Project Name**: rpmt - **Description**: 基于TS切片的音频直播网关 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-08-10 - **Last Updated**: 2026-01-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 基于TS切片的音频直播网关的设置 - 1、添加nginx对于lua的支持(openresty安装) - 2、在直播的切片服务器上配置对于音频网关的支持 ###### http 头中增加支持lua(添加如下两行): ###### lua_package_path "/usr/local/lualib/?.lua;;"; ###### lua_package_cpath "/usr/local/lualib/?.so;;"; - 3、在http中增加下面的内容项: ###### #对于原始的m3u8访问链接,增加audio路径,来区分是否是音频内容;该部分只是区分音频部分内容后, ###### #还访问原始的m3u8的内容,并把m3u8中的ts后缀的切片替换成aac的后缀; location /audio { default_type application/vnd.apple.mpegurl; content_by_lua ' local base_m3u8_url = ngx.var.uri:gsub("audio", "hls") local res = ngx.location.capture(base_m3u8_url) local new_body = res.body:gsub(".ts", ".aac") ngx.print(new_body) ngx.exit(ngx.HTTP_OK) '; } location ~ .*\.aac$ { #content_by_lua 'ngx.say("hello world")'; default_type audio/mp2t; content_by_lua_file lua/onlyaudio.lua; #content_by_lua ' #local base_m3u8_url = ngx.var.uri:gsub("audio", "hls") #local base_ts_url = base_m3u8_url:gsub("aac", "ts") #local res = ngx.location.capture(base_ts_url) #ngx.print(res.body) #ngx.exit(ngx.HTTP_OK) ## #'; } - 4、在nginx的主目录下建立lua子目录,并把onlyaudio.lua拷到该目录下 - 5、编译rtmp.go成动态链接库 librpmt.solibrpmt.so (已经提供生成的动态库,可以直接通考贝使用) ###### go build -o librpmt.so -buildmode=c-shared rpmt.go - 6、把librpmt.so拷贝到/lib/x86_64-linux-gnu/(可使用 ldd ./sbin/nginx查看动态链接库的路径) - 7、访问方式: ###### 原始访问链接 http://10.10.10.8/hls/123456.m3u8 ###### 音频访问链接 http://10.10.10.8/audio/123456.m3u8 ###### (具体的路径可根据第3项的配置)