ffmpeg问题“;501“未实施”;在录制RTSP流时
我有一个4K摄像头(索尼SNC-VB770)流媒体RTSP 我试图将流记录到文件中(每个文件都有方便的长度,比如说1小时) 使用简单脚本反复启动ffmpeg(4.1版): 如果我在直接连接到相机的本地PC上运行脚本,它会工作(至少一周以上)。 但是,如果我在位于数据中心的服务器计算机上执行相同操作,它将随机失败,并且没有错误消息。 有时它会运行几天,有时它会在一分钟内死去 典型的输出如下所示:ffmpeg问题“;501“未实施”;在录制RTSP流时,ffmpeg,video-streaming,rtsp,Ffmpeg,Video Streaming,Rtsp,我有一个4K摄像头(索尼SNC-VB770)流媒体RTSP 我试图将流记录到文件中(每个文件都有方便的长度,比如说1小时) 使用简单脚本反复启动ffmpeg(4.1版): 如果我在直接连接到相机的本地PC上运行脚本,它会工作(至少一周以上)。 但是,如果我在位于数据中心的服务器计算机上执行相同操作,它将随机失败,并且没有错误消息。 有时它会运行几天,有时它会在一分钟内死去 典型的输出如下所示: # devname: snc-vb770 # url: rtsp://10.40.35.90/medi
# devname: snc-vb770
# url: rtsp://10.40.35.90/media/video1
# vb: 16000k
# datefmt %d%H
# addtimestamp 0
no timestamp
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-18)
configuration: --prefix=/usr/local/ffmpeg-4.1 --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-libx264 --enable-libvorbis --enable-filter=drawtext --enable-libfreetype --enable-libfribidi --enable-fontconfig
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, rtsp, from 'rtsp://10.40.35.90/media/video1':
Metadata:
title : Sony RTSP Server
Duration: N/A, start: 0.066667, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 14.99 fps, 14.99 tbr, 90k tbn, 29.97 tbc
Output #0, mp4, to './2811.mp4':
Metadata:
title : Sony RTSP Server
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 16000 kb/s, 14.99 fps, 14.99 tbr, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x24e4ec0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mp4 @ 0x24e4ec0] pts has no value
[mp4 @ 0x24e4ec0] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
frame= 33 fps=0.0 q=-1.0 size= 1792kB time=00:00:02.00 bitrate=7332.9kbits/s speed=3.57x
...
frame= 104 fps=8.4 q=-1.0 Lsize= 6532kB time=00:00:06.74 bitrate=7939.6kbits/s speed=0.548x
video:6531kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.023506%
我查看了RTSP数据包,发现“RTSP/1.0 501未实现”从ffmpeg发送到相机。
之后,摄像机最终返回“RTSP/1.0 505 RTSP版本不受支持”,然后ffmpeg很快退出
“501”数据包似乎是由libavformat/rtsp.c:ff_rtsp_read_reply()生成的,
当ffmpeg接收到格式不正确的RTSP数据包时,其方法=(null),状态\ U代码=0。
我不知道为什么这样的数据包到达随机的时间和谁是错误的(也许相机,也许任何网络交换机或路由器在网络路径的中间,从相机到服务器机)。
但无论如何,我不想停止录音
由于那些格式不正确的数据包
是否有任何解决方法可以让ffmpeg忽略无效的RTSP数据包并继续录制
其他信息:
- 我已经用ffmpeg版本4.1和2.8.4对录制进行了测试,没有发现任何差异
- 在较低分辨率和较低比特率下均未观察到差异
- 在同一网络环境中,我有3台来自不同制造商的摄像机。 这三个人都顺利地工作了一个多月。 只有索尼SNC-VB770显示出这种奇怪的行为
# devname: snc-vb770
# url: rtsp://10.40.35.90/media/video1
# vb: 16000k
# datefmt %d%H
# addtimestamp 0
no timestamp
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-18)
configuration: --prefix=/usr/local/ffmpeg-4.1 --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-libx264 --enable-libvorbis --enable-filter=drawtext --enable-libfreetype --enable-libfribidi --enable-fontconfig
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, rtsp, from 'rtsp://10.40.35.90/media/video1':
Metadata:
title : Sony RTSP Server
Duration: N/A, start: 0.066667, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 14.99 fps, 14.99 tbr, 90k tbn, 29.97 tbc
Output #0, mp4, to './2811.mp4':
Metadata:
title : Sony RTSP Server
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 16000 kb/s, 14.99 fps, 14.99 tbr, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x24e4ec0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mp4 @ 0x24e4ec0] pts has no value
[mp4 @ 0x24e4ec0] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
frame= 33 fps=0.0 q=-1.0 size= 1792kB time=00:00:02.00 bitrate=7332.9kbits/s speed=3.57x
...
frame= 104 fps=8.4 q=-1.0 Lsize= 6532kB time=00:00:06.74 bitrate=7939.6kbits/s speed=0.548x
video:6531kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.023506%