来自RTSP流的H.264解码错误日志

11

我遇到了以下H264错误日志。在使用FFMPEG解码RTSP视频流时,出现这个日志。在5/6秒后,显示的图像变得模糊。图像会不时恢复,但大部分时间仍然模糊。

编辑:一些FFMPEG讨论论坛建议升级FFMPEG版本以避免这些日志。我已经更新了2015年6月最新的FFMPEG版本构建。然而,日志仍然存在,图像仍然模糊。

编辑2:RTSP流来自GANZ摄像机。该摄像机通过LAN连接。

[h264 @ 0abb2aa0] Cannot use next picture in error concealment
[h264 @ 0abb2aa0] concealing 1933 DC, 1933 AC, 1933 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 131 packets
[h264 @ 0abb3300] error while decoding MB 66 25, bytestream (-9)
[h264 @ 0abb3300] Cannot use next picture in error concealment
[h264 @ 0abb3300] concealing 1583 DC, 1583 AC, 1583 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 8 packets
[h264 @ 0b113e40] error while decoding MB 54 30, bytestream (-11)
[h264 @ 0b113e40] Cannot use next picture in error concealment
[h264 @ 0b113e40] concealing 1195 DC, 1195 AC, 1195 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 118 packets
[h264 @ 0ac79960] error while decoding MB 13 20, bytestream (-13)
[h264 @ 0ac79960] Cannot use next picture in error concealment
[h264 @ 0ac79960] concealing 2036 DC, 2036 AC, 2036 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 198 packets
[h264 @ 0ad4f500] error while decoding MB 21 9, bytestream (-5)
[h264 @ 0ad4f500] Cannot use next picture in error concealment
[h264 @ 0ad4f500] concealing 2908 DC, 2908 AC, 2908 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 108 packets
[h264 @ 0abb3300] error while decoding MB 1 14, bytestream (-5)
[h264 @ 0abb3300] Cannot use next picture in error concealment
[h264 @ 0abb3300] concealing 2528 DC, 2528 AC, 2528 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 106 packets
[h264 @ 0b1149c0] error while decoding MB 12 5, bytestream (-7)
[h264 @ 0b1149c0] Cannot use next picture in error concealment
[h264 @ 0b1149c0] concealing 3237 DC, 3237 AC, 3237 MV errors in P frame
[h264 @ 098e5c80] RTP: missed -65402 packets
[h264 @ 0b1155a0] error while decoding MB 50 38, bytestream (-7)
[h264 @ 0b1155a0] Cannot use next picture in error concealment
[h264 @ 0b1155a0] concealing 559 DC, 559 AC, 559 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 150 packets
[h264 @ 0af65740] error while decoding MB 48 31, bytestream (-15)
[h264 @ 0af65740] Cannot use next picture in error concealment
[h264 @ 0af65740] concealing 1121 DC, 1121 AC, 1121 MV errors in P frame
[h264 @ 098e5c80] RTP: missed 4 packets
[h264 @ 0ac79960] error while decoding MB 35 38, bytestream (-41)
[h264 @ 0ac79960] Cannot use next picture in error concealment
[h264 @ 0ac79960] concealing 574 DC, 574 AC, 574 MV errors in P frame

我使用ffmpeg将RTSP流转储为avi文件,并且没有出现任何错误。 C:\Users\Matlab>ffmpeg -i rtsp://192.168.1.67/gnz_media/main 123.avi

在使用ffmpeg api时,没有H.264解码错误。有人可以帮忙解决上述解码错误吗?


1
请不要在多个 Stack Exchange 网站上询问同样的问题 - llogan
以下是ffplay rtsp://192.168.1.67/gnz_media/main的输出结果。输出结果无法在一个评论框内完整显示,请参见以下链接:https://gist.github.com/anonymous/059c4db6e860675890ce - Tariq
@Tariq,Play没问题,但你能展示一下你的FFmpeg命令行吗? - Dmitri Sosnik
@Tariq - 你正在重新编码你的流(h264(原生) - > h264(libx264)),这相当昂贵,而且根据分辨率和/或帧速率,实时执行可能无法完成,因此rtp会丢失数据包,请尝试仅复制视频并稍后重新编码它,类似于:ffmpeg -i rtsp://192.168.1.67/gnz_media/second -c:v copy 987.mp4 - Dmitri Sosnik
@Tariq,你解决了吗?!! - Muhammed Refaat
显示剩余16条评论
2个回答

10
如果您正在使用UDP,您可以预期有一些帧会被丢弃 - 这是UDP设计的一部分,它更注重速度而非可靠性。对于H264格式来说,缺失的数据包是一个严重的问题,因为一个数据包可能依赖于前面或后面的数据包(使用差分图像而不是发送完整的新图像)。
因此,使用UDP将产生许多错误,包括“RTP:错过XXX个数据包”。
通过向avformat_open_input传递rtsp_transport="tcp"选项,切换到更可靠但较慢的TCP。例如:
AVDictionary * opts = NULL;
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
int error = avformat_open_input(&rtsp_format_context, "rtsp://your url here", NULL, &opts);
if (error < 0)
    ; // Connection error. Add your error handling here.

这将停止数据包的丢失,从而消除视频的损坏。


我们如何使用Python模块python-opencv设置rtsp_transport="tcp"选项。为了捕获视频,我们添加以下代码:cv2.VideoCapture("rtsp://%s:%s@%s/Streaming/Channels/1"),那么在VideoCapture函数中是否需要添加一些其他参数,例如rtsp_transport='tcp'。 - Nishant Kashyap
@NishantKashyap 我没有使用过OpenCV,但是这篇博客说只需在RTSP网址后面添加“?tcp”。因此改成连接rtsp://stream/?tcp - Phi
我更喜欢使用ffmpeg以无数据包丢失和处理量较少的方式获取mp4格式的视频,这样易于在HTML视频播放器上播放和显示。请尝试以下命令:ffmpeg -rtsp_transport tcp -i "rtsp://username:password@xxx.xx.xx.xx" -r 30 -vcodec copy -flags +global_header -map 0 -f mp4 -t 10 -y "video.mp4" - Nishant Kashyap
谢谢您的回答。然而,我并没有遇到丢包的问题,而是视频中完全缺失了一些帧。因此不是“模糊”,而是会失去整整几秒钟的视频。有什么建议吗?谢谢! - Joshua Pinter
@JoshuaPinter 我对此没有额外的输入...但是丢失的帧可能是由于丢包或相机本身在丢失一些帧,也许是为了达到固定的fps?我建议更新相机固件并增加ffmpeg日志级别,以查看是否有丢失的数据包。 - Phi
2
经过多天的广泛测试,相机没有问题,但是WiFi和流媒体功能有问题。或者设备本身无法处理数据吞吐量,但这种可能性较小。使用TCP不会导致帧的“模糊”或“撕裂”,但它会完全丢失帧(即未捕获到部分帧)。使用UDP,它会尽力保留部分帧,但这会导致这些帧的“模糊”或“撕裂”。我们最终选择了UDP,因为它至少显示了部分帧,而不是缺少整个视频块。 - Joshua Pinter

-4

这个问题是由相机引起的,需要通过GANZ技术支持升级相机最新固件。该相机不支持H.264视频压缩。


你遇到了同样的问题吗?你是如何更新GANZ摄像头的固件的? - Tariq

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接