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.7k stars 6.02k forks source link

RTSP Playback error: "Server did not provide timing for track" #9664

Closed bianchina3 closed 2 years ago

bianchina3 commented 2 years ago

i am trying to connect to an ip camera but exoplayer 2.16.0 throws "Server did not provide timing for track" exception.

This is the log:

2021-11-06 19:32:58.671 12292-12318/com.example.rtspexogoole D/RtspClient: OPTIONS rtsp://192.168.0.110:554/1 RTSP/1.0
    User-Agent: ExoPlayerLib/2.16.0
    CSeq: 0
2021-11-06 19:32:58.790 12292-12318/com.example.rtspexogoole D/RtspClient: RTSP/1.0 200 OK
    CSeq: 0
    Server: Hipcam RealServer/V1.0
    Public: OPTIONS,DESCRIBE,SETUP,TEARDOWN,PLAY,SET_PARAMETER,GET_PARAMETER

2021-11-06 19:32:58.793 12292-12318/com.example.rtspexogoole D/RtspClient: DESCRIBE rtsp://192.168.0.110:554/1 RTSP/1.0
    User-Agent: ExoPlayerLib/2.16.0
    CSeq: 1
2021-11-06 19:32:58.918 12292-12318/com.example.rtspexogoole D/RtspClient: RTSP/1.0 200 OK
    CSeq: 1
    Server: Hipcam RealServer/V1.0
    Content-Type: application/sdp
    Cache-Control: must-revalidate
    Content-length: 430
    Content-Base: rtsp://192.168.0.110:554/1/

    v=0
    o=StreamingServer 3331435948 1116907222000 IN IP4 192.168.0.110
    s=10
    c=IN IP4 0.0.0.0
    t=0 0
    a=control:*
    m=video 0 RTP/AVP 96
    a=control:trackID=0
    a=rtpmap:96 H264/90000
    a=fmtp:96 packetization-mode=1;profile-level-id=4D002A;sprop-parameter-sets=R00AH5mwFAFuhAAAD6AAAnECEA==,SOpDyA==
    a=framesize:96 1280-720
    m=audio 0 RTP/AVP 8
    a=control:trackID=1
    a=rtpmap:8 PCMA/8000/1
    a=ptime:20
    a=fmtp:8 packetization-mode=1

2021-11-06 19:32:59.029 12292-12318/com.example.rtspexogoole D/RtspClient: SETUP rtsp://192.168.0.110:554/1/trackID=0 RTSP/1.0
    User-Agent: ExoPlayerLib/2.16.0
    CSeq: 2
    Transport: RTP/AVP/TCP;unicast;interleaved=0-1
2021-11-06 19:32:59.142 12292-12318/com.example.rtspexogoole D/RtspClient: RTSP/1.0 200 OK
    CSeq: 2
    Server: Hipcam RealServer/V1.0
    Session: NjNtYlzJORS
    Transport: RTP/AVP/TCP;unicast;interleaved=0-1

2021-11-06 19:32:59.146 12292-12318/com.example.rtspexogoole D/RtspClient: PLAY rtsp://192.168.0.110:554/1 RTSP/1.0
    User-Agent: ExoPlayerLib/2.16.0
    CSeq: 3
    Session: NjNtYlzJORS
    Range: npt=0.000-
2021-11-06 19:32:59.258 12292-12318/com.example.rtspexogoole D/RtspClient: RTSP/1.0 200 OK
    CSeq: 3
    Server: Hipcam RealServer/V1.0
    Session: NjNtYlzJORS
    RTP-Info:url=192.168.0.110/trackID=0;seq=1;rtptime=10000,url=192.168.0.110/trackID=1;seq=1;rtptime=10000

2021-11-06 19:32:59.270 12292-12318/com.example.rtspexogoole E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: Source error
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:628)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:223)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: com.google.android.exoplayer2.source.rtsp.RtspMediaSource$RtspPlaybackException: Server did not provide timing for track rtsp://192.168.0.110:554/1/trackID=0
        at com.google.android.exoplayer2.source.rtsp.RtspMediaPeriod$InternalListener.onPlaybackStarted(RtspMediaPeriod.java:518)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.onPlayResponseReceived(RtspClient.java:688)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:607)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:494)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$com-google-android-exoplayer2-source-rtsp-RtspClient$MessageListener(RtspClient.java:487)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
christosts commented 2 years ago

@claincly can you take a look?

claincly commented 2 years ago

You can try commenting out the lines 515-523 in RtspMediaPeriod.

The problem is the server response

RTP-Info:url=192.168.0.110/trackID=0;seq=1;rtptime=10000,url=192.168.0.110/trackID=1;seq=1;rtptime=10000

should be

RTP-Info:url=192.168.0.110/1/trackID=0;seq=1;rtptime=10000,url=192.168.0.110/1/trackID=1;seq=1;rtptime=10000
bianchina3 commented 2 years ago

Thanks for the reply. your proposal patch works, but for me it's frustrating to work with patching code

claincly commented 2 years ago

I understand your frustration having to patch the code, but please note that this is a error in the server.

By RTSP spec, the RTP-Info header in RTSP PLAY response should include timing info for both audio and video tracks, in your case they are identified as

But the server responded with wrong identifiers, for example for video: url=192.168.0.110/trackID=0. It's missing two parts:

  1. The rtsp:// scheme. Note that the uri 192.168.0.110/trackID=0 is not technically a "URL" without the scheme part.
  2. The 1/ path after the ip address

ExoPlayer is following the spec and does not make exceptions for quirky servers. That said, I'm closing the issue for now, please reopen if you have further questions.