gwuhaolin / livego

live video streaming server in golang
MIT License
9.66k stars 2k forks source link

请教造成“packet queue max”的原因分析 #208

Open Jiaoma opened 2 years ago

Jiaoma commented 2 years ago

作者你好,我使用livego搭建了一个多视频通过ffmpeg推流至livego的程序,视频流比如有ffmpeg1,ffmpeg2,ffmpeg3。一个进程负责从livego拉取三个视频流处理后,再次通过ffmpeg推流到livego,流名称为test。这个进程速度可能略慢。整个程序运行一段时间后livego会报如下错误:

INFO[2022-05-10T23:09:39+08:00] HLS server enable....
INFO[2022-05-10T23:09:39+08:00] RTMP Listen On :1935
INFO[2022-05-10T23:09:39+08:00] HTTP-API listen On :8090
INFO[2022-05-10T23:09:39+08:00] HLS listen On :7002
INFO[2022-05-10T23:09:39+08:00] HTTP-FLV listen On :7001
WARN[2022-05-10T23:10:54+08:00] [<key: live/ffmpeg3, URL: /live/ffmpeg3.flv, UID: jVtIXeKQT_qTtMF3, Inter: true>] packet queue max!!!
WARN[2022-05-10T23:11:09+08:00] [<key: live/ffmpeg3, URL: /live/ffmpeg3.flv, UID: jVtIXeKQT_qTtMF3, Inter: true>] packet queue max!!!
WARN[2022-05-10T23:11:21+08:00] avc end sequence
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4f5656]

goroutine 86 [running]:
bufio.(*Writer).Flush(0xc000569100)
        /usr/local/go/src/bufio/bufio.go:607 +0x56
bufio.(*Writer).Write(0xc000569100, {0xc002f50317, 0x437db2, 0xc00053e150})
        /usr/local/go/src/bufio/bufio.go:643 +0xd8
net/http.(*response).write(0xc000146700, 0x1738, {0xc002f50317, 0x1738, 0x38ce9}, {0x0, 0x0})
        /usr/local/go/src/net/http/server.go:1592 +0x21e
net/http.(*response).Write(0xc00025e190, {0xc002f50317, 0x7ce70, 0x3})
        /usr/local/go/src/net/http/server.go:1550 +0x30
github.com/gwuhaolin/livego/protocol/httpflv.(*FLVWriter).SendPacket(0xc00025e180)
        /home/molijuly/github/livego/protocol/httpflv/writer.go:151 +0x1d3
github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter.func1()
        /home/molijuly/github/livego/protocol/httpflv/writer.go:55 +0x26
created by github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter
        /home/molijuly/github/livego/protocol/httpflv/writer.go:54 +0x43c

我看记录是说其中的ffmpeg3的packet queue max。请问造成这个“packet queue max”是什么原因呢?

gitzwt commented 2 years ago

遇到相同问题,livego运行一段时间后会奔溃,得重启脚本

tzarebczan commented 2 years ago

We are also seeing this for some streamers and it crashes the stream. What's the proper way to recover quickly or try to prevent this?