ffmpeg在记录RTSP流时发出“ 501未实现”

时间:2019-02-28 05:44:16

标签: ffmpeg video-streaming rtsp

我有一个4K摄像机(Sony SNC-VB770)流式RTSP。

我正在尝试将流记录到文件中(每个文件都有方便的长度,例如1小时) 使用简单的脚本重复启动ffmpeg(4.1版):

while : ; do
  # (set $url and $outfile, and then)
  ffmpeg -rtsp_transport tcp -t 3600 -y -i $url -c copy -map 0:0 -b:v 16000k $outfile
done

如果我在直接连接到相机的本地PC上运行脚本,则该脚本可以运行(至少一周以上)。 但是,如果我在位于数据中心的服务器上执行相同的操作,则它会随机失败,并且没有错误消息。 有时它会运行几天,有时会在一分钟之内消失。

典型输出如下:

# 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数据包,发现从ffmpeg向摄像机发送了“ RTSP / 1.0 501未实现”。 之后,摄像机最终发送回“不支持RTSP / 1.0 505 RTSP版本”,然后ffmpeg很快退出。

“ 501”数据包似乎是由libavformat / rtsp.c:ff_rtsp_read_reply()生成的, 当ffmpeg接收到格式为null且格式为null的RTSP数据包时,status_code = 0。 我不知道为什么这样的数据包会在随机的时间到达,谁错了(也许是摄像机,也许是从摄像机到服务器计算机的网络路径中间的任何网络交换机或路由器)。 但是无论如何,我不想停止录制 由于那些格式错误的数据包。

有什么解决方法可以使ffmpeg忽略无效的RTSP数据包并继续记录吗?

其他信息:

  • 我已经用ffmpeg ver4.1和2.8.4测试了录音,没有发现差异。

  • 在较低分辨率和较低比特率下均未观察到差异。

  • 我在同一网络环境中有3个来自不同制造商的相机。 这三个都正常工作了一个多月。 只有Sony SNC-VB770表现出奇怪的行为。

0 个答案:

没有答案