google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

RTSP: stream does not play (blackscreen) #9264

Closed holoc285 closed 3 years ago

holoc285 commented 3 years ago

implementation 'com.google.android.exoplayer:exoplayer:2.14.2' implementation 'com.google.android.exoplayer:exoplayer-rtsp:2.14.2'

play: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov cannot play: rtsp://113.163.157.230:9717/rtsph2641080p

Debug Log 2021-08-06 10:13:32.544 8410-8410/com.example.demo D/EventLogger: surfaceSize [eventTime=0.09, mediaPos=0.00, window=0, period=0, 900, 1440] 2021-08-06 10:13:32.547 8410-8410/com.example.demo D/EventLogger: timeline [eventTime=0.09, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE 2021-08-06 10:13:32.547 8410-8410/com.example.demo D/EventLogger: period [?] 2021-08-06 10:13:32.547 8410-8410/com.example.demo D/EventLogger: window [?, seekable=false, dynamic=false] 2021-08-06 10:13:32.547 8410-8410/com.example.demo D/EventLogger: ] 2021-08-06 10:13:32.548 8410-8410/com.example.demo D/EventLogger: loading [eventTime=0.09, mediaPos=0.00, window=0, period=0, true]

Thanks

claincly commented 3 years ago

FYI rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov plays on my end.

Please provide a log of RTSP messages.

Add logs at

https://github.com/google/ExoPlayer/blob/b2333c86c1eac9a1f95992960a8495f1e5b79200/library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMessageChannel.java#L182

and

https://github.com/google/ExoPlayer/blob/b2333c86c1eac9a1f95992960a8495f1e5b79200/library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspClient.java#L423

The easiest way is to use

Log.d("RTSP", message)

holoc285 commented 3 years ago

How can I override this methods to add logs. Thanks

claincly commented 3 years ago

You don't need to override it, adding one line of code Log.d("RTSP", message) to the pointed locations will be sufficient.

holoc285 commented 3 years ago

This methods is read-only. I can't modify.

claincly commented 3 years ago

You can either

claincly commented 3 years ago

You can now use a factory method to enable logging.

See be19624a204682bee73008ffafe09dad397b8a9a

maxxxbar commented 3 years ago

I have the same problem. Logs looks like this.

D/RtspClient: OPTIONS rtsp://113.163.157.230:9717/rtsph2641080p RTSP/1.0
    CSeq: 0
    User-Agent: ExoPlayerLib/2.14.2

D/RtspClient: RTSP/1.0 200 OK
    CSeq: 0
    Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, SET_PARAMETER
D/RtspClient: DESCRIBE rtsp://113.163.157.230:9717/rtsph2641080p RTSP/1.0
    CSeq: 1
    User-Agent: ExoPlayerLib/2.14.2
D/RtspClient: RTSP/1.0 200 OK
    CSeq: 1
    Content-Base: rtsp://113.163.157.230:9717/rtsph2641080p/
    Content-Type: application/sdp
    Content-Length: 444

    v=0
    o=- 1628630486 1628630486 IN IP4 113.163.157.230
    s=RTSP/RTP stream from HDIPCam
    t=0 0
    a=type:broadcast
    a=range:npt=0-
    m=video 0 RTP/AVP 96
    c=IN IP4 0.0.0.0
    a=rtpmap:96 H264/90000
    a=control:track1
    a=fmtp:96 packetization-mode=1; profile-level-id=4D4028; sprop-parameter-sets=Z01AKJpmA8ARPy4C3AQEBQAAAwPoAAB1MOhgBwcAAF9eC7y40MAODgAAvrwXeXCg,aO44gA==
    m=audio 0 RTP/AVP 0
    a=rtpmap:0 PCMU/8000
    c=IN IP4 0.0.0.0
    a=control:track2
D/RtspClient: SETUP rtsp://113.163.157.230:9717/rtsph2641080p/track1 RTSP/1.0
    CSeq: 2
    User-Agent: ExoPlayerLib/2.14.2
    Transport: RTP/AVP;unicast;client_port=46790-46791
D/RtspClient: RTSP/1.0 200 OK
    CSeq: 2
    Session: 467466BB2663D5A2F5CB270008EE01
    Transport: RTP/AVP;unicast;client_port=46790-46791;server_port=46790-46791;ssrc=00000000;mode="PLAY"
D/RtspClient: PLAY rtsp://113.163.157.230:9717/rtsph2641080p RTSP/1.0
    CSeq: 3
    User-Agent: ExoPlayerLib/2.14.2
    Session: 467466BB2663D5A2F5CB270008EE01
    Range: npt=0.000-
D/RtspClient: RTSP/1.0 200 OK
    CSeq: 3
    Session: 467466BB2663D5A2F5CB270008EE01
    Range: npt=0-
    RTP-Info: url=track1;seq=0;rtptime=0, url=track2;seq=0;rtptime=0

...

     Caused by: com.google.android.exoplayer2.ParserException: url=track1;seq=0;rtptime=0
claincly commented 3 years ago

@maxxxbar You see the error is caused by the line

url=track1;seq=0;rtptime=0

In the last message (PLAY response).

In fact, the url field needs to be something like rtsp://113.163.157.230:9717/rtsph2641080p/track1 instead of track1, as required by the spec.

I know VLC does play it, but we don't have the bandwidth to support all quirky servers for now.

What you can try: remove the check for the URL at RtspTrackTiming:L91, and RtspClient:L511-538

maxxxbar commented 3 years ago

@maxxxbar You see the error is caused by the line

url=track1;seq=0;rtptime=0

In the last message (PLAY response).

In fact, the url field needs to be something like rtsp://113.163.157.230:9717/rtsph2641080p/track1 instead of track1, as required by the spec.

I know VLC does play it, but we don't have the bandwidth to support all quirky servers for now.

What you can try: remove the check for the URL at RtspTrackTiming:L91, and RtspClient:L511-538

This remove the error, but it doesn't play

claincly commented 3 years ago

Could you share some log messages?

mmalisz commented 3 years ago

Hi @claincly, I've created a PR that is more of a workaround than a fix, but to avoid removing the tests, it checks if the server response is contains a pre-defined string.

I've covered the track1 case, and my own, where the response is trackID=1.

https://github.com/google/ExoPlayer/pull/9353

google-oss-bot commented 3 years ago

Hey @holoc285. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 3 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@holoc285 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.