Closed IvanovNiko closed 5 years ago
Your very first debug line should give you a clue.
RtspClientSharp.MediaParsers.H264ParserException: Invalid nal unit type: 31
If you look at official RTSP spec nal unit types 24-31 are unspecified. Some RTSP cameras inject (interleaved) meta data into the video stream.
This library throws an exception if the nal unit type is not between 0 and 24, see this line of code here. You can literally comment out the line below it and it should get the video feed fine.
So actually this is a legitimate issue that needs to be fixed, good find. Well maybe not an issue but a part of the library that needs to be expanded upon.
On another note,
Have you done any outside debugging to confirm? For example, connect with VLC and have it output verbose and also check media Codec/Statistics. If you get a good video on VLC then go to FFMPEG, connect with RTSP and have it output verbose. See if it's dropping frames or data, save to file, open file with a media analyzer of some sort and see if the packets parse correctly.
FFmpeg is a tried and true work horse, always use that as a secondary debugging tool.
@DogFive Thank you for help.
Guys, I could offer to ignore this type of NAL's if problem is really connected only with NAL type
I can fix it if you like and submit a PR. I have an idea on how to fix it for now, and you can return it as a meta data packet type later.
On Mon, May 27, 2019, 2:56 AM Kirill notifications@github.com wrote:
@DogFive https://github.com/DogFive Thank you for help.
Guys, I could offer to ignore this type of NAL's if problem is really connected only with NAL type
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BogdanovKirill/RtspClientSharp/issues/33?email_source=notifications&email_token=AAIMVCQQ3HGDTLPGO5RHME3PXOA2XA5CNFSM4HPSWDHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWI6NWQ#issuecomment-496101082, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIMVCVAZP6WNBZYLXPYEMTPXOA2XANCNFSM4HPSWDHA .
@DogFive
Sure
Your very first debug line should give you a clue.
RtspClientSharp.MediaParsers.H264ParserException: Invalid nal unit type: 31
If you look at official RTSP spec nal unit types 24-31 are unspecified. Some RTSP cameras inject (interleaved) meta data into the video stream.
This library throws an exception if the nal unit type is not between 0 and 24, see this line of code here. You can literally comment out the line below it and it should get the video feed fine.
So actually this is a legitimate issue that needs to be fixed, good find. Well maybe not an issue but a part of the library that needs to be expanded upon.
On another note,
Have you done any outside debugging to confirm? For example, connect with VLC and have it output verbose and also check media Codec/Statistics. If you get a good video on VLC then go to FFMPEG, connect with RTSP and have it output verbose. See if it's dropping frames or data, save to file, open file with a media analyzer of some sort and see if the packets parse correctly.
FFmpeg is a tried and true work horse, always use that as a secondary debugging tool.
Hi guyes.
@DogFive I tryied to comment this line but it is not solved my problem. Yes, i have not issue with invalid NAL type, but i also have the rest issues: 1) RtspClientSharp.Rtsp.RtspClientException: Receive error ---> System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. at System.ArraySegment1..ctor(T[] array, Int32 offset, Int32 count) at RtspClientSharp.MediaParsers.H264VideoPayloadParser.ParseMTAP(DateTime frameTimestamp, ArraySegment1 byteSegment, Int32 tsOffsetFieldSize, Boolean markerBit) at RtspClientSharp.MediaParsers.H264VideoPayloadParser.Parse(TimeSpan timeOffset, ArraySegment1 byteSegment, Boolean markerBit) at RtspClientSharp.Rtp.RtpStream.ProcessImmediately(RtpPacket& rtpPacket) at RtspClientSharp.Rtp.RtpStream.Process(ArraySegment1 payloadSegment)
2) recieve timeout exception thrown because no frames parsed and RtspClient.FrameReceived event is not called
I connect to camera by VLC player and it is good worked, video displayed as expected.
I am not tried to debug stream with ffmpeg tool. I will try it, but i am not expert with ffmpeg and possible it will take more time than i expect.
@BogdanovKirill could you help me to resolve this issues with camera? Maybe you have any ideas how to solve this issues? Why FrameReceived event not called?
I am using 1.2.6 library version. Did some issues was fixed in new version maybe?
@IvanovNiko
Could you change RTP transport protocol from UDP to TCP and test? Or from TCP to UDP? Is it possible to give me access to that camera? (you can mail me to bogdanov.kv@bk.ru)
Thank you all for help. Problem was found and fixed. It was connected with additional space in SDP answer in media line.
Fixed here: https://github.com/BogdanovKirill/RtspClientSharp/commit/04f5abfd798536e770d4b7887e4ed32067844fd0
New version 1.2.8 was released. Please reopen if required.
Thank you all for help. Problem was found and fixed. It was connected with additional space in SDP answer in media line.
Fixed here: 04f5abf
New version 1.2.8 was released. Please reopen if required.
Thank you, Kirill. You made great and fast job. My problem was solved.
I connect to VStarcam C8824WIP IP-camera via RTSP and i got several errors when recieve frames
1) First error RtspClientSharp.Rtsp.RtspClientException: Receive error ---> RtspClientSharp.MediaParsers.H264ParserException: Invalid nal unit type: 31 at RtspClientSharp.MediaParsers.H264Parser.ProcessNalUnit(DateTime frameTimestamp, ArraySegmentd33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RtspClientSharp.Rtsp.RtspClientInternal.d 18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RtspClientSharp.RtspClient.d14.MoveNext()
--- End of inner exception stack trace ---
at RtspClientSharp.RtspClient.d 14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
1 byteSegment, Boolean hasStartMarker, Boolean generateFrame) at RtspClientSharp.MediaParsers.H264Parser.Parse(DateTime frameTimestamp, ArraySegment
1 byteSegment, Boolean dontSliceForce, Boolean generateFrame) at RtspClientSharp.MediaParsers.H264VideoPayloadParser.ParseFU(DateTime frameTimestamp, ArraySegment1 byteSegment, Int32 donFieldSize, Boolean markerBit) at RtspClientSharp.MediaParsers.H264VideoPayloadParser.Parse(TimeSpan timeOffset, ArraySegment
1 byteSegment, Boolean markerBit) at RtspClientSharp.Rtp.RtpStream.ProcessImmediately(RtpPacket& rtpPacket) at RtspClientSharp.Rtp.RtpStream.Process(ArraySegment`1 payloadSegment) at RtspClientSharp.Rtsp.RtspClientInternal.2) second error RtspClientSharp.Rtsp.RtspClientException: Receive error ---> System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. at System.ArraySegmentd33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RtspClientSharp.Rtsp.RtspClientInternal.d 18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RtspClientSharp.RtspClient.d14.MoveNext()
--- End of inner exception stack trace ---
at RtspClientSharp.RtspClient.d 14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
1..ctor(T[] array, Int32 offset, Int32 count) at RtspClientSharp.MediaParsers.H264VideoPayloadParser.ParseMTAP(DateTime frameTimestamp, ArraySegment
1 byteSegment, Int32 tsOffsetFieldSize, Boolean markerBit) at RtspClientSharp.MediaParsers.H264VideoPayloadParser.Parse(TimeSpan timeOffset, ArraySegment1 byteSegment, Boolean markerBit) at RtspClientSharp.Rtp.RtpStream.ProcessImmediately(RtpPacket& rtpPacket) at RtspClientSharp.Rtp.RtpStream.Process(ArraySegment
1 payloadSegment) at RtspClientSharp.Rtsp.RtspClientInternal.3) When scene is not changed infront of camera i get timeout exception
RtspClientSharp.Rtsp.RtspClientException: Receive timeout ---> System.TimeoutException: The operation has timed out. --- End of inner exception stack trace --- at RtspClientSharp.RtspClient.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()