Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[接口] /api/ctrl/start_pull 如何使用? #112

Closed
opo2000tw opened this issue Nov 29, 2021 · 9 comments
Closed

[接口] /api/ctrl/start_pull 如何使用? #112

opo2000tw opened this issue Nov 29, 2021 · 9 comments

Comments

@opo2000tw
Copy link

opo2000tw commented Nov 29, 2021

頻道地址:佛教2,rtmp://hk2.hwadzan.com/liveedge/amtb

測試播放:ffplay rtmp://hk2.hwadzan.com/liveedge/amtb

  1. 指令:
    curl -H "Content-Type:application/json" -X POST -d '{"protocol": "rtmp", "addr":"hk2.hwadzan.com", "app_name":"liveedge", "stream_name":"amtb"}' http://127.0.0.1:8083/api/ctrl/start_pull

錯誤訊息:
lalserver.go

2021/11/26 18:54:06.805791 DEBUG group size=0 - server_manager.go:244
2021/11/26 18:54:36.801188 DEBUG group size=0 - server_manager.go:244
2021/11/26 18:54:37.140985  INFO http api start pull. req info={Protocol:rtmp Addr:hk2.hwadzan.com AppName:liveedge StreamName:amtb UrlParam:} - http_api.go:115
2021/11/26 18:54:37.141042  WARN group not exist, ignore start pull. streamName=amtb - server_manager.go:327
2021/11/26 18:55:06.801238 DEBUG group size=0 - server_manager.go:244
  1. 靜態設定:
    lalserver.conf.json
    "relay_pull": {
    "enable": false,
    "addr": ""
    },

可以給個範例或是說明以上兩個怎麼使用嗎?

不太懂這邊的流程和指令應該怎麼下。謝謝

我的理解是 1. 指令要拉取遠端流,卻去判斷 group 是否存在? 這不是很奇怪嗎

@opo2000tw
Copy link
Author

opo2000tw commented Nov 29, 2021

做了以下嘗試
0. 關閉自動清空 group

  1. 先給他 group sub 對象,輸入:ffplay rtmp://127.0.0.1/liveedge/amtb,返回以下 json
{
    "error_code": 0,
    "desp": "succ",
    "data": {
        "groups": [
            {
                "stream_name": "amtb",
                "audio_codec": "",
                "video_codec": "",
                "video_width": 0,
                "video_height": 0,
                "pub": {
                    "protocol": "",
                    "session_id": "",
                    "remote_addr": "",
                    "start_time": "",
                    "read_bytes_sum": 0,
                    "wrote_bytes_sum": 0,
                    "bitrate": 0,
                    "read_bitrate": 0,
                    "write_bitrate": 0
                },
                "subs": [
                    {
                        "protocol": "RTMP",
                        "session_id": "RTMPPUBSUB2",
                        "remote_addr": "127.0.0.1:61227",
                        "start_time": "2021-11-29 14:53:24.759",
                        "read_bytes_sum": 3449,
                        "wrote_bytes_sum": 3527,
                        "bitrate": 0,
                        "read_bitrate": 0,
                        "write_bitrate": 0
                    }
                ],
                "pull": {
                    "protocol": "",
                    "session_id": "",
                    "remote_addr": "",
                    "start_time": "",
                    "read_bytes_sum": 0,
                    "wrote_bytes_sum": 0,
                    "bitrate": 0,
                    "read_bitrate": 0,
                    "write_bitrate": 0
                }
            }
        ]
    }
}
  1. 輸入指令
    curl -H "Content-Type:application/json" -X POST -d '{"protocol": "rtmp", "addr":"hk2.hwadzan.com:1935", "app_name":"liveedge", "stream_name":"amtb"}' http://127.0.0.1:8083/api/ctrl/start_pull

  2. 錯誤訊息

2021/11/29 14:57:17.530388  INFO http api start pull. req info={Protocol:rtmp Addr:hk2.hwadzan.com:1935 AppName:liveedge StreamName:amtb UrlParam:} - http_api.go:115
2021/11/29 14:57:17.530440  INFO [GROUP1] start relay pull. url=rtmp://hk2.hwadzan.com:1935/liveedge/amtb - group.go:1303
2021/11/29 14:57:17.530513  INFO [RTMPPULL3] lifecycle new rtmp ClientSession. session=0xc00011a400 - client_session.go:120
2021/11/29 14:57:17.530557 DEBUG [RTMPPULL3] Do. url=rtmp://hk2.hwadzan.com:1935/liveedge/amtb - client_session.go:126
2021/11/29 14:57:17.530640  INFO [RTMPPULL3] > tcp connect. - client_session.go:299
2021/11/29 14:57:17.563579 DEBUG [NAZACONN5] lifecycle new connection. net.Conn=0xc0000b6410, naza.Connection=0xc0000e29a0 - connection.go:192
2021/11/29 14:57:17.563649  INFO [RTMPPULL3] > W Handshake C0+C1. - client_session.go:317
2021/11/29 14:57:17.596959  INFO [RTMPPULL3] < R Handshake S0+S1. - client_session.go:325
2021/11/29 14:57:17.597040  INFO [RTMPPULL3] > W Handshake C2. - client_session.go:327
2021/11/29 14:57:17.597109  INFO [RTMPPULL3] < R Handshake S2. - client_session.go:335
2021/11/29 14:57:17.597163  INFO [RTMPPULL3] > W SetChunkSize 4096. - client_session.go:248
2021/11/29 14:57:17.597220  INFO [RTMPPULL3] > W connect('liveedge'). tcUrl=rtmp://hk2.hwadzan.com:1935/liveedge - client_session.go:254
2021/11/29 14:57:17.631139  INFO [RTMPPULL3] < R Window Acknowledgement Size: 2500000 - client_session.go:518
2021/11/29 14:57:17.631194  WARN [RTMPPULL3] < R Set Peer Bandwidth. ignore. - client_session.go:521
2021/11/29 14:57:17.631221  WARN [RTMPPULL3] read user control message, ignore. buf=00000000  00 00 00 00 00 00                                 |......|
 - client_session.go:362
2021/11/29 14:57:17.631242  INFO [RTMPPULL3] < R Set Chunk Size 4096. - client_session.go:524
2021/11/29 14:57:17.631271  WARN amf ReadArray without suffix Amf0TypeMarkerObjectEndBytes. - amf0.go:381
2021/11/29 14:57:17.631308  INFO [RTMPPULL3] < R _result("NetConnection.Connect.Success"). - client_session.go:474
2021/11/29 14:57:17.631325  INFO [RTMPPULL3] > W createStream(). - client_session.go:475
2021/11/29 14:57:17.664283  INFO [RTMPPULL3] < R _result(). - client_session.go:491
2021/11/29 14:57:17.664328  INFO [RTMPPULL3] > W play('amtb'). - client_session.go:494
2021/11/29 14:57:22.535206  INFO [RTMPPULL3] lifecycle dispose rtmp ClientSession. err=<nil> - client_session.go:550
2021/11/29 14:57:22.535326 DEBUG [NAZACONN5] Close. - connection.go:376
2021/11/29 14:57:22.535354 DEBUG [NAZACONN5] close once. err=<nil> - connection.go:504
2021/11/29 14:57:22.535446 ERROR [RTMPPULL3] relay pull fail. err=context deadline exceeded - group.go:1313
2021/11/29 14:57:22.535490 DEBUG [GROUP1] [RTMPPULL3] del rtmp PullSession from group. - group.go:680

@opo2000tw
Copy link
Author

opo2000tw commented Nov 29, 2021

已用過以下測試源

ffplay rtmp://127.0.0.1:1935/liveedge/amtb

curl -H "Content-Type:application/json" -X POST -d '{"protocol": "rtmp", "addr":"61.93.225.146:1935", "app_name":"liveedge", "stream_name":"amtb"}' http://127.0.0.1:8083/api/ctrl/start_pull

2021/11/29 15:26:53.992769 ERROR [RTMPPULL1] relay pull fail. err=context deadline exceeded - group.go:1313
2021/11/29 15:26:53.992847 DEBUG [GROUP1] [RTMPPULL1] del rtmp PullSession from group. - group.go:680
ffplay rtmp://127.0.0.1:1935/dmb/ydlive_20140419_1

curl -H "Content-Type:application/json" -X POST -d '{"protocol": "rtmp", "addr":"1.255.48.202:1935", "app_name":"dmb", "stream_name":"ydlive_20140419_1"}' http://127.0.0.1:8083/api/ctrl/start_pull

進入 panic  lalserver 主程式死亡
ffplay rtmp://127.0.0.1:1935/cbs-live/cbs-live.stream

curl -H "Content-Type:application/json" -X POST -d '{"protocol": "rtmp", "addr":"101.79.245.175:1935", "app_name":"cbs-live", "stream_name":"cbs-live.stream", "url_param":""}' http://127.0.0.1:8083/api/ctrl/start_pull

進入 panic lalserver 程式死亡

詳見以下 2. --> 從程式開始到進入 panic lalserver 程式死亡

GOROOT=/usr/local/opt/go/libexec #gosetup
GOPATH=/Users/blakewu/go #gosetup
/usr/local/opt/go/libexec/bin/go build -o /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go -gcflags all=-N -l /Volumes/Case/go/fork/lal/app/lalserver/main.go #gosetup
/Applications/GoLand.app/Contents/plugins/go/lib/dlv/mac/dlv --listen=127.0.0.1:56438 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go --
API server listening at: 127.0.0.1:56438
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1200.0.44
 for x86_64.
Got a connection, launched process /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go (pid = 86860).
2021/11/29 15:59:39.960082  WARN config file did not specify in the command line, try to load it in the usual path. - main.go:52
2021/11/29 15:59:39.960619  WARN lalserver.conf.json not exist. - main.go:68
2021/11/29 15:59:39.960636  WARN ./conf/lalserver.conf.json exist. using it as config file. - main.go:65
2021/11/29 15:59:39.963486  INFO initial log succ. - config.go:210
2021/11/29 15:59:39.963754  INFO 
    __    ___    __
   / /   /   |  / /
  / /   / /| | / /
 / /___/ ___ |/ /___
/_____/_/  |_/_____/
 - config.go:213
2021/11/29 15:59:39.964135  INFO load conf file succ. filename=./conf/lalserver.conf.json, raw content={ "# doc of config": "https://pengrl.com/lal/#/ConfigBrief", "conf_version": "v0.2.4", "rtmp": { "enable": true, "addr": ":1935", "gop_num": 0, "merge_write_size": 0, "add_dummy_audio_enable": false, "add_dummy_audio_wait_audio_ms": 150 }, "default_http": { "http_listen_addr": ":8080", "https_listen_addr": ":4433", "https_cert_file": "./conf/cert.pem", "https_key_file": "./conf/key.pem" }, "httpflv": { "enable": false, "enable_https": false, "url_pattern": "/", "gop_num": 0 }, "hls": { "enable": false, "enable_https": false, "url_pattern": "/hls/", "out_path": "./lal_record/hls/", "fragment_duration_ms": 3000, "fragment_num": 6, "cleanup_mode": 1, "use_memory_as_disk_flag": false }, "httpts": { "enable": false, "enable_https":false, "url_pattern": "/" }, "rtsp": { "enable": true, "addr": ":5544" }, "record": { "enable_flv": false, "flv_out_path": "./lal_record/flv/", "enable_mpegts": false, "mpegts_out_path": "./lal_record/mpegts" }, "relay_push": { "enable": false, "addr_list":[ ] }, "relay_pull": { "enable": false, "addr": "" }, "http_api": { "enable": true, "addr": ":8083" }, "server_id": "1", "http_notify": { "enable": true, "update_interval_sec": 5, "on_server_start": "http://127.0.0.1:10101/on_server_start", "on_update": "http://127.0.0.1:10101/on_update", "on_pub_start": "http://127.0.0.1:10101/on_pub_start", "on_pub_stop": "http://127.0.0.1:10101/on_pub_stop", "on_sub_start": "http://127.0.0.1:10101/on_sub_start", "on_sub_stop": "http://127.0.0.1:10101/on_sub_stop", "on_rtmp_connect": "http://127.0.0.1:10101/on_rtmp_connect" }, "pprof": { "enable": true, "addr": ":8084" }, "log": { "level": 1, "filename": "./logs/lalserver.log", "is_to_stdout": true, "is_rotate_daily": true, "short_file_flag": true, "timestamp_flag": true, "timestamp_with_ms_flag": true, "level_flag": true, "assert_behavior": 1 } }  parsed=&{ConfVersion:v0.2.4 RtmpConfig:{Enable:true Addr::1935 GopNum:0 MergeWriteSize:0 AddDummyAudioEnable:false AddDummyAudioWaitAudioMs:150} DefaultHttpConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem}} HttpflvConfig:{CommonHttpServerConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem} Enable:false EnableHttps:false UrlPattern:/} GopNum:0} HlsConfig:{CommonHttpServerConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem} Enable:false EnableHttps:false UrlPattern:/hls/} UseMemoryAsDiskFlag:false MuxerConfig:{OutPath:./lal_record/hls/ FragmentDurationMs:3000 FragmentNum:6 CleanupMode:1}} HttptsConfig:{CommonHttpServerConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem} Enable:false EnableHttps:false UrlPattern:/}} RtspConfig:{Enable:true Addr::5544} RecordConfig:{EnableFlv:false FlvOutPath:./lal_record/flv/ EnableMpegts:false MpegtsOutPath:./lal_record/mpegts} RelayPushConfig:{Enable:false AddrList:[]} RelayPullConfig:{Enable:false Addr:} HttpApiConfig:{Enable:true Addr::8083} ServerId:1 HttpNotifyConfig:{Enable:true UpdateIntervalSec:5 OnServerStart:http://127.0.0.1:10101/on_server_start OnUpdate:http://127.0.0.1:10101/on_update OnPubStart:http://127.0.0.1:10101/on_pub_start OnPubStop:http://127.0.0.1:10101/on_pub_stop OnSubStart:http://127.0.0.1:10101/on_sub_start OnSubStop:http://127.0.0.1:10101/on_sub_stop OnRtmpConnect:http://127.0.0.1:10101/on_rtmp_connect} PprofConfig:{Enable:true Addr::8084} LogConfig:{Level:1 Filename:./logs/lalserver.log IsToStdout:true IsRotateDaily:true ShortFileFlag:true TimestampFlag:true TimestampWithMsFlag:true LevelFlag:true AssertBehavior:1}} - config.go:296
2021/11/29 15:59:39.964484  INFO wd: /Volumes/Case/go/fork/lal - server_manager.go:67
2021/11/29 15:59:39.964568  INFO args: /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go - server_manager.go:68
2021/11/29 15:59:39.964584  INFO bininfo: GitTag=unknown. GitCommitLog=unknown. GitStatus=unknown. BuildTime=unknown. GoVersion=unknown. runtime=darwin/amd64. - server_manager.go:69
2021/11/29 15:59:39.964599  INFO version: lal v0.26.0 (github.com/q191201771/lal) - server_manager.go:70
2021/11/29 15:59:39.964611  INFO github: https://github.com/q191201771/lal - server_manager.go:71
2021/11/29 15:59:39.964623  INFO doc: https://pengrl.com/lal - server_manager.go:72
2021/11/29 15:59:39.964635  INFO serverStartTime: 2021-11-29 15:59:39.96 - server_manager.go:73
2021/11/29 15:59:39.965671  INFO start web pprof listen. addr=:8084 - server_manager.go:755
2021/11/29 15:59:39.967666  INFO start rtmp server listen. addr=:1935 - server.go:42
2021/11/29 15:59:39.968191  INFO start rtsp server listen. addr=:5544 - server.go:64
2021/11/29 15:59:39.968639  INFO start httpapi server listen. addr=:8083 - http_api.go:40
2021/11/29 15:59:47.637359  INFO accept a rtmp connection. remoteAddr=127.0.0.1:56452 - server.go:66
2021/11/29 15:59:47.637760 DEBUG [NAZACONN1] lifecycle new connection. net.Conn=0xc000140358, naza.Connection=0xc00016a370 - connection.go:192
2021/11/29 15:59:47.638179  INFO [RTMPPUBSUB1] lifecycle new rtmp ServerSession. session=0xc0001769a0, remote addr=127.0.0.1:56452 - server_session.go:97
2021/11/29 15:59:47.639637 DEBUG handshake complex mode. - handshake.go:249
2021/11/29 15:59:47.640024  INFO [RTMPPUBSUB1] < R Handshake C0+C1. - server_session.go:192
2021/11/29 15:59:47.640133  INFO [RTMPPUBSUB1] > W Handshake S0+S1+S2. - server_session.go:194
2021/11/29 15:59:47.640730  INFO [RTMPPUBSUB1] < R Handshake C2. - server_session.go:202
2021/11/29 15:59:47.641268  INFO [RTMPPUBSUB1] < R connect('dmb'). tcUrl=rtmp://127.0.0.1:1935/dmb - server_session.go:349
2021/11/29 15:59:47.641395  INFO [RTMPPUBSUB1] > W Window Acknowledgement Size 5000000. - server_session.go:353
2021/11/29 15:59:47.641602  INFO [RTMPPUBSUB1] > W Set Peer Bandwidth. - server_session.go:358
2021/11/29 15:59:47.641641  INFO [RTMPPUBSUB1] > W SetChunkSize 4096. - server_session.go:363
2021/11/29 15:59:47.641708  INFO [RTMPPUBSUB1] > W _result('NetConnection.Connect.Success'). - server_session.go:368
2021/11/29 15:59:47.642908  WARN [RTMPPUBSUB1] read unknown message. typeid=5, header={Csid:2 MsgLen:4 MsgTypeId:5 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=0, wpos=4, hex=00000000  00 4c 4b 40                                       |.LK@|
 - server_session.go:229
2021/11/29 15:59:47.642969  INFO [RTMPPUBSUB1] < R createStream(). - server_session.go:380
2021/11/29 15:59:47.643002  INFO [RTMPPUBSUB1] > W _result(). - server_session.go:381
2021/11/29 15:59:47.643374 DEBUG [RTMPPUBSUB1] read command message, ignore it. cmd=getStreamLength, header={Csid:8 MsgLen:48 MsgTypeId:20 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=27, wpos=48, hex=00000000  05 02 00 11 79 64 6c 69  76 65 5f 32 30 31 34 30  |....ydlive_20140|
00000010  34 31 39 5f 31                                    |419_1|
 - server_session.go:323
2021/11/29 15:59:47.643425  INFO [RTMPPUBSUB1] < R play('ydlive_20140419_1'). - server_session.go:441
2021/11/29 15:59:47.643508  INFO [RTMPPUBSUB1] > W onStatus('NetStream.Play.Start'). - server_session.go:451
2021/11/29 15:59:47.643617 DEBUG CHEFERASEME [RTMPPUBSUB1] OnNewRtmpSubSession. rtmp://127.0.0.1:1935/dmb/ydlive_20140419_1, dmb, ydlive_20140419_1,  - server_manager.go:432
2021/11/29 15:59:47.644081  INFO [GROUP1] lifecycle new group. group=0xc0001a6a00, appName=dmb, streamName=ydlive_20140419_1 - group.go:152
2021/11/29 15:59:47.644188 DEBUG [GROUP1] [RTMPPUBSUB1] add SubSession into group. - group.go:406
2021/11/29 15:59:47.644368  WARN [RTMPPUBSUB1] read unknown message. typeid=4, header={Csid:2 MsgLen:10 MsgTypeId:4 MsgStreamId:0 TimestampAbs:1}, b=len(core)=4096, rpos=0, wpos=10, hex=00000000  00 03 00 00 00 01 00 00  0b b8                    |..........|
 - server_session.go:229
2021/11/29 15:59:49.717938  INFO http api start pull. req info={Protocol:rtmp Addr:1.255.48.202:1935 AppName:dmb StreamName:ydlive_20140419_1 UrlParam:} - http_api.go:115
2021/11/29 15:59:49.718060  INFO [GROUP1] start relay pull. url=rtmp://1.255.48.202:1935/dmb/ydlive_20140419_1 - group.go:1303
2021/11/29 15:59:49.718346  INFO [RTMPPULL1] lifecycle new rtmp ClientSession. session=0xc000324000 - client_session.go:120
2021/11/29 15:59:49.718447 DEBUG [RTMPPULL1] Do. url=rtmp://1.255.48.202:1935/dmb/ydlive_20140419_1 - client_session.go:126
2021/11/29 15:59:49.718609  INFO [RTMPPULL1] > tcp connect. - client_session.go:299
2021/11/29 15:59:49.780839 DEBUG [NAZACONN2] lifecycle new connection. net.Conn=0xc000010068, naza.Connection=0xc00031c0b0 - connection.go:192
2021/11/29 15:59:49.780901  INFO [RTMPPULL1] > W Handshake C0+C1. - client_session.go:317
2021/11/29 15:59:49.843796  INFO [RTMPPULL1] < R Handshake S0+S1. - client_session.go:325
2021/11/29 15:59:49.843855  INFO [RTMPPULL1] > W Handshake C2. - client_session.go:327
2021/11/29 15:59:49.843900  INFO [RTMPPULL1] < R Handshake S2. - client_session.go:335
2021/11/29 15:59:49.843929  INFO [RTMPPULL1] > W SetChunkSize 4096. - client_session.go:248
2021/11/29 15:59:49.843982  INFO [RTMPPULL1] > W connect('dmb'). tcUrl=rtmp://1.255.48.202:1935/dmb - client_session.go:254
2021/11/29 15:59:49.906884  INFO [RTMPPULL1] < R Window Acknowledgement Size: 2500000 - client_session.go:518
2021/11/29 15:59:49.906968  WARN [RTMPPULL1] < R Set Peer Bandwidth. ignore. - client_session.go:521
2021/11/29 15:59:49.907036  WARN [RTMPPULL1] read user control message, ignore. buf=00000000  00 00 00 00 00 00                                 |......|
 - client_session.go:362
2021/11/29 15:59:49.907063  INFO [RTMPPULL1] < R Set Chunk Size 4096. - client_session.go:524
2021/11/29 15:59:49.907183  WARN amf ReadArray without suffix Amf0TypeMarkerObjectEndBytes. - amf0.go:381
2021/11/29 15:59:49.907212  INFO [RTMPPULL1] < R _result("NetConnection.Connect.Success"). - client_session.go:474
2021/11/29 15:59:49.907232  INFO [RTMPPULL1] > W createStream(). - client_session.go:475
2021/11/29 15:59:49.968505  INFO [RTMPPULL1] < R _result(). - client_session.go:491
2021/11/29 15:59:49.968615  INFO [RTMPPULL1] > W play('ydlive_20140419_1'). - client_session.go:494
2021/11/29 15:59:50.580619  WARN [RTMPPULL1] read on status message but code field unknown. code=NetStream.Play.PublishNotify - client_session.go:450
2021/11/29 15:59:50.580720  WARN [RTMPPULL1] read user control message, ignore. buf=00000000  00 00 00 00 00 01                                 |......|
 - client_session.go:362
2021/11/29 15:59:50.580758  WARN [RTMPPULL1] read on status message but code field unknown. code=NetStream.Play.Reset - client_session.go:450
2021/11/29 15:59:50.580794  INFO [RTMPPULL1] < R onStatus('NetStream.Play.Start'). - client_session.go:447
2021/11/29 15:59:50.581062 DEBUG [RTMPPULL1] < R |RtmpSampleAccess, ignore. - client_session.go:390
2021/11/29 15:59:50.581216 DEBUG [GROUP1] [RTMPPULL1] add PullSession into group. - group.go:367
2021/11/29 15:59:50.581458 DEBUG [GROUP1] cache rtmp metadata. size:56 - gop_cache.go:90
2021/11/29 16:01:15.336904 DEBUG [NAZACONN2] close once. err=read tcp 192.168.50.234:56454->1.255.48.202:1935: i/o timeout - connection.go:504
2021/11/29 16:01:15.337050 ERROR http notify post error. err=Post "http://127.0.0.1:10101/on_update": context deadline exceeded (Client.Timeout exceeded while awaiting headers) - http_notify.go:141
2021/11/29 16:01:15.337250  INFO [RTMPPULL1] lifecycle dispose rtmp ClientSession. err=read tcp 192.168.50.234:56454->1.255.48.202:1935: i/o timeout - client_session.go:550
2021/11/29 16:01:15.337340  INFO [RTMPPULL1] relay pull done. err=read tcp 192.168.50.234:56454->1.255.48.202:1935: i/o timeout - group.go:1320
2021/11/29 16:01:15.337414 DEBUG [GROUP1] [RTMPPULL1] del rtmp PullSession from group. - group.go:680
2021/11/29 16:01:15.337314 DEBUG [NAZACONN2] Close. - connection.go:376
2021/11/29 16:01:15.969995 DEBUG group size=1 - server_manager.go:244
2021/11/29 16:01:15.970161 DEBUG {"stream_name":"ydlive_20140419_1","audio_codec":"","video_codec":"","video_width":0,"video_height":0,"pub":{"protocol":"","session_id":"","remote_addr":"","start_time":"","read_bytes_sum":0,"wrote_bytes_sum":0,"bitrate":0,"read_bitrate":0,"write_bitrate":0},"subs":[{"protocol":"RTMP","session_id":"RTMPPUBSUB1","remote_addr":"127.0.0.1:56452","start_time":"2021-11-29 15:59:47.638","read_bytes_sum":3465,"wrote_bytes_sum":3583,"bitrate":0,"read_bitrate":0,"write_bitrate":0}],"pull":{"protocol":"RTMP","session_id":"RTMPPULL1","remote_addr":"1.255.48.202:1935","start_time":"2021-11-29 15:59:49.718","read_bytes_sum":4368,"wrote_bytes_sum":3312,"bitrate":0,"read_bitrate":0,"write_bitrate":0}} - server_manager.go:247
2021/11/29 16:01:26.038193 DEBUG [NAZACONN1] close once. err=EOF - connection.go:504
2021/11/29 16:01:26.038484  INFO [RTMPPUBSUB1] rtmp loop done. err=EOF - server.go:69
2021/11/29 16:01:26.038535 DEBUG CHEFERASEME [RTMPPUBSUB1] OnDelRtmpSubSession. rtmp://127.0.0.1:1935/dmb/ydlive_20140419_1, dmb, ydlive_20140419_1,  - server_manager.go:455
2021/11/29 16:01:26.038637 DEBUG [GROUP1] [RTMPPUBSUB1] del rtmp SubSession from group. - group.go:688
2021/11/29 16:01:27.968529  INFO accept a rtmp connection. remoteAddr=127.0.0.1:56498 - server.go:66
2021/11/29 16:01:27.968614 DEBUG [NAZACONN3] lifecycle new connection. net.Conn=0xc000010090, naza.Connection=0xc00031c210 - connection.go:192
2021/11/29 16:01:27.968690  INFO [RTMPPUBSUB2] lifecycle new rtmp ServerSession. session=0xc000314c60, remote addr=127.0.0.1:56498 - server_session.go:97
2021/11/29 16:01:27.968794 DEBUG handshake complex mode. - handshake.go:249
2021/11/29 16:01:27.968858  INFO [RTMPPUBSUB2] < R Handshake C0+C1. - server_session.go:192
2021/11/29 16:01:27.968888  INFO [RTMPPUBSUB2] > W Handshake S0+S1+S2. - server_session.go:194
2021/11/29 16:01:27.969160  INFO [RTMPPUBSUB2] < R Handshake C2. - server_session.go:202
2021/11/29 16:01:27.969279  INFO [RTMPPUBSUB2] < R connect('dmb'). tcUrl=rtmp://127.0.0.1:1935/dmb - server_session.go:349
2021/11/29 16:01:27.969327  INFO [RTMPPUBSUB2] > W Window Acknowledgement Size 5000000. - server_session.go:353
2021/11/29 16:01:27.969413  INFO [RTMPPUBSUB2] > W Set Peer Bandwidth. - server_session.go:358
2021/11/29 16:01:27.970014  INFO [RTMPPUBSUB2] > W SetChunkSize 4096. - server_session.go:363
2021/11/29 16:01:27.970186  INFO [RTMPPUBSUB2] > W _result('NetConnection.Connect.Success'). - server_session.go:368
2021/11/29 16:01:27.970524  WARN [RTMPPUBSUB2] read unknown message. typeid=5, header={Csid:2 MsgLen:4 MsgTypeId:5 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=0, wpos=4, hex=00000000  00 4c 4b 40                                       |.LK@|
 - server_session.go:229
2021/11/29 16:01:27.970632  INFO [RTMPPUBSUB2] < R createStream(). - server_session.go:380
2021/11/29 16:01:27.970686  INFO [RTMPPUBSUB2] > W _result(). - server_session.go:381
2021/11/29 16:01:27.970935 DEBUG [RTMPPUBSUB2] read command message, ignore it. cmd=getStreamLength, header={Csid:8 MsgLen:48 MsgTypeId:20 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=27, wpos=48, hex=00000000  05 02 00 11 79 64 6c 69  76 65 5f 32 30 31 34 30  |....ydlive_20140|
00000010  34 31 39 5f 31                                    |419_1|
 - server_session.go:323
2021/11/29 16:01:27.970987  INFO [RTMPPUBSUB2] < R play('ydlive_20140419_1'). - server_session.go:441
2021/11/29 16:01:27.971036  INFO [RTMPPUBSUB2] > W onStatus('NetStream.Play.Start'). - server_session.go:451
2021/11/29 16:01:27.971156 DEBUG CHEFERASEME [RTMPPUBSUB2] OnNewRtmpSubSession. rtmp://127.0.0.1:1935/dmb/ydlive_20140419_1, dmb, ydlive_20140419_1,  - server_manager.go:432
2021/11/29 16:01:27.971202 DEBUG [GROUP1] [RTMPPUBSUB2] add SubSession into group. - group.go:406
2021/11/29 16:01:27.971235  INFO [GROUP1] start relay pull. url=rtmp://1.255.48.202:1935/dmb/ydlive_20140419_1 - group.go:1303
2021/11/29 16:01:27.971303  WARN [RTMPPUBSUB2] read unknown message. typeid=4, header={Csid:2 MsgLen:10 MsgTypeId:4 MsgStreamId:0 TimestampAbs:1}, b=len(core)=4096, rpos=0, wpos=10, hex=00000000  00 03 00 00 00 01 00 00  0b b8                    |..........|
 - server_session.go:229
2021/11/29 16:01:27.971359  INFO [RTMPPULL2] lifecycle new rtmp ClientSession. session=0xc0003e6000 - client_session.go:120
2021/11/29 16:01:27.971401 DEBUG [RTMPPULL2] Do. url=rtmp://1.255.48.202:1935/dmb/ydlive_20140419_1 - client_session.go:126
2021/11/29 16:01:27.971472  INFO [RTMPPULL2] > tcp connect. - client_session.go:299
2021/11/29 16:01:28.042642 DEBUG [NAZACONN4] lifecycle new connection. net.Conn=0xc0004ae050, naza.Connection=0xc0004c0210 - connection.go:192
2021/11/29 16:01:28.042698  INFO [RTMPPULL2] > W Handshake C0+C1. - client_session.go:317
2021/11/29 16:01:28.113688  INFO [RTMPPULL2] < R Handshake S0+S1. - client_session.go:325
2021/11/29 16:01:28.113755  INFO [RTMPPULL2] > W Handshake C2. - client_session.go:327
2021/11/29 16:01:28.113854  INFO [RTMPPULL2] < R Handshake S2. - client_session.go:335
2021/11/29 16:01:28.113898  INFO [RTMPPULL2] > W SetChunkSize 4096. - client_session.go:248
2021/11/29 16:01:28.113986  INFO [RTMPPULL2] > W connect('dmb'). tcUrl=rtmp://1.255.48.202:1935/dmb - client_session.go:254
2021/11/29 16:01:28.185174  INFO [RTMPPULL2] < R Window Acknowledgement Size: 2500000 - client_session.go:518
2021/11/29 16:01:28.185240  WARN [RTMPPULL2] < R Set Peer Bandwidth. ignore. - client_session.go:521
2021/11/29 16:01:28.185273  WARN [RTMPPULL2] read user control message, ignore. buf=00000000  00 00 00 00 00 00                                 |......|
 - client_session.go:362
2021/11/29 16:01:28.185294  INFO [RTMPPULL2] < R Set Chunk Size 4096. - client_session.go:524
2021/11/29 16:01:28.185332  WARN amf ReadArray without suffix Amf0TypeMarkerObjectEndBytes. - amf0.go:381
2021/11/29 16:01:28.185358  INFO [RTMPPULL2] < R _result("NetConnection.Connect.Success"). - client_session.go:474
2021/11/29 16:01:28.185374  INFO [RTMPPULL2] > W createStream(). - client_session.go:475
2021/11/29 16:01:28.255378  INFO [RTMPPULL2] < R _result(). - client_session.go:491
2021/11/29 16:01:28.255479  INFO [RTMPPULL2] > W play('ydlive_20140419_1'). - client_session.go:494
2021/11/29 16:01:28.783652  WARN [RTMPPULL2] read on status message but code field unknown. code=NetStream.Play.PublishNotify - client_session.go:450
2021/11/29 16:01:28.783764  WARN [RTMPPULL2] read user control message, ignore. buf=00000000  00 00 00 00 00 01                                 |......|
 - client_session.go:362
2021/11/29 16:01:28.783803  WARN [RTMPPULL2] read on status message but code field unknown. code=NetStream.Play.Reset - client_session.go:450
2021/11/29 16:01:28.783843  INFO [RTMPPULL2] < R onStatus('NetStream.Play.Start'). - client_session.go:447
2021/11/29 16:01:38.000847 DEBUG [GROUP1] [RTMPPULL2] add PullSession into group. - group.go:367
2021/11/29 16:01:38.000846 DEBUG [RTMPPULL2] < R |RtmpSampleAccess, ignore. - client_session.go:390
2021/11/29 16:01:38.001302 DEBUG [GROUP1] cache rtmp metadata. size:56 - gop_cache.go:90
2021/11/29 16:01:41.270168 DEBUG [GROUP1] cache rtmp metadata. size:553 - gop_cache.go:90
2021/11/29 16:01:41.270264  INFO http api start pull. req info={Protocol:rtmp Addr:1.255.48.202:1935 AppName:dmb StreamName:ydlive_20140419_1 UrlParam:} - http_api.go:115
panic: runtime error: index out of range [0] with length 0

goroutine 84 [running]:
github.com/q191201771/lal/pkg/base.RtmpMsg.IsAacSeqHeader({{0x6, 0x0, 0x8, 0x1, 0x0}, {0x0, 0x0, 0x0}})
        /Volumes/Case/go/fork/lal/pkg/base/rtmp_t.go:114 +0xbb
github.com/q191201771/lal/pkg/remux.(*GopCache).Feed(0xc000149f40, {{0x6, 0x0, 0x8, 0x1, 0x0}, {0x0, 0x0, 0x0}}, 0xc000125298)
        /Volumes/Case/go/fork/lal/pkg/remux/gop_cache.go:93 +0xd0
github.com/q191201771/lal/pkg/logic.(*Group).broadcastByRtmpMsg(0xc0001a6a00, {{0x6, 0x0, 0x8, 0x1, 0x0}, {0x0, 0x0, 0x0}})
        /Volumes/Case/go/fork/lal/pkg/logic/group.go:1149 +0x126d
github.com/q191201771/lal/pkg/logic.(*Group).OnReadRtmpAvMsg(0xc0001a6a00, {{0x6, 0x0, 0x8, 0x1, 0x0}, {0x0, 0x0, 0x0}})
        /Volumes/Case/go/fork/lal/pkg/logic/group.go:918 +0x145
github.com/q191201771/lal/pkg/rtmp.(*ClientSession).doMsg(0xc0003e6000, 0xc0004a4750)
        /Volumes/Case/go/fork/lal/pkg/rtmp/client_session.go:368 +0x409
github.com/q191201771/lal/pkg/rtmp.(*ChunkComposer).RunLoop(0xc00039a440, {0x5b7d3c0, 0xc0004c0210}, 0xc000125da0)
        /Volumes/Case/go/fork/lal/pkg/rtmp/chunk_composer.go:238 +0xdbd
github.com/q191201771/lal/pkg/rtmp.(*ClientSession).runReadLoop(0xc0003e6000)
        /Volumes/Case/go/fork/lal/pkg/rtmp/client_session.go:340 +0xb2
github.com/q191201771/lal/pkg/rtmp.(*ClientSession).doContext.func1()
        /Volumes/Case/go/fork/lal/pkg/rtmp/client_session.go:260 +0x618
created by github.com/q191201771/lal/pkg/rtmp.(*ClientSession).doContext
        /Volumes/Case/go/fork/lal/pkg/rtmp/client_session.go:233 +0x12d
Exiting.

Debugger finished with the exit code 0

@q191201771
Copy link
Owner

感谢反馈,对您的三次留言依次回复:

  1. http api中的start pull当前常见的用法是,有播放端从lalserver拉流,流不存在,从远端pull至本地,供拉流端使用。当本地没有拉这路流的播放者时,不再pull。设计的初衷是按需pull,节约资源。

  2. 看日志是发起了pull动作,但是在发送完rtmp play信令后,没有收到相对应的结果信令,最终达到超时时间,本端主动停止了pull会话。

该测试中的rtmp://hk2.hwadzan.com/liveedge/amtb 我tcp建联失败(可能是网络原因),你用ffplay播放这个流是正常的吗?

  1. panic的问题我会尽快定位并修复

感谢。

@q191201771
Copy link
Owner

3.2中的panic的问题我已经修复,你可以继续测试了。(panic的原因是源流的rtmp协议不太标准)

@opo2000tw
Copy link
Author

opo2000tw commented Nov 29, 2021

  1. 理解是 按需照 appName/streamName = xxx 拉取指定的流
    "動態給定網址" 的應用場景在 lalserver.go session 過期前,或由 dispatch.go 以下情況發生之間
    "靜態給定網址" 則寫入在 lalserver.conf.json
dispatch.go
2021/11/30 04:55:14.806995  INFO [ReqID2733] on_sub_start. info={SessionEventCommonInfo:{Protocol:rtmp://127.0.0.1:1935/live/test SessionId:RTMPPUBSUB3 RemoteAddr:127.0.0.1:62562 ServerId:1 Url: AppName:live StreamName:test UrlParam: HasInSession:false HasOutSession:true}} - dispatch.go:118
2021/11/30 04:55:14.807015  INFO [ReqID2733] pub not exist, ignore. - dispatch.go:142

輸入 /api/ctrl/start_pull ...

dispatch.go
2021/11/30 05:15:46.351803  INFO [ReqID42] on_sub_stop. info={SessionEventCommonInfo:{Protocol:RTMP SessionId:RTMPPUBSUB4 RemoteAddr:127.0.0.1:63251 ServerId:1 Url: AppName:cbs-live StreamName:cbs-live.stream UrlParam: HasInSession:false HasOutSession:false}} - dispatch.go:172
2021/11/30 05:15:50.351280  INFO [ReqID43] on_update. info={ServerId:1 Groups:[]} - dispatch.go:183

  1. 用 ffplay 播放皆正常,不確定 hk2.hwadzan.com 在大陸是否會被擋 ip,因為是佛教網站
    佛教2,rtmp://hk2.hwadzan.com/liveedge/amtb
    佛教4,rtmp://hk2.hwadzan.com/liveedgelist/livetv
/Volumes/Case/go/fork/lal/lal_record tags/v0.26.0* 2m 17s
❯ ffplay rtmp://hk2.hwadzan.com/liveedge/amtb
ffplay version 4.4.1 Copyright (c) 2003-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, flv, from 'rtmp://hk2.hwadzan.com/liveedge/amtb': f=0/0
  Metadata:
    |RtmpSampleAccess: false
    length          : 100236864
    timescale       : 48000
    sampletype      : mp4a
    audiochannels   : 2
    videoframerate  : 30
    aacaot          : 2
    avclevel        : 31
    avcprofile      : 77
    frameWidth      : 1280
    frameHeight     : 720
    displayWidth    : 1280
    displayHeight   : 720
    moovposition    : 40
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Data: none
  Stream #0:1: Video: h264 (Main), yuv420p(progressive), 1280x720, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
  Stream #0:2: Audio: aac (LC), 48000 Hz, stereo, fltp
  17.75 A-V: -0.004 fd= 187 aq=    0KB vq=    0KB sq=    0B f=88/45

没有收到相对应的结果信令,最终达到超时时间,本端主动停止了pull会话。
我會再去做確認,指令和地址應該是沒有問題,log如下

GOROOT=/usr/local/opt/go/libexec #gosetup
GOPATH=/Users/blakewu/go #gosetup
/usr/local/opt/go/libexec/bin/go build -o /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go -gcflags all=-N -l /Volumes/Case/go/fork/lal/app/lalserver/main.go #gosetup
/Applications/GoLand.app/Contents/plugins/go/lib/dlv/mac/dlv --listen=127.0.0.1:64829 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go --
API server listening at: 127.0.0.1:64829
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1200.0.44
 for x86_64.
Got a connection, launched process /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go (pid = 34344).
2021/11/30 06:08:59.069284  WARN config file did not specify in the command line, try to load it in the usual path. - main.go:52
2021/11/30 06:08:59.070343  WARN lalserver.conf.json not exist. - main.go:68
2021/11/30 06:08:59.070377  WARN ./conf/lalserver.conf.json exist. using it as config file. - main.go:65
2021/11/30 06:08:59.073645  INFO initial log succ. - config.go:210
2021/11/30 06:08:59.073934  INFO 
    __    ___    __
   / /   /   |  / /
  / /   / /| | / /
 / /___/ ___ |/ /___
/_____/_/  |_/_____/
 - config.go:213
2021/11/30 06:08:59.074540  INFO load conf file succ. filename=./conf/lalserver.conf.json, raw content={ "# doc of config": "https://pengrl.com/lal/#/ConfigBrief", "conf_version": "v0.2.4", "rtmp": { "enable": true, "addr": ":1935", "gop_num": 0, "merge_write_size": 0, "add_dummy_audio_enable": false, "add_dummy_audio_wait_audio_ms": 150 }, "default_http": { "http_listen_addr": ":8080", "https_listen_addr": ":4433", "https_cert_file": "./conf/cert.pem", "https_key_file": "./conf/key.pem" }, "httpflv": { "enable": true, "enable_https": false, "url_pattern": "/", "gop_num": 0 }, "hls": { "enable": true, "enable_https": false, "url_pattern": "/hls/", "out_path": "./lal_record/hls/", "fragment_duration_ms": 3000, "fragment_num": 6, "cleanup_mode": 1, "use_memory_as_disk_flag": false }, "httpts": { "enable": true, "enable_https":false, "url_pattern": "/" }, "rtsp": { "enable": true, "addr": ":5544" }, "record": { "enable_flv": false, "flv_out_path": "./lal_record/flv/", "enable_mpegts": false, "mpegts_out_path": "./lal_record/mpegts" }, "relay_push": { "enable": false, "addr_list":[ ] }, "relay_pull": { "enable": false, "addr": "" }, "http_api": { "enable": true, "addr": ":8083" }, "server_id": "1", "http_notify": { "enable": true, "update_interval_sec": 5, "on_server_start": "http://127.0.0.1:10101/on_server_start", "on_update": "http://127.0.0.1:10101/on_update", "on_pub_start": "http://127.0.0.1:10101/on_pub_start", "on_pub_stop": "http://127.0.0.1:10101/on_pub_stop", "on_sub_start": "http://127.0.0.1:10101/on_sub_start", "on_sub_stop": "http://127.0.0.1:10101/on_sub_stop", "on_rtmp_connect": "http://127.0.0.1:10101/on_rtmp_connect" }, "pprof": { "enable": true, "addr": ":8084" }, "log": { "level": 1, "filename": "./logs/lalserver.log", "is_to_stdout": true, "is_rotate_daily": true, "short_file_flag": true, "timestamp_flag": true, "timestamp_with_ms_flag": true, "level_flag": true, "assert_behavior": 1 } }  parsed=&{ConfVersion:v0.2.4 RtmpConfig:{Enable:true Addr::1935 GopNum:0 MergeWriteSize:0 AddDummyAudioEnable:false AddDummyAudioWaitAudioMs:150} DefaultHttpConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem}} HttpflvConfig:{CommonHttpServerConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem} Enable:true EnableHttps:false UrlPattern:/} GopNum:0} HlsConfig:{CommonHttpServerConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem} Enable:true EnableHttps:false UrlPattern:/hls/} UseMemoryAsDiskFlag:false MuxerConfig:{OutPath:./lal_record/hls/ FragmentDurationMs:3000 FragmentNum:6 CleanupMode:1}} HttptsConfig:{CommonHttpServerConfig:{CommonHttpAddrConfig:{HttpListenAddr::8080 HttpsListenAddr::4433 HttpsCertFile:./conf/cert.pem HttpsKeyFile:./conf/key.pem} Enable:true EnableHttps:false UrlPattern:/}} RtspConfig:{Enable:true Addr::5544} RecordConfig:{EnableFlv:false FlvOutPath:./lal_record/flv/ EnableMpegts:false MpegtsOutPath:./lal_record/mpegts} RelayPushConfig:{Enable:false AddrList:[]} RelayPullConfig:{Enable:false Addr:} HttpApiConfig:{Enable:true Addr::8083} ServerId:1 HttpNotifyConfig:{Enable:true UpdateIntervalSec:5 OnServerStart:http://127.0.0.1:10101/on_server_start OnUpdate:http://127.0.0.1:10101/on_update OnPubStart:http://127.0.0.1:10101/on_pub_start OnPubStop:http://127.0.0.1:10101/on_pub_stop OnSubStart:http://127.0.0.1:10101/on_sub_start OnSubStop:http://127.0.0.1:10101/on_sub_stop OnRtmpConnect:http://127.0.0.1:10101/on_rtmp_connect} PprofConfig:{Enable:true Addr::8084} LogConfig:{Level:1 Filename:./logs/lalserver.log IsToStdout:true IsRotateDaily:true ShortFileFlag:true TimestampFlag:true TimestampWithMsFlag:true LevelFlag:true AssertBehavior:1}} - config.go:296
2021/11/30 06:08:59.074921  INFO wd: /Volumes/Case/go/fork/lal - server_manager.go:67
2021/11/30 06:08:59.075059  INFO args: /private/var/folders/7c/6l1tr8_53w501pny7tp41x840000gn/T/GoLand/___go_build_main_go - server_manager.go:68
2021/11/30 06:08:59.075084  INFO bininfo: GitTag=unknown. GitCommitLog=unknown. GitStatus=unknown. BuildTime=unknown. GoVersion=unknown. runtime=darwin/amd64. - server_manager.go:69
2021/11/30 06:08:59.075105  INFO version: lal v0.26.0 (github.com/q191201771/lal) - server_manager.go:70
2021/11/30 06:08:59.075125  INFO github: https://github.com/q191201771/lal - server_manager.go:71
2021/11/30 06:08:59.075146  INFO doc: https://pengrl.com/lal - server_manager.go:72
2021/11/30 06:08:59.075166  INFO serverStartTime: 2021-11-30 06:08:59.07 - server_manager.go:73
2021/11/30 06:08:59.076557  INFO start web pprof listen. addr=:8084 - server_manager.go:755
2021/11/30 06:08:59.079040  INFO add http listen for httpflv. addr=:8080, pattern=/ - server_manager.go:143
2021/11/30 06:08:59.079090  INFO add http listen for httpts. addr=:8080, pattern=/ - server_manager.go:143
2021/11/30 06:08:59.079117  INFO add http listen for hls. addr=:8080, pattern=/hls/ - server_manager.go:143
2021/11/30 06:08:59.079196  INFO start rtmp server listen. addr=:1935 - server.go:42
2021/11/30 06:08:59.079899  INFO start rtsp server listen. addr=:5544 - server.go:64
2021/11/30 06:08:59.080347  INFO start httpapi server listen. addr=:8083 - http_api.go:40
2021/11/30 06:09:04.979559  INFO accept a rtmp connection. remoteAddr=127.0.0.1:64842 - server.go:66
2021/11/30 06:09:04.979682 DEBUG [NAZACONN1] lifecycle new connection. net.Conn=0xc0001a0360, naza.Connection=0xc0001d0370 - connection.go:192
2021/11/30 06:09:04.980107  INFO [RTMPPUBSUB1] lifecycle new rtmp ServerSession. session=0xc0001dcb00, remote addr=127.0.0.1:64842 - server_session.go:97
2021/11/30 06:09:04.980489 DEBUG handshake complex mode. - handshake.go:249
2021/11/30 06:09:04.980629  INFO [RTMPPUBSUB1] < R Handshake C0+C1. - server_session.go:192
2021/11/30 06:09:04.980758  INFO [RTMPPUBSUB1] > W Handshake S0+S1+S2. - server_session.go:194
2021/11/30 06:09:04.981562  INFO [RTMPPUBSUB1] < R Handshake C2. - server_session.go:202
2021/11/30 06:09:04.981974  INFO [RTMPPUBSUB1] < R connect('liveedge'). tcUrl=rtmp://127.0.0.1:1935/liveedge - server_session.go:349
2021/11/30 06:09:04.982227  INFO [RTMPPUBSUB1] > W Window Acknowledgement Size 5000000. - server_session.go:353
2021/11/30 06:09:04.982442  INFO [RTMPPUBSUB1] > W Set Peer Bandwidth. - server_session.go:358
2021/11/30 06:09:04.982494  INFO [RTMPPUBSUB1] > W SetChunkSize 4096. - server_session.go:363
2021/11/30 06:09:04.982580  INFO [RTMPPUBSUB1] > W _result('NetConnection.Connect.Success'). - server_session.go:368
2021/11/30 06:09:04.982944  WARN [RTMPPUBSUB1] read unknown message. typeid=5, header={Csid:2 MsgLen:4 MsgTypeId:5 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=0, wpos=4, hex=00000000  00 4c 4b 40                                       |.LK@|
 - server_session.go:229
2021/11/30 06:09:04.982989  INFO [RTMPPUBSUB1] < R createStream(). - server_session.go:380
2021/11/30 06:09:04.983077  INFO [RTMPPUBSUB1] > W _result(). - server_session.go:381
2021/11/30 06:09:04.983315 DEBUG [RTMPPUBSUB1] read command message, ignore it. cmd=getStreamLength, header={Csid:8 MsgLen:35 MsgTypeId:20 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=27, wpos=35, hex=00000000  05 02 00 04 61 6d 74 62                           |....amtb|
 - server_session.go:323
2021/11/30 06:09:04.983376  INFO [RTMPPUBSUB1] < R play('amtb'). - server_session.go:441
2021/11/30 06:09:04.983462  INFO [RTMPPUBSUB1] > W onStatus('NetStream.Play.Start'). - server_session.go:451
2021/11/30 06:09:04.983619 DEBUG CHEFERASEME [RTMPPUBSUB1] OnNewRtmpSubSession. rtmp://127.0.0.1:1935/liveedge/amtb, liveedge, amtb,  - server_manager.go:432
2021/11/30 06:09:04.983733  INFO [GROUP1] lifecycle new group. group=0xc0002f8000, appName=liveedge, streamName=amtb - group.go:152
2021/11/30 06:09:04.983867 DEBUG [GROUP1] [RTMPPUBSUB1] add SubSession into group. - group.go:406
2021/11/30 06:09:04.984151  WARN [RTMPPUBSUB1] read unknown message. typeid=4, header={Csid:2 MsgLen:10 MsgTypeId:4 MsgStreamId:0 TimestampAbs:1}, b=len(core)=4096, rpos=0, wpos=10, hex=00000000  00 03 00 00 00 01 00 00  0b b8                    |..........|
 - server_session.go:229
2021/11/30 06:09:15.083983  WARN [GROUP1] session timeout. session=RTMPPUBSUB1 - group.go:201
2021/11/30 06:09:15.084054  INFO [RTMPPUBSUB1] lifecycle dispose rtmp ServerSession. - server_session.go:124
2021/11/30 06:09:15.084071 DEBUG [NAZACONN1] Close. - connection.go:376
2021/11/30 06:09:15.084107 DEBUG [NAZACONN1] close once. err=<nil> - connection.go:504
2021/11/30 06:09:15.084221 DEBUG [GROUP1] [RTMPPUBSUB1] del rtmp SubSession from group. - group.go:688
2021/11/30 06:09:15.084247  INFO [RTMPPUBSUB1] rtmp loop done. err=read tcp 127.0.0.1:1935->127.0.0.1:64842: use of closed network connection - server.go:69
2021/11/30 06:09:15.084291 DEBUG CHEFERASEME [RTMPPUBSUB1] OnDelRtmpSubSession. rtmp://127.0.0.1:1935/liveedge/amtb, liveedge, amtb,  - server_manager.go:455
2021/11/30 06:09:15.084345 DEBUG [GROUP1] [RTMPPUBSUB1] del rtmp SubSession from group. - group.go:688
2021/11/30 06:09:15.169443  INFO http api start pull. req info={Protocol:rtmp Addr:61.93.225.146:1935 AppName:liveedge StreamName:amtb UrlParam:} - http_api.go:115
2021/11/30 06:09:16.084120  INFO erase empty group. [GROUP1] - server_manager.go:232
2021/11/30 06:09:16.084181  INFO [GROUP1] lifecycle dispose group. - group.go:262
2021/11/30 06:09:22.139226  INFO accept a rtmp connection. remoteAddr=127.0.0.1:64853 - server.go:66
2021/11/30 06:09:22.139326 DEBUG [NAZACONN2] lifecycle new connection. net.Conn=0xc0001340b0, naza.Connection=0xc00015c210 - connection.go:192
2021/11/30 06:09:22.139396  INFO [RTMPPUBSUB2] lifecycle new rtmp ServerSession. session=0xc0001531e0, remote addr=127.0.0.1:64853 - server_session.go:97
2021/11/30 06:09:22.139517 DEBUG handshake complex mode. - handshake.go:249
2021/11/30 06:09:22.139586  INFO [RTMPPUBSUB2] < R Handshake C0+C1. - server_session.go:192
2021/11/30 06:09:22.139618  INFO [RTMPPUBSUB2] > W Handshake S0+S1+S2. - server_session.go:194
2021/11/30 06:09:22.139873  INFO [RTMPPUBSUB2] < R Handshake C2. - server_session.go:202
2021/11/30 06:09:22.139988  INFO [RTMPPUBSUB2] < R connect('liveedge'). tcUrl=rtmp://127.0.0.1:1935/liveedge - server_session.go:349
2021/11/30 06:09:22.140034  INFO [RTMPPUBSUB2] > W Window Acknowledgement Size 5000000. - server_session.go:353
2021/11/30 06:09:22.140075  INFO [RTMPPUBSUB2] > W Set Peer Bandwidth. - server_session.go:358
2021/11/30 06:09:22.140125  INFO [RTMPPUBSUB2] > W SetChunkSize 4096. - server_session.go:363
2021/11/30 06:09:22.140181  INFO [RTMPPUBSUB2] > W _result('NetConnection.Connect.Success'). - server_session.go:368
2021/11/30 06:09:22.140400  WARN [RTMPPUBSUB2] read unknown message. typeid=5, header={Csid:2 MsgLen:4 MsgTypeId:5 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=0, wpos=4, hex=00000000  00 4c 4b 40                                       |.LK@|
 - server_session.go:229
2021/11/30 06:09:22.140447  INFO [RTMPPUBSUB2] < R createStream(). - server_session.go:380
2021/11/30 06:09:22.140474  INFO [RTMPPUBSUB2] > W _result(). - server_session.go:381
2021/11/30 06:09:22.141029 DEBUG [RTMPPUBSUB2] read command message, ignore it. cmd=getStreamLength, header={Csid:8 MsgLen:35 MsgTypeId:20 MsgStreamId:0 TimestampAbs:0}, b=len(core)=4096, rpos=27, wpos=35, hex=00000000  05 02 00 04 61 6d 74 62                           |....amtb|
 - server_session.go:323
2021/11/30 06:09:22.141117  INFO [RTMPPUBSUB2] < R play('amtb'). - server_session.go:441
2021/11/30 06:09:22.141176  INFO [RTMPPUBSUB2] > W onStatus('NetStream.Play.Start'). - server_session.go:451
2021/11/30 06:09:22.141288 DEBUG CHEFERASEME [RTMPPUBSUB2] OnNewRtmpSubSession. rtmp://127.0.0.1:1935/liveedge/amtb, liveedge, amtb,  - server_manager.go:432
2021/11/30 06:09:22.141333  INFO [GROUP2] lifecycle new group. group=0xc0002f8280, appName=liveedge, streamName=amtb - group.go:152
2021/11/30 06:09:22.141369 DEBUG [GROUP2] [RTMPPUBSUB2] add SubSession into group. - group.go:406
2021/11/30 06:09:22.141464  WARN [RTMPPUBSUB2] read unknown message. typeid=4, header={Csid:2 MsgLen:10 MsgTypeId:4 MsgStreamId:0 TimestampAbs:1}, b=len(core)=4096, rpos=0, wpos=10, hex=00000000  00 03 00 00 00 01 00 00  0b b8                    |..........|
 - server_session.go:229
2021/11/30 06:09:23.887008  INFO http api start pull. req info={Protocol:rtmp Addr:61.93.225.146:1935 AppName:liveedge StreamName:amtb UrlParam:} - http_api.go:115
2021/11/30 06:09:23.887065  INFO [GROUP2] start relay pull. url=rtmp://61.93.225.146:1935/liveedge/amtb - group.go:1308
2021/11/30 06:09:23.887297  INFO [RTMPPULL1] lifecycle new rtmp ClientSession. session=0xc0001fa400 - client_session.go:120
2021/11/30 06:09:23.887389 DEBUG [RTMPPULL1] Do. url=rtmp://61.93.225.146:1935/liveedge/amtb - client_session.go:126
2021/11/30 06:09:23.887680  INFO [RTMPPULL1] > tcp connect. - client_session.go:299
2021/11/30 06:09:23.943954 DEBUG [NAZACONN3] lifecycle new connection. net.Conn=0xc0001a03d8, naza.Connection=0xc0001d0420 - connection.go:192
2021/11/30 06:09:23.944029  INFO [RTMPPULL1] > W Handshake C0+C1. - client_session.go:317
2021/11/30 06:09:23.986161  INFO [RTMPPULL1] < R Handshake S0+S1. - client_session.go:325
2021/11/30 06:09:23.986241  INFO [RTMPPULL1] > W Handshake C2. - client_session.go:327
2021/11/30 06:09:23.988946  INFO [RTMPPULL1] < R Handshake S2. - client_session.go:335
2021/11/30 06:09:23.988991  INFO [RTMPPULL1] > W SetChunkSize 4096. - client_session.go:248
2021/11/30 06:09:23.989032  INFO [RTMPPULL1] > W connect('liveedge'). tcUrl=rtmp://61.93.225.146:1935/liveedge - client_session.go:254
2021/11/30 06:09:24.033483  INFO [RTMPPULL1] < R Window Acknowledgement Size: 2500000 - client_session.go:518
2021/11/30 06:09:24.033700  WARN [RTMPPULL1] < R Set Peer Bandwidth. ignore. - client_session.go:521
2021/11/30 06:09:24.033795  WARN [RTMPPULL1] read user control message, ignore. buf=00000000  00 00 00 00 00 00                                 |......|
 - client_session.go:362
2021/11/30 06:09:24.033874  INFO [RTMPPULL1] < R Set Chunk Size 4096. - client_session.go:524
2021/11/30 06:09:24.034126  WARN amf ReadArray without suffix Amf0TypeMarkerObjectEndBytes. - amf0.go:381
2021/11/30 06:09:24.034239  INFO [RTMPPULL1] < R _result("NetConnection.Connect.Success"). - client_session.go:474
2021/11/30 06:09:24.034282  INFO [RTMPPULL1] > W createStream(). - client_session.go:475
2021/11/30 06:09:24.075045  INFO [RTMPPULL1] < R _result(). - client_session.go:491
2021/11/30 06:09:24.075115  INFO [RTMPPULL1] > W play('amtb'). - client_session.go:494
2021/11/30 06:09:28.890173  INFO [RTMPPULL1] lifecycle dispose rtmp ClientSession. err=<nil> - client_session.go:550
2021/11/30 06:09:28.891260 DEBUG [NAZACONN3] Close. - connection.go:376
2021/11/30 06:09:28.891312 DEBUG [NAZACONN3] close once. err=<nil> - connection.go:504
2021/11/30 06:09:28.891431 ERROR [RTMPPULL1] relay pull fail. err=context deadline exceeded - group.go:1318
2021/11/30 06:09:28.891488 DEBUG [GROUP2] [RTMPPULL1] del rtmp PullSession from group. - group.go:680
2021/11/30 06:09:29.080849  INFO [GROUP2] start relay pull. url=rtmp://61.93.225.146:1935/liveedge/amtb - group.go:1308
2021/11/30 06:09:29.080952 DEBUG group size=1 - server_manager.go:244
2021/11/30 06:09:29.081036  INFO [RTMPPULL2] lifecycle new rtmp ClientSession. session=0xc000498000 - client_session.go:120
2021/11/30 06:09:29.081089 DEBUG [RTMPPULL2] Do. url=rtmp://61.93.225.146:1935/liveedge/amtb - client_session.go:126
2021/11/30 06:09:29.081051 DEBUG {"stream_name":"amtb","audio_codec":"","video_codec":"","video_width":0,"video_height":0,"pub":{"protocol":"","session_id":"","remote_addr":"","start_time":"","read_bytes_sum":0,"wrote_bytes_sum":0,"bitrate":0,"read_bitrate":0,"write_bitrate":0},"subs":[{"protocol":"RTMP","session_id":"RTMPPUBSUB2","remote_addr":"127.0.0.1:64853","start_time":"2021-11-30 06:09:22.139","read_bytes_sum":3449,"wrote_bytes_sum":3527,"bitrate":0,"read_bitrate":0,"write_bitrate":0}],"pull":{"protocol":"","session_id":"","remote_addr":"","start_time":"","read_bytes_sum":0,"wrote_bytes_sum":0,"bitrate":0,"read_bitrate":0,"write_bitrate":0}} - server_manager.go:247
2021/11/30 06:09:29.081165  INFO [RTMPPULL2] > tcp connect. - client_session.go:299
2021/11/30 06:09:29.139702 DEBUG [NAZACONN4] lifecycle new connection. net.Conn=0xc0002bc0a0, naza.Connection=0xc0002c6420 - connection.go:192
2021/11/30 06:09:29.139772  INFO [RTMPPULL2] > W Handshake C0+C1. - client_session.go:317
2021/11/30 06:09:29.185599  INFO [RTMPPULL2] < R Handshake S0+S1. - client_session.go:325
2021/11/30 06:09:29.185704  INFO [RTMPPULL2] > W Handshake C2. - client_session.go:327
2021/11/30 06:09:29.185784  INFO [RTMPPULL2] < R Handshake S2. - client_session.go:335
2021/11/30 06:09:29.185838  INFO [RTMPPULL2] > W SetChunkSize 4096. - client_session.go:248
2021/11/30 06:09:29.185963  INFO [RTMPPULL2] > W connect('liveedge'). tcUrl=rtmp://61.93.225.146:1935/liveedge - client_session.go:254
2021/11/30 06:09:29.230327  INFO [RTMPPULL2] < R Window Acknowledgement Size: 2500000 - client_session.go:518
2021/11/30 06:09:29.230417  WARN [RTMPPULL2] < R Set Peer Bandwidth. ignore. - client_session.go:521
2021/11/30 06:09:29.230459  WARN [RTMPPULL2] read user control message, ignore. buf=00000000  00 00 00 00 00 00                                 |......|
 - client_session.go:362
2021/11/30 06:09:29.230489  INFO [RTMPPULL2] < R Set Chunk Size 4096. - client_session.go:524
2021/11/30 06:09:29.230531  WARN amf ReadArray without suffix Amf0TypeMarkerObjectEndBytes. - amf0.go:381
2021/11/30 06:09:29.230584  INFO [RTMPPULL2] < R _result("NetConnection.Connect.Success"). - client_session.go:474
2021/11/30 06:09:29.230623  INFO [RTMPPULL2] > W createStream(). - client_session.go:475
2021/11/30 06:09:29.267976  INFO [RTMPPULL2] < R _result(). - client_session.go:491
2021/11/30 06:09:29.268122  INFO [RTMPPULL2] > W play('amtb'). - client_session.go:494
2021/11/30 06:09:33.082088  WARN [GROUP2] session timeout. session=RTMPPUBSUB2 - group.go:201
2021/11/30 06:09:33.082210  INFO [RTMPPUBSUB2] lifecycle dispose rtmp ServerSession. - server_session.go:124
2021/11/30 06:09:33.082251 DEBUG [NAZACONN2] Close. - connection.go:376
2021/11/30 06:09:33.082278 DEBUG [NAZACONN2] close once. err=<nil> - connection.go:504
2021/11/30 06:09:33.082390 DEBUG [GROUP2] [RTMPPUBSUB2] del rtmp SubSession from group. - group.go:688
2021/11/30 06:09:33.082446  INFO [RTMPPUBSUB2] rtmp loop done. err=read tcp 127.0.0.1:1935->127.0.0.1:64853: use of closed network connection - server.go:69
2021/11/30 06:09:33.082532 DEBUG CHEFERASEME [RTMPPUBSUB2] OnDelRtmpSubSession. rtmp://127.0.0.1:1935/liveedge/amtb, liveedge, amtb,  - server_manager.go:455
2021/11/30 06:09:33.082581 DEBUG [GROUP2] [RTMPPUBSUB2] del rtmp SubSession from group. - group.go:688
2021/11/30 06:09:34.084193  INFO erase empty group. [GROUP2] - server_manager.go:232
2021/11/30 06:09:34.084318  INFO [GROUP2] lifecycle dispose group. - group.go:262
2021/11/30 06:09:34.084270  INFO [RTMPPULL2] lifecycle dispose rtmp ClientSession. err=<nil> - client_session.go:550
2021/11/30 06:09:34.084444 DEBUG [NAZACONN4] Close. - connection.go:376
2021/11/30 06:09:34.084505 DEBUG [NAZACONN4] close once. err=<nil> - connection.go:504
2021/11/30 06:09:34.084610 ERROR [RTMPPULL2] relay pull fail. err=context deadline exceeded - group.go:1318
2021/11/30 06:09:34.084664 DEBUG [GROUP2] [RTMPPULL2] del rtmp PullSession from group. - group.go:680
2021/11/30 06:09:59.082844 DEBUG group size=0 - server_manager.go:244


  1. 已測試可以播放
    您那邊有比較標準規範的 rtmp server 網址或是推薦使用哪個軟體可以簡單的測試?

@opo2000tw
Copy link
Author

opo2000tw commented Nov 29, 2021

還有以下兩個問題想請問您。是否要開新討論串?

  1. 改成直接從 rtsp 回源拉流 (start_pull) 的想法是否有錯誤和可能壓在兩秒內顯示? 目前想法如下,思路有問題嗎?
  • 修改 ComplexGroupManager,確認一些 appName 和 streamName 的問題
  • 修改 dispatch.go 增加 api
  • 接收 dispatch.go 的指令觸發 CtrlStartPull
  • 仿造 CtrlStartPull 並確認 rtsp 實際流程新增 function 可能在 pullIfNeeded 裡面做判斷 rtmp, rtsp 等等
mcu -> rtsp tcp 1280p的條件下 rtsp 
-> ffplay (1.2秒)

pullrtsp2rtsp 
-> FLV, HLS, MPEGTS, RTMP
-> ffplay
1. FLV 會慢到出現 timestamp 錯誤 
2. HLS 太慢(10-15 sec) 
3. 未嘗試:MPEGTS 
4. rtmp(5 sec)播放器端麻煩,顯示想用 js 寫大概率只能用 popup 去 call 播放器 
  1. 需要對存儲下的影像做以下場景,有一般使用影像的格式或想法嗎
  • 使用者點擊播放延遲 2-5 sec
  • 外部事件觸發分段錄影(檔案含預錄 30s-60s)
  • 影像格式和播放器整合到 JS 或 Go,能用 html 做GUI 最好

感謝

@q191201771
Copy link
Owner

  1. 改造lalserver的relay pull支持rtsp是可行的(我后续也会支持这个功能,排期没有定)
  2. 你也可以选择在lalserver之外,使用pullrtsp2pushrtsp等demo所演示的做法,拉取源流转推至lalserver

@q191201771
Copy link
Owner

HTTP-API控制的relay pull回源拉流功能已支持rtsp协议,可以试试,文档见:
https://pengrl.com/lal/#/HTTPAPI?id=_21-apictrlstart_relay_pull

@q191201771
Copy link
Owner

这个功能已经完成,issue先关闭了,有需要请重新打开或创建新的issue,感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants