sakutylev
@sakutylev
junior python developer

Как правильно осуществлять streaming в ffmpeg при захвате потока с rtsp и отдаче его в rtmp?

Проблема при захвате rtsp потока с ip камеры и отдачи его через rtmp и ffmpeg. Просто отдавать в файл получается без проблем, но при использования rtmp выдается ошибка connection refused.
Ниже приведен листинг ffmpeg.
ffmpeg version 2.4.3 Copyright (c) 2000-2014 the FFmpeg developers
  built on Nov 16 2014 14:47:18 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: 
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument 'rtsp://172.16.7.18:554/play1.sdp'.
Reading option '-threads' ... matched as AVOption 'threads' with argument '4'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '704x576'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '25'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '22050'.
Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'.
Reading option 'rtmp://172.16.16.2:1935/live/cam' ... matched as output file.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file rtsp://172.16.7.18:554/play1.sdp.
Successfully parsed a group of options.
Opening an input file: rtsp://172.16.7.18:554/play1.sdp.
[rtsp @ 0x1fafe40] SDP:
v=0
o=CV-RTSPHandler 1123412 0 IN IP4 172.16.7.18
s=Trendnet TV-IP612P
c=IN IP4 0.0.0.0
t=0 0
a=charset:Shift_JIS
a=range:npt=now-
a=control:*
a=etag:1234567890
m=video 0 RTP/AVP 99
a=rtpmap:99 H264/90000
a=fmtp:99 profile-level-id=42A01E;packetization-mode=1;sprop-parameter-sets=Z0IAKOkBYCTYFxIAIPWAAzf5gDYgQlA=,aM44gA==
a=control:trackID=1
m=audio 0 RTP/AVP 0 
a=rtpmap:0 PCMU/8000
a=control:trackID=2
a=sendonly

[rtsp @ 0x1fafe40] video codec set to: h264
[rtsp @ 0x1fafe40] RTP Profile IDC: 42 Profile IOP: a0 Level: 1e
[rtsp @ 0x1fafe40] RTP Packetization Mode: 1
[rtsp @ 0x1fafe40] Extradata set to 0x1fa6be0 (size: 35)!
[rtsp @ 0x1fafe40] audio codec set to: pcm_mulaw
[rtsp @ 0x1fafe40] audio samplerate set to: 8000
[rtsp @ 0x1fafe40] audio channels set to: 1
[udp @ 0x1faf620] end receive buffer size reported is 131072
[udp @ 0x1fc39c0] end receive buffer size reported is 131072
[udp @ 0x1fd4280] end receive buffer size reported is 131072
[udp @ 0x1fd3fc0] end receive buffer size reported is 131072
[rtsp @ 0x1fafe40] hello state=0
[h264 @ 0x1fb2440] no picture 
[rtsp @ 0x1fafe40] All info found
rfps: 24.666667 0.017816
rfps: 24.750000 0.014629
rfps: 24.833333 0.012175
rfps: 24.916667 0.010457
rfps: 25.000000 0.009473
rfps: 25.083333 0.009223
    Last message repeated 1 times
rfps: 25.166667 0.009708
    Last message repeated 1 times
rfps: 25.250000 0.010928
    Last message repeated 1 times
rfps: 25.333333 0.012882
    Last message repeated 1 times
rfps: 25.416667 0.015571
rfps: 25.500000 0.018994
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://172.16.7.18:554/play1.sdp':
  Metadata:
    title           : Trendnet TV-IP612P
  Duration: N/A, start: 0.000000, bitrate: 64 kb/s
    Stream #0:0, 23, 1/90000: Video: h264 (Baseline), yuvj420p(pc), 704x576 [SAR 12:11 DAR 4:3], 1/25, 12.50 fps, 25.08 tbr, 90k tbn, 25 tbc
    Stream #0:1, 14, 1/8000: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
Successfully opened the file.
Parsing a group of options: output file rtmp://172.16.16.2:1935/live/cam.
Applying option s (set frame size (WxH or abbreviation)) with argument 704x576.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 25.
Applying option ar (set audio sampling rate (in Hz)) with argument 22050.
Applying option an (disable audio) with argument 1.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: rtmp://172.16.16.2:1935/live/cam.
[tcp @ 0x210c280] Connection to tcp://172.16.16.2:1935 failed: Connection refused
[rtmp @ 0x210c420] Cannot open connection tcp://172.16.16.2:1935
rtmp://172.16.16.2:1935/live/cam: Connection refused
  • Вопрос задан
  • 8516 просмотров
Пригласить эксперта
Ответы на вопрос 1
ptchol
@ptchol
Linux system administrator
Вроде же написано: 172.16.16.2:1935 failed: Connection refused.
Хост отверг соединение. FFmpeg не умеет выступать rtmp сервером, он может только публиковать поток на указанный Вами destination.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы