-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SharpRTSP not working with Janus Gateway #53
Comments
I see janus uses libcurl for RTSP. I've never tested that, but doing some Google searches shows me libcurl had issues with Digest Authentication. Try with an empty username and password Also try with a change from .Digest to .Basic in this code
|
Thank you for your quick answer. I am not using any authentication (password ans username are set to null, this is the only change I made to CameraExample) |
Can you get some Verbose logs from Janus to show me what it is doing, or how far through it gets through the OPTIONS, DESCRIBE, SETUP, PLAY sequence. |
I will post Janus' logs later (no access to them right now), but here are the logs from the RtspCameraExample:
|
Thanks for the logs. This tells me RtspCameraClient is sending the video OK. So we need to check Janus to see what the problem is |
Yes, that was my first thought too, but the stream coming from RtspCameraExample is the only one not working in Janus (any IP Camera will work). So my guess right now is that there is something not totally standard in the stream coming from RtspCameraExample (maybe SDP?) and makes Janus failing the decoding. |
There are a few possible places it can go wrong b) Maybe it does not like the very basic H264 encoder that is being used. It is a very simple encoder with a very large bitstream c) Or maybe it does not like that fact that I am sending the H264 as one large RTP packet and letting the OS fragment a large RTP packet.
and change 'false' to 'true' It is supposed to be 'true'. |
a) I tried with other profile-level-ids, still no result. (4d002a which seems to be the one used in the RTSP stream coming from the IPCamera) b) Originally I was feeding h264 frames coming from an IPCamera, but I am now trying with the original RtspCameraExample to be sure the problem isnt in my modifications. The RTSP stream from the same camera works in Janus. c) I just tried with this code, still no image in Janus:
|
Here are some logs of Janus, those lines keep repeating so I only pasted a few occurrences of them: |
Spoke directly to @lminiero which is the creator & maintainer of Janus Gateway and redirected to this issue, maybe he can see something that we cannot about this problem |
I enabled webrtc logging on chrome here are the logs: seems like this is the problem
test made with RtspCameraExample sdp generated by RtspCameraExample:
|
Hi |
I have a question. You said you are using the raw H264 frames from an IP camera. eg are you using some RTSP client and looking at the received UDP packets? The best way to check your NALs are correct is to write each one to a .264 file, with a 0x00 0x00 0x00 0x01 4 byte header. Then see if you can play with |
Hi, I used 2 ways to get those raw frames: by using RtspClient to get the frames from the RTSP Stream of the IP camera and by requesting them from a VMS. I just tried with the updated SimpleH264Encoder, same result. In Janus' source code, these is a function that detects keyframes, it never detects keyframes when the stream is coming from SharpRTSP.
This is the error in Chrome's webrtc debug:
I just resend the nals I get from RtspClient.Received_NALs using RtspServer.video_source_ReceivedYUVFrame. I suspect the problem to be linked to SPS/PPS, NAL HEADER ? Sadly I dont understand everything below:
Here is my sdp code, I hardcoded it using values i got from RtspClient.Received_SPS_PPS (I tried a lot of stuff on this, like changing profile-level-id, removing sprop-parameter-sets)
|
Let's focus on this code in Janus I've built Janus on a Linux box (raspberry pi) but I don't know how to configure it properly. So I need to do more - eg does it only call that function when you have a client. |
Hello Roger, Thanks a lot for the effort you put in, i'll drop you everything required to make Janus work in a minute |
To make it work correctly you should: you should see errors in the chrome console if all levels logging are enabled, and if you try with the direct rtsp stream from the camera it should work, you can also run Janus like this please do not hesitate if you have any question |
Ok. I've got there. |
To get more precise debugging from chrome, you need to start it with those parameters:
this will output the logs into |
good, if you wanna try with a stream that is working, please run this command:
you should see an endless trailer video with a big bunny |
big buck bunny works |
nice, you should have a setup that is kind of equivalent to ours |
The keyframe detection code is fine for me. It detects RTP packets with raw NALs (so spots fragment type 5 which means an IDR I-frame) and it spots NALs wrapped in a Fragmented Packet (so spots fragment type 28) So no idea why you don't see the Keyframe message, unless you are not passing in NALs correctly. As for Chrome, you are right, it does not show SharpRTSP, even with my recent changes. I'll try and take a look, but am on customer sites the rest of this week and most of next week |
Ok. I have a possible suggestion RtspCameraExample only sends the SPS and PPS in the SDP I would suggest the first step is to get the SPS and PPS into the RTP stream. |
Another thing you will need to implement in RtspCameraExample is to handle the case where there are multiple NALs forming a video frame. Anyway the main thing is that a RTSP Server needs to be passed an Array of NALs and then send thm properly in a way that the RTSP Client can tell that all these NALs are from the same Array of NALs. But RtspCameraExample only handles the case where there is a a single NAL for the whole frame of video. So in the real world it will not work very well as most H264 encoders return lots of small NALs to make a video frame, and it means you have no way to inject the SPS NAL and the PPS NAL. So RtspCameraExample needs to cope with an Array of NALs. You'll be able to read the RtspClientExample to see how it receives RTP packets and forms the Array of NALs. |
Ok. quick update. But, it still does not actually show any video. Maybe it is waiting on RTCP Sender Reports or something else Anyway at least I can see that the next step is to send the SPS and PPS before the KeyFrame to resolve some issues. |
Still on my holidays break, so apologies if I'll be brief. In the Janus Streaming plugin (the one with RTSP support) we just relay media, so there's no transcoding: what we receive from the camera is what we send to the viewers. As such, when the browser fails to decode/render an H.264 stream, it's usually one of two things: broken video, or the SDP advertises an H.264 profile the browser doesn't support. The latter can be fixed by overriding the fmtp property when configuring the streaming mountpoint in Janus, while for the former there's nothing we can do since we don't touch the media. The keyframe method you see is not used much in that plugin, or at all, so it might be useful for debugging, but you shouldn't rely on that much: the logs from Chrome are much more indicative. I see you made some changes where you now send a new SPS/PPS before every keyframe: I think that's the right thing to do, and what I believe most encoders do. I guess you'll want to send the SPS/PPS in the same packet that contains the keyframe NAL, as if an endpoints waits for a keyframe before doing anything and the SPS/PPS precedes that, the SPS/PPS nal may be missed (I seem to remember this being an issue in Janus too the past, but I'm not sure). As to the RTCP Sender Reports, we send them on a regular basis when sending media. |
Hi @lminiero That little keyframe detection logic was good - always handy as a log entry to help tell what a H264 stream is doing. SharpRTSP's Camera Example does not generate any Sender Reports. So did not know if that caused Janus problems if you were waiting on the SR to match the RTP timestamp to Wall Clock time. Anyway will dig on next week when I'm back home |
Hi, thanks again for your help. If I understood everything correctly, I need to send NALU containing SPS/PPS before each keyframe, Do I need to change this part of the code ? Or will also handle NALU containing SPS/PPS ?
Could you push (on a branch?) your changes that lead you to a green screen on janus ? |
Will stick it on a branch at the weekend (unless I get a spare 10 mins today) |
(but yes, that is the right part of the code) |
commit made. |
@REPRESSION is there any news after I made the change to add the SPS and PPS before the I-Frame? |
Hi, sorry for the late reply, I was quite busy the last few days. I'm going to do some tests and I will come back to you with updates and hopefuly a solution. |
I pulled your changes (on master branch) and tested it, I did not get the green screen, I go the same usual white screen - using the CameraExample - with the following logs in chrome:
|
Are you running chrome on windows, Linux or Mac. I use a mac. That may explain the green rectangle. |
we're using windows actually |
you mentioned you had written a program using sharprtsp to pull in video from a remote source (using code from RtspClientExample and then re-distribute it with the code from RtspCameraExample. Could you send me this please so I can re-create a working Janus example. right now I was getting a green screen on the Mac. I also tried another live555 server in the office but failed with the invalid fmpt in the SDP |
PING.... |
Hi, I am having some problems in real life, I won't be able to access my pc until the end of this week. I will send you the code when I get access to my pc later this week. Sorry for the late answer again. |
There is no rush. |
Any update. No problem if you have not had time yet. |
SharpRTSP's CameraExample does not work with Janus. Every other stream i've tested works on Janus.
Is there anything non standard done in SharpRTSP with RTSP streams ? It does work with VLC, live555 RTSP Proxy, KMP, webrtc-streamer (this one transcode from H264 to VP8, Janus does not). I'm struggling with this since a few days, I thought the problem came from UDP (as Janus only support UDP).
Janus' Github: https://github.com/meetecho/janus-gateway
webrtc-streamer's Github: https://github.com/mpromonet/webrtc-streamer
The text was updated successfully, but these errors were encountered: