|
本帖最后由 learn_ffmpeg 于 2019-12-26 18:34 编辑
昨天项目现场碰到一个问题,ffmpeg在启动接收之后遇到一个异常的时间戳,然后有一个丢包,丢包之后就开始疯狂的往网卡打流量,出口1个千M的网卡直接给打满了。
转码的命令如下:
[AppleScript] 纯文本查看 复制代码 ffmpeg -re -i -reorder_queue_size 2000 -buffer_size 2867200 -i rtp://xxxx -c:v hevc_nvenc -profile:v main10 -preset fast -b:v 8000K -r 25 -g 25 -rc cbr_hq -cbr true -s 3840*2160 -gpu 0 -c:a aac -b:a 128K -ac 2 -ar 44100 -bufsize:v 5332K -minrate:v 7800K -maxrate:v 7800K -muxrate 8776K -f mpegts -y "udp://xxxx?pkt_size=1316&localaddr=xxxx&overrun_nonfatal=1&fifo_size=286720&ttl=64"
转码日志,从开始直到疯狂输出流量[AppleScript] 纯文本查看 复制代码 2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> encoder : Lavf57.83.100
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> Program 27
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> Metadata:
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> title :
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> Stream #0:0: Video: hevc (hevc_nvenc) (Main 10), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], q=-1--1, 8000 kb/s, 25 fps, 90k tbn, 25 tbc
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> Metadata:
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> encoder : Lavc57.107.100 hevc_nvenc
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> Side data:
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> cpb: bitrate max/min/avg: 7800000/0/8000000 buffer size: 5332000 vbv_delay: -1
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> Stream #0:1: Audio: aac (libfdk_aac), 44100 Hz, stereo, s16, 128 kb/s
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> Metadata:
2019/12/25 18:24:34 otsCheckError.go:276: info task_id = 27 --->>> encoder : Lavc57.107.100 libfdk_aac
2019/12/25 18:24:34 otsCheckError.go:289: info task_id = 27 --->>>frame= 1 fps=0.0 q=0.0 size= 0kB time=00:00:01.09 bitrate= 0.0kbits/s speed=1.25x
2019/12/25 18:24:35 otsCheckError.go:289: info task_id = 27 --->>>frame= 19 fps= 14 q=29.0 size= 1883kB time=00:00:01.88 bitrate=8203.6kbits/s speed=1.37x
2019/12/25 18:24:35 otsCheckError.go:289: info task_id = 27 --->>>frame= 37 fps= 19 q=29.0 size= 2762kB time=00:00:02.53 bitrate=8938.5kbits/s speed=1.33x
2019/12/25 18:24:36 otsCheckError.go:276: info task_id = 27 --->>>[h264 @ 0x2f37680] cabac decode of qscale diff failed at 76 44
2019/12/25 18:24:36 otsCheckError.go:276: info task_id = 27 --->>>[h264 @ 0x2f37680] error while decoding MB 76 44, bytestream 16140
2019/12/25 18:24:36 otsCheckError.go:276: info task_id = 27 --->>>[h264 @ 0x2f37680] concealing 2853 DC, 2853 AC, 2853 MV errors in P frame
2019/12/25 18:24:36 otsCheckError.go:289: info task_id = 27 --->>>frame= 53 fps= 22 q=25.0 size= 3574kB time=00:00:03.20 bitrate=9136.1kbits/s speed=1.33x
2019/12/25 18:24:36 otsCheckError.go:289: info task_id = 27 --->>>frame= 62 fps= 21 q=29.0 size= 3886kB time=00:00:03.80 bitrate=8358.7kbits/s speed=1.31x
2019/12/25 18:24:37 otsCheckError.go:289: info task_id = 27 --->>>frame= 76 fps= 22 q=36.0 size= 4572kB time=00:00:04.20 bitrate=8911.7kbits/s speed=1.23x
2019/12/25 18:24:37 otsCheckError.go:289: info task_id = 27 --->>>frame= 93 fps= 24 q=34.0 size= 5154kB time=00:00:04.69 bitrate=9001.1kbits/s speed=1.19x
2019/12/25 18:24:38 otsRequest.go:208: info ping to server [vip] (172.25.96.3:443) , (gpuc = 4 , g1 = 35 , g2 = 0 , g3 = 0 , g4 = 0) , (report run id's = 27,) , (response = 0)
2019/12/25 18:24:38 otsCheckError.go:289: info task_id = 27 --->>>frame= 106 fps= 24 q=29.0 size= 5690kB time=00:00:05.38 bitrate=8652.6kbits/s speed= 1.2x
2019/12/25 18:24:38 otsCheckError.go:289: info task_id = 27 --->>>frame= 122 fps= 24 q=25.0 size= 6307kB time=00:00:05.85 bitrate=8829.3kbits/s speed=1.17x
2019/12/25 18:24:39 otsCheckError.go:276: info task_id = 27 --->>>[rtp @ 0x2bafb80] PES packet size mismatch
2019/12/25 18:24:39 otsCheckError.go:276: info task_id = 27 --->>>[mp2 @ 0x2c1f360] Header missing
2019/12/25 18:24:39 otsCheckError.go:276: info task_id = 27 --->>>Error while decoding stream #0:1: Invalid data found when processing input
2019/12/25 18:24:39 otsCheckError.go:289: info task_id = 27 --->>>frame= 132 fps= 24 q=26.0 size= 6830kB time=00:00:06.40 bitrate=8730.1kbits/s speed=1.15x
2019/12/25 18:24:39 otsCheckError.go:276: info task_id = 27 --->>>[h264 @ 0x2c25800] cabac decode of qscale diff failed at 103 21
2019/12/25 18:24:39 otsCheckError.go:276: info task_id = 27 --->>>[h264 @ 0x2c25800] error while decoding MB 103 21, bytestream 207647
2019/12/25 18:24:39 otsCheckError.go:276: info task_id = 27 --->>>[h264 @ 0x2c25800] concealing 5586 DC, 5586 AC, 5586 MV errors in I frame
2019/12/25 18:24:39 otsCheckError.go:289: info task_id = 27 --->>>frame= 147 fps= 24 q=26.0 size= 7373kB time=00:00:06.87 bitrate=8786.2kbits/s speed=1.13x
2019/12/25 18:24:40 otsCheckError.go:289: info task_id = 27 --->>>frame= 157 fps= 24 q=29.0 size= 7904kB time=00:00:07.50 bitrate=8631.5kbits/s speed=1.14x
2019/12/25 18:24:40 otsCheckError.go:289: info task_id = 27 --->>>frame= 174 fps= 25 q=27.0 size= 8528kB time=00:00:07.94 bitrate=8796.1kbits/s speed=1.12x
2019/12/25 18:24:41 otsCheckError.go:289: info task_id = 27 --->>>frame= 182 fps= 24 q=30.0 size= 8971kB time=00:00:08.54 bitrate=8598.8kbits/s speed=1.12x
2019/12/25 18:24:41 otsCheckError.go:289: info task_id = 27 --->>>frame= 198 fps= 24 q=25.0 size= 9556kB time=00:00:09.05 bitrate=8643.1kbits/s speed=1.11x
2019/12/25 18:24:42 otsCheckError.go:289: info task_id = 27 --->>>frame= 198 fps= 23 q=25.0 size= 9556kB time=00:00:09.56 bitrate=8181.6kbits/s speed= 1.1x
2019/12/25 18:24:42 otsCheckError.go:289: info task_id = 27 --->>>frame= 209 fps= 23 q=26.0 size= 10126kB time=00:00:09.66 bitrate=8586.6kbits/s speed=1.05x
2019/12/25 18:24:43 otsRequest.go:208: info ping to server [vip] (172.25.96.3:443) , (gpuc = 4 , g1 = 29 , g2 = 0 , g3 = 0 , g4 = 0) , (report run id's = 27,) , (response = 0)
2019/12/25 18:24:43 otsCheckError.go:276: info task_id = 27 --->>>[rtp @ 0x2bafb80] Invalid timestamps stream=0, pts=8590024592, dts=8590082192, size=39805
2019/12/25 18:24:43 otsCheckError.go:201: error task_id = 27 && got error [[rtp @ 0x2bafb80] Invalid timestamps stream=0, pts=8590024592, dts=8590082192, size=39805]
2019/12/25 18:24:43 otsCheckError.go:276: info task_id = 27 --->>>[rtp @ 0x2bafb80] PES packet size mismatch
2019/12/25 18:24:43 otsCheckError.go:201: error task_id = 27 && got error [[rtp @ 0x2bafb80] PES packet size mismatch]
2019/12/25 18:24:43 otsCheckError.go:289: info task_id = 27 --->>>frame= 218 fps= 22 q=26.0 size= 10433kB time=00:00:09.68 bitrate=8825.4kbits/s speed=0.992x
2019/12/25 18:24:48 otsRequest.go:208: info ping to server [vip] (172.25.96.3:443) , (gpuc = 4 , g1 = 6 , g2 = 0 , g3 = 0 , g4 = 0) , (report run id's = 27,) , (response = 0)
2019/12/25 18:24:53 otsRequest.go:208: info ping to server [vip] (172.25.96.3:443) , (gpuc = 4 , g1 = 1 , g2 = 0 , g3 = 0 , g4 = 0) , (report run id's = 27,) , (response = 0)
按理说ffmpeg因为不至于发包导致吧网卡打满,但是把这个转码停止掉之后流量马上就下来了,所以可以锁定就是ffmpeg的问题;因为使用的是mpegts CBR 封装,所以会填充空包,就分析是不是这块出问题,[AppleScript] 纯文本查看 复制代码 mpegts_write_pes()
{
while (payload_size > 0){
av_log(s, AV_LOG_ERROR, "muxer timestamp dts = %s\n", av_d2str(dts));
if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&
(dts - get_pcr(ts, s->pb) / 300) > delay)
{
/* pcr insert gets priority over null packet insert */
if (write_pcr)
mpegts_insert_pcr_only(s, st);
else
mpegts_insert_null_packet(s);
/* recalculate write_pcr and possibly retransmit si_info */
continue;
}
}
}
我的分析,如果时间戳异常,给出的DTS远远大于应该应该发送的同一时刻计算出来的PCR,则此处会疯狂的插入空包并发送,当时由于太着急并没有抓包,所以无法确定是不是这个问题,还请大师兄和各位高手给看看,谢谢?
还有一个问题,ffmpeg中的时间戳处理流程请大家给科普下,比如源自己带的时间戳,解复用之后应该不会变,主要是各个时间基的变换,如果视频的时间戳有重大跳变(非单调递增的除外,这种情况会报错)比如突然变大,但是编码输出,复用之后的时间戳依然正常(测试使用的是mpegts), 视频和音频的编码之后会从新计算时间戳吗?
谢谢
|
|