-
Notifications
You must be signed in to change notification settings - Fork 48
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
Exiting because of bad sps #68
Comments
Maybe this can provide some context Running `target/debug/client info --url 'rtsp://192.168.10.10' --print-streams --print-sdp`
SDP:
v=0
s=streamed by the macro-video rtsp server
t=0 0
a=control:*
a=range:npt=0-
a=x-qt-text-nam:streamed by the macro-video rtsp server
c=IN IP4 0.0.0.0
m=video 0 RTP/AVP 96
b=AS:500
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=TQAf;packetization-mode=1;sprop-parameter-sets=J00AH+dAKALdgKUFBQXwAAADABAAAAMCiwEAAtxoAAIlUX//AoA=,KO48gA==
a=control:track1
stream 0:
Stream {
media: "video",
control: Some(
"rtsp://192.168.10.10/track1",
),
encoding_name: "h264",
rtp_payload_type: 96,
clock_rate: 90000,
channels: None,
framerate: None,
depacketizer: Ok(
Depacketizer(
H264(
Depacketizer {
input_state: New,
pending: None,
parameters: Some(
InternalParameters {
generic_parameters: VideoParameters {
rfc6381_codec: "avc1.4D001F",
pixel_dimensions: (
1280,
720,
),
pixel_aspect_ratio: Some(
(
1,
1,
),
),
frame_rate: Some(
(
2,
40,
),
),
extra_data: Length: 53 (0x35) bytes
0000: 01 4d 00 1f ff e1 00 26 27 4d 00 1f e7 40 28 02 .M.....&'M...@(.
0010: dd 80 a5 05 05 05 f0 00 00 03 00 10 00 00 03 02 ................
0020: 8b 01 00 02 dc 68 00 02 25 51 7f ff 02 80 01 00 .....h..%Q......
0030: 04 28 ee 3c 80 .(.<.,
},
sps_nal: b"'M\0\x1f\xe7@(\x02\xdd\x80\xa5\x05\x05\x05\xf0\0\0\x03\0\x10\0\0\x03\x02\x8b\x01\0\x02\xdch\0\x02%Q\x7f\xff\x02\x80",
pps_nal: b"(\xee<\x80",
},
),
pieces: [],
nals: [],
},
),
),
),
state: Uninit,
}
I20221015 14:49:18.468 main client] Done |
What make/model/version camera is this?
Likely yes, but I'm happy to add workarounds as needed. The SDP you quoted looks fine, as far as I can tell. The SPS there is parseable. And if there were an error in that SDP, Retina should have logged a warning Instead, I think it's struggling with the "in-band parameters" (ones sent in the middle of the RTP data stream, rather than in the SDP). Not sure yet what to do about that. Maybe we could try making it ignore them if it already has valid parameters (as it seems to in this case). We can also improve the logging here to give some more info than It'd help me to see the whole data stream. Would you be able/willing to gather a packet capture with e.g. Wireshark? It could be this Retina run, or maybe better yet some other software talking successfully with this camera (rather than bailing with an error here). The packet capture will have your camera's MAC and such embedded in it, so If you don't want to share it publicly, emailing it to me would be perfectly fine. |
It's a generic V380 camera.
Sure. Let me check if I can capture some relevant data. I have a raspberry pi setup to stream camera's RTSP using VLC. |
I've mailed the wireshark capture to you. Please let me know if it's what you were looking for. I did the following:
I noticed this error pop up a couple of times during startup, as well as exiting in middle of receiving packets ( E20221015 22:44:40.071 main client] Fatal: SPS NAL is 120954 bytes long; must fit in u16 Whenever it does record to EDIT: I also noticed that the error pops up on Also on |
I also noticed when trying to stream HD track, VLC doesn't immediately start showing video. VLC itself starts up but the video comes up a bit after. I don't have knowledge about how the communication works, but maybe it has to do with VLC waiting to get those "in-band params" and after it gets them, it figures out how to stream video. |
The packet capture helped. I have in my working copy a program that chews through it, with improved errors. Here's what it says:
Some background. H.264 streams are divided into messages called "NAL"s (Network Abstraction Layer, which is a weird name for what it is IMHO). A NAL can be encoded in different ways, including:
The H.264 spec defines an encoding (often called "Annex B format") that uses these sequences of zeros to mark the ends of NALs. This is why they're not allowed to appear inside a single encoded NAL. RTSP uses another standard called RTP for its data messages. Different audio/video encodings each have their own RFC to describe how RTP transports them. For H.264, it's RFC 6184. It includes:
It looks like your camera is sending FU-As which contain several encoded NALs:
This isn't what the standard says to do. Retina's behavior recently changed:
To support your camera well, we need to alter Retina's I could work on this. I also see that you have some experience working with networking in Rust. Would you prefer to try it yourself? I'm happy to walk you through it if so. |
Thanks for the detailed response Scott. I'd love to work on this. I did work with networking in Rust a while back, but I wouldn't consider my rust skills to be that good :p Just started re-learning rust. I can try to work on this, with a little bit of hand-holding along the way :D |
Update on the issue. I've managed to throw some code at it and it is now creating an mp4 file that is working! I'll create a PR soon and we can review if there's anything we need to add :) |
Hi, I tried out your crate to check if it works with my outdoor camera. It exits out because of
bad sps
.Is this a problem with how the camera implements RTSP?
Thank you
Output
I20221015 14:37:53.671 main client::mp4] Using h264 video stream I20221015 14:37:53.686 main client::mp4] No suitable audio stream found E20221015 14:37:55.589 main client] Fatal: bad sps conn: 192.168.10.15:53286(me)->192.168.10.10:554@2022-10-15T14:37:53 stream: TCP, interleaved channel ids 0-1 ssrc: 00000000 seq: 00000068 pkt: 150505@2022-10-15T14:37:54
The text was updated successfully, but these errors were encountered: