bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.56k stars 1.46k forks source link

SDP malformed: sprop-parameter-sets= #861

Closed nanosonde closed 2 years ago

nanosonde commented 2 years ago

Which version are you using?

v0.17.17

Which operating system are you using?

Describe the issue

SDP parameter "sprop-parameter-sets=" is empty.

Describe how to replicate the issue

Convert an MJPEG IP cam stream to RTSP with H264. Run ffmpeg to connect to this server:

ffmpeg -r 15 -i http://10.10.10.22:8080/?action=stream -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -max_muxing_queue_size 1024 -g 15  -tune zerolatency -x264-params keyint=15:min-keyint=15 -f rtsp -rtsp_transport tcp rtsp://localhost:8554/mystream

VLC is able to stream via the provided RTSP URL. Home assisstant however with the RTSP2WEBRTC addon is not able to cope with this reply.

Did you attach the server logs?

Nothing special from the server. No error message.

Did you attach a network dump?

Wireshark with RTSP filter:

Session Description Protocol
    Session Description Protocol Version (v): 0
    Owner/Creator, Session Id (o): - 0 0 IN IP4 127.0.0.1
    Session Name (s): Stream
    Connection Information (c): IN IP4 0.0.0.0
    Time Description, active time (t): 0 0
    Media Description, name and address (m): video 0 RTP/AVP 96
    Media Attribute (a): rtpmap:96 H264/90000
        Media Attribute Fieldname: rtpmap
        Media Format: 96
        MIME Type: H264
        Sample Rate: 90000
    Media Attribute (a): fmtp:96 packetization-mode=1; sprop-parameter-sets=
        Media Attribute Fieldname: fmtp
        Media Format: 96 [H264]
        Media format specific parameters: packetization-mode=1
        Media format specific parameters: sprop-parameter-sets=
            NAL unit 1 string: 
            NAL unit: <MISSING>
            [Malformed Packet: SDP]
                [Expert Info (Error/Malformed): Malformed Packet (Exception occurred)]
                    [Malformed Packet (Exception occurred)]
                    [Severity level: Error]
                    [Group: Malformed]
    Media Attribute (a): control:trackID=0
        Media Attribute Fieldname: control
        Media Attribute Value: trackID=0
aler9 commented 2 years ago

Hello, it's the publisher responsibility to fill sprop-parameter-sets. If it's empty, it means that ffmpeg didn't fill it.

Unfortunately it's quite common to deal with H264 tracks that have an empty sprop-parameter-sets (see #787 #715) for various reasons - it may be caused be a defective software/firmware or by choice since parameters may change during time.

In the near future the server will fill sprop-parameter-sets according to the last received SPS and PPS, but anyway, your client (RTSP2WEBRTC) should be edited to get SPS and PPS from the H264 NALUs, not from sprop-parameters-set.

aler9 commented 2 years ago

I can confirm that your command line makes ffmpeg send to the server an SDP without sprop-parameters-set:

v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.76.100
m=video 0 RTP/AVP 96
b=AS:600
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1
a=control:streamid=0
nanosonde commented 2 years ago

Thanks for the explanation.

I have added "-flags +global_header" as output option and now the SDP contains the sprop-parameter-sets. However, I had to remove the option "-tune zerolatency" to get a proper video. With the mentioned option approx,. 2/3 of the video frame was distorted.

Now it works with both VLC and RTSP2WebRTC.

github-actions[bot] commented 1 year ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.