ffmpeg正在从RTSP流中读取SDP,但无法保存屏幕截图。是网络还是实用程序问题?

时间:2017-07-05 20:17:26

标签: ubuntu ffmpeg

我的任务是通过ffmpeg从IP摄像机rtsp流中获取屏幕截图。 当我尝试在DigitalOcean Droplet上执行此操作时出现以下错误:

root@docker-512mb-fra1-01:~# ffmpeg -hide_banner -loglevel debug -i rtsp://10.132.193.9//ch0.h264 -f image2 latest.jpg
Splitting the commandline.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input url with argument 'rtsp://10.132.193.9//ch0.h264'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'image2'.
Reading option 'latest.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://10.132.193.9//ch0.h264.
Successfully parsed a group of options.
Opening an input file: rtsp://10.132.193.9//ch0.h264.
[rtsp @ 0x1298440] SDP:
v=0
o=- 1499314217993040 1 IN IP4 192.168.1.128
s=H.264 Program Stream, streamed by the LIVE555 Media Server
i=ch0.h264
t=0 0
a=DevVer:pusher2
a=GroupName:IPCAM
a=NickName:CIF
a=CfgSection:PROG_CHN0
a=tool:LIVE555 Streaming Media v2011.08.13
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:H.264 Program Stream, streamed by the LIVE555 Media Server
a=x-qt-text-inf:ch0.h264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:4000
a=rtpmap:96 H264/90000
a=control:trackID=1
a=fmtp:96 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z2QAH6wrUCgC3IA=,aO48MA==
a=framesize:96 1280-720
a=cliprect:0,0,1280,720
m=audio 0 RTP/AVP 97
a=rtpmap:97 mpeg4-generic/8000/2
a=fmtp:97 streamtype=5;profile-level-id=1;cpresent=0;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1590
a=control:trackID=2

Failed to parse interval end specification ''
[rtsp @ 0x1298440] video codec set to: h264
[rtsp @ 0x1298440] RTP Packetization Mode: 1
[rtsp @ 0x1298440] RTP Profile IDC: 64 Profile IOP: 0 Level: 1f
[rtsp @ 0x1298440] Extradata set to 0x1298a20 (size: 23)
[rtsp @ 0x1298440] audio codec set to: aac
[rtsp @ 0x1298440] audio samplerate set to: 8000
[rtsp @ 0x1298440] audio channels set to: 2
[udp @ 0x129e7e0] end receive buffer size reported is 131072
[udp @ 0x129e680] end receive buffer size reported is 131072
[udp @ 0x12bf380] end receive buffer size reported is 131072
[udp @ 0x12bf1c0] end receive buffer size reported is 131072
[rtsp @ 0x1298440] hello state=0
[rtsp @ 0x1298440] UDP timeout, retrying with TCP
[rtsp @ 0x1298440] hello state=0
[rtsp @ 0x1298440] Could not find codec parameters for stream 0 (Video: h264, 1 reference frame, none(left), 1280x720, 1/180000): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://10.132.193.9//ch0.h264':
  Metadata:
    title           : H.264 Program Stream, streamed by the LIVE555 Media Server
    comment         : ch0.h264
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 0, 1/90000: Video: h264, 1 reference frame, none(left), 1280x720, 1/180000, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1, 0, 1/8000: Audio: aac, 8000 Hz, stereo, fltp
Successfully opened the file.
Parsing a group of options: output url latest.jpg.
Applying option f (force format) with argument image2.
Successfully parsed a group of options.
Opening an output file: latest.jpg.
Successfully opened the file.
detected 1 logical cores
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'pix_fmt' to value '-1'
[buffer @ 0x12f9680] Unable to parse option value "-1" as pixel format
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'time_base' to value '1/90000'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'frame_rate' to value '180000/2'
[buffer @ 0x12f9680] Unable to parse option value "-1" as pixel format
[buffer @ 0x12f9680] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x1298280] Error applying options to the filter.
Error opening filters!
Exiting normally, received signal 2.

如您所见,ffmpeg能够读取SDP元数据,但由于某种原因无法保存屏幕截图

同样的命令在我的笔记本电脑上使用相同的VPN配置也能正常工作!

以防万一,IP摄像机没有公共IP地址,可通过VPN访问。

可能出现什么问题以及如何调试?

我尝试将-analyzeduration-probesize选项从默认的5s增加到30s,但它不起作用。

2 个答案:

答案 0 :(得分:1)

如果您看到..输出包含以下问题:

Failed to parse interval end specification ''

因此,ffmpeg无法找到搜索rtp流的开始和结束时间范围。它没有找到所有必需的参数(可能已损坏)。所以,我希望从thisthis讨论中为你的ffmpeg命令添加一些以下标志会很有帮助。

-pix_fmt yuv420p or -analyzeduration 2147483647 (some huge value)

答案 1 :(得分:0)

这是防火墙的问题。 service ufw stop和现在ffmpeg工作得很好!