can't ingest RTSP stream

richard-vd

New Member
Hi,

WCS doesn't want to take the RTSP stream from my HDMI H.264 encoder device. The RTSP stream plays just fine in VLC. What can I change to get this to work? All configs are default. I tried this on my Debian server, but I get the same result on AWS.

Here is the RTSP communication log from a Wireshark capture. It shows that the SETUP and PLAY steps are missing:

OPTIONS rtsp://163.x.x.x/hdmi2 RTSP/1.0
Host: 163.x.x.x
User-Agent: WebCallServer-5.2.629-dd8778ba58690d19a44ed583cd116650fe511539
CSeq: 2

RTSP/1.0 200 OK
CSeq: 2
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY
Server: RtspServer1.0

DESCRIBE rtsp://163.x.x.x/hdmi2 RTSP/1.0
Host: 163.x.x.x
User-Agent: WebCallServer-5.2.629-dd8778ba58690d19a44ed583cd116650fe511539
CSeq: 3
Accept: application/sdp

RTSP/1.0 200 OK
CSeq: 3
Server: RtspServer1.0
Content-Base: rtsp://163.x.x.x/hdmi2
Content-Type: application/sdp
Content-Length: 492

v=0
o=- 18467 41 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
a=control:*
a=range:npt=0-
t=0 0
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=0; packetization-mode=2; sprop-parameter-sets=Z2QAKqwsaoHgCJ+XAG4CAgKAAAADAIAAADJC,aO48sA==;
a=control:trackID=1
m=audio 0 RTP/AVP 97
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 streamtype=5;mode=AAC-hbr;profile-level-id=15;SizeLength=13;IndexLength=3;IndexDeltaLength=3;object=1;cpresent=0;config=1190
a=control:trackID=2



The flashphoner.log file has this "String index out of range: 2" error:

15:32:38,296 INFO RestClient - API-ASYNC-pool-12-thread-6 RECEIVED REST OBJECT <==
URL:http://localhost:8081/apps/EchoApp/publishStream
OBJECT:
{
"nodeId" : "DbnxXbU4HjGDDasKOHLUpHEaG895Za1A@127.0.0.1",
"appKey" : "defaultApp",
"sessionId" : "rtsp://163.x.x.x/hdmi2-738994cd-efbe-404e-ac7a-397f0b1f7560",
"mediaSessionId" : "3091345a-90af-43ae-baeb-6a8726a5a8f2",
"name" : "rtsp://163.x.x.x/hdmi2",
"published" : true,
"hasVideo" : false,
"hasAudio" : true,
"status" : "NEW",
"record" : false,
"width" : 0,
"height" : 0,
"bitrate" : 0,
"minBitrate" : 0,
"maxBitrate" : 0,
"quality" : 0,
"history" : false,
"gop" : 0,
"fps" : 0,
"audioBitrate" : 0,
"codecImpl" : "",
"transport" : "UDP",
"cvoExtension" : false,
"mediaType" : "pull",
"mediaProvider" : "RTSP"
}
15:32:38,299 INFO RtpVideoConfig - pool-49-thread-1 VideoResolution C 0x0
15:32:38,299 INFO MediaSession - pool-49-thread-1 Stop MediaSession id: 3091345a-90af-43ae-baeb-6a8726a5a8f2
15:32:38,300 INFO MediaSession - pool-49-thread-1 '3091345a-90af-43ae-baeb-6a8726a5a8f2' has been terminated
15:32:38,300 ERROR MediaHandler - pool-49-thread-1 publishStream exception
java.lang.StringIndexOutOfBoundsException: String index out of range: 2
at java.lang.String.substring(String.java:1963)
at com.flashphoner.media.F.A.A.C(Unknown Source)
at com.flashphoner.media.F.A.A.B(Unknown Source)
at com.flashphoner.media.F.A.A.A(Unknown Source)
at com.flashphoner.media.B.N.getMediaDescription(Unknown Source)
at com.flashphoner.media.B.G.A(Unknown Source)
at com.flashphoner.media.B.G.createLocalSdp(Unknown Source)
at com.flashphoner.server.client.handler.wcs4.media.MediaHandlerUtils.setRemoteSDP(Unknown Source)
at com.flashphoner.server.client.handler.wcs4.media.MediaHandlerUtils.createMediaSession(Unknown Source)
at com.flashphoner.server.client.handler.wcs4.media.MediaHandler.publishStream(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.flashphoner.server.client.handler.MediaHandlerProxyCreator$MediaHandlerInvocationHandler.invoke(Unknown Source)
at com.flashphoner.server.client.handler.wcs4.WCS4Handler_$$_jvstb86_0.publishStream(WCS4Handler_$$_jvstb86_0.java)
at com.flashphoner.server.remote.E.D.A(Unknown Source)
at com.flashphoner.D.B.messageReceived(Unknown Source)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(Unknown Source)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(Unknown Source)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(Unknown Source)
at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(Unknown Source)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(Unknown Source)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(Unknown Source)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(Unknown Source)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(Unknown Source)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(Unknown Source)
at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
at org.jboss.netty.channel.socket.nio.NioWorker.read(Unknown Source)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(Unknown Source)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(Unknown Source)
at org.jboss.netty.channel.socket.nio.NioWorker.run(Unknown Source)
at org.jboss.netty.util.ThreadRenamingRunnable.run(Unknown Source)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
15:32:38,301 INFO RestClient - API-ASYNC-pool-12-thread-7 SEND REST OBJECT ==>
 

Max

Administrator
Staff member
It seems WCS can't parse SDP
Code:
v=0
o=- 18467 41 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
a=control:*
a=range:npt=0-
t=0 0
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=0; packetization-mode=2; sprop-parameter-sets=Z2QAKqwsaoHgCJ+XAG4CAgKAAAADAIAAADJC,aO48sA==;
a=control:trackID=1
m=audio 0 RTP/AVP 97
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 streamtype=5;mode=AAC-hbr;profile-level-id=15;SizeLength=13;IndexLength=3;IndexDeltaLength=3;object=1;cpresent=0;config=1190
a=control:trackID=2
We raise ticket WCS-2780. Will check SDP parsing and report.
Please provide public RTSP URL. Then we will be able to connect to the camera and test directly.
 

Max

Administrator
Staff member
We tried to connect to RTSP URL provided, but all connection attempts are failed with exception
Code:
08:27:07,913 WARN  annelUpstreamHandler - pool-45-thread-1 EXCEPTION, please implement com.flashphoner.rtsp.RtspResponseHandler.exceptionCaught() for proper handling.
java.io.IOException: Connection reset by peer
So please check your RTSP camera, or provide 24/7 access to the stream, or, if this is not possible for some reason, collect a report including traffic dump as described here. The traffic dump should be collected on WCS as follows:
1. Start traffic dump collection
Code:
sudo tcpdump -npi any -B 10240 -w log.pcap
2. Try to play RTSP stream, make sure the problem is reproduced
3. Stop traffic dump collection
Then send us logs ant traffic dump archive using the following link. If the archive size is greater than 20 M, place it to some cloud drive and send us the link to download.
 

richard-vd

New Member
Network issue, sorry. The test stream is now available for you.
Please try again using the same RTSP URL.

I can view the stream from an external IP using ffmpeg:
Code:
# ffmpeg -v verbose -i rtsp://77.x.x.x:yyy/hdmi2 -c copy test15.mp4
ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  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
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[tcp @ 0x563b8d45bb00] Starting connection attempt to 77.x.x.x port yyy
[tcp @ 0x563b8d45bb00] Successfully connected to 77.x.x.x port yyy
[rtsp @ 0x563b8d459800] SDP:
v=0
o=- 18467 41 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
a=control:*
a=range:npt=0-
t=0 0
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=0; packetization-mode=2; sprop-parameter-sets=Z2QAKqwsaoHgCJ+XAG4CAgKAAAADAIAAADJC,aO48sA==;
a=control:trackID=1
m=audio 0 RTP/AVP 97
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 streamtype=5;mode=AAC-hbr;profile-level-id=15;SizeLength=13;IndexLength=3;IndexDeltaLength=3;object=1;cpresent=0;config=1190
a=control:trackID=2


[rtsp @ 0x563b8d459800] Interleaved RTP mode is not supported yet.
[rtsp @ 0x563b8d459800] setting jitter buffer size to 500
    Last message repeated 1 times
[h264 @ 0x563b8d45d180] Reinit context to 1920x1088, pix_fmt: yuvj420p
Input #0, rtsp, from 'rtsp://77.x.x.x:yyy/hdmi2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1920x1080 (1920x1088), 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
Output #0, mp4, to 'test15.mp4':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive, left), 1920x1080 (0x0), q=2-31, 50 fps, 50 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 3365 fps= 50 q=-1.0 Lsize=   26361kB time=00:01:08.09 bitrate=3171.2kbits/s speed=1.02x   
video:25211kB audio:1042kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.408282%
Input file #0 (rtsp://77.x.x.x:yyy/hdmi2):
  Input stream #0:0 (video): 3405 packets read (26136810 bytes);
  Input stream #0:1 (audio): 3193 packets read (1067441 bytes);
  Total: 6598 packets (27204251 bytes) demuxed
Output file #0 (test15.mp4):
  Output stream #0:0 (video): 3365 packets muxed (25816189 bytes);
  Output stream #0:1 (audio): 3193 packets muxed (1067441 bytes);
  Total: 6558 packets (26883630 bytes) muxed
[AVIOContext @ 0x563b8d6a4a00] Statistics: 2 seeks, 106 writeouts
Exiting normally, received signal 2.
 

Max

Administrator
Staff member
Hello,

WCS build with fix for WCS-2780 - 5.2.685. The problem with SDP parsing was due to invalid value of profile-level-id (profile-level-id=0).
 

richard-vd

New Member
I updated from 5.2.784 to 5.2.798 and now the same RTSP stream fails, is this again an SDP parsing issue? The SDP has not changed.
Code:
o=- 18467 41 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
a=control:*
a=range:npt=0-
t=0 0
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=0; packetization-mode=2; sprop-parameter-sets=Z2QAH6wsa4FAFu/8AAQABbgICAoAAAMAAgAAAwDJCA==,aO48sA==;
a=control:trackID=1
m=audio 0 RTP/AVP 97
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 streamtype=5;mode=AAC-hbr;profile-level-id=15;SizeLength=13;IndexLength=3;IndexDeltaLength=3;object=1;cpresent=0;config=1190
a=control:trackID=2
Flashphoner.log shows an exception:

Code:
11:32:39,616 ERROR         MediaHandler - pool-48-thread-1 publishStream exception
java.lang.ArrayIndexOutOfBoundsException: 1
    at com.flashphoner.media.E.B.<init>(Unknown Source)
    at com.flashphoner.media.codec.A.A(Unknown Source)
    at com.flashphoner.media.F.B._(Unknown Source)
    at com.flashphoner.media.F.B.B(Unknown Source)
    at com.flashphoner.media.F.B.A(Unknown Source)
    at com.flashphoner.media.B.G.setRemoteSDP(Unknown Source)
    at com.flashphoner.server.client.handler.wcs4.media.MediaHandlerUtils.setRemoteSDP(Unknown Source)
    at com.flashphoner.server.client.handler.wcs4.media.MediaHandlerUtils.createMediaSession(Unknown Source)
    at com.flashphoner.server.client.handler.wcs4.media.MediaHandler.publishStream(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.flashphoner.server.client.handler.MediaHandlerProxyCreator$MediaHandlerInvocationHandler.invoke(Unknown Source)
    at com.flashphoner.server.client.handler.wcs4.WCS4Handler_$$_jvst4c_0.publishStream(WCS4Handler_$$_jvst4c_0.java)
    at com.flashphoner.server.remote.E.D.A(Unknown Source)
    at com.flashphoner.F.B.messageReceived(Unknown Source)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(Unknown Source)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(Unknown Source)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(Unknown Source)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(Unknown Source)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(Unknown Source)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(Unknown Source)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(Unknown Source)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(Unknown Source)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(Unknown Source)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(Unknown Source)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(Unknown Source)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(Unknown Source)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(Unknown Source)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(Unknown Source)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
 

Max

Administrator
Staff member
We reproduced the issue and raised internal ticket WCS-2952. Will let you know here when fix it. Please keep yor RTSP stream alive to debug.
 

Max

Administrator
Staff member
Good day.
Regarding stream rtsp://*****:*****@**.***.***.21:554/h264/ch1/main/av_stream. This RTSP source send video in MotionJPEG codec:
Code:
v=0
o=- 2208990726 2208990736 IN IP4 127.0.0.1
s=Video Server Session
c=IN IP4 0.0.0.0
t=0 0
a=control:*
a=range:npt=0-
m=video 0 RTP/AVP 26
a=control:trackID=1
WCS does not support this codec. Please use H264 or VP8 codec for video and AAC, G.711 or Speex for audio.
 

Max

Administrator
Staff member
Yes. Someone send the RSTP URL via "Report" button from your thread. Sorry for incovinuence.
 
Top