androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.71k stars 408 forks source link

RTSP missing attribute fmtp #901

Open coocoricodev opened 11 months ago

coocoricodev commented 11 months ago

Hello,

I'm attempting to play a camera stream using ExoPlayer, but I'm encountering an issue.

My code is very simple :

    val mediaSource: MediaSource = RtspMediaSource.Factory()
        .setDebugLoggingEnabled(true)
        .createMediaSource(MediaItem.fromUri("rtsp://user:password@camera.domain.com:14500"))

    val exoPlayer = ExoPlayer.Builder(context).build()
    exoPlayer.setMediaSource(mediaSource)
    exoPlayer.prepare()
    exoPlayer.playWhenReady = true

I'm facing the same problem with two models of Hikvision cameras. The connection and authentication work well, but the DESCRIBE operation fails due to the absence of the "fmtp" attribute. I've tested other apps using ExoPlayer, and the stream functions correctly. So I believe I may have missed something in my configuration.

Debug Log From RtspMediaSource :

OPTIONS rtsp://camera.domain.com:14500 RTSP/1.0
User-Agent: AndroidXMedia3/1.2.0
CSeq: 0

RTSP/1.0 200 OK
CSeq: 0
Public: OPTIONS, DESCRIBE, PLAY, PAUSE, SETUP, TEARDOWN, SET_PARAMETER, GET_PARAMETER
Date:  Sun, Feb 28 1971 00:51:09 GMT

DESCRIBE rtsp://camera.domain.com:14500 RTSP/1.0
User-Agent: AndroidXMedia3/1.2.0
CSeq: 1

RTSP/1.0 401 Unauthorized
CSeq: 1
WWW-Authenticate: Digest realm="IP Camera", nonce="xxxxxxxxxxxxxxxxxxxxxxxx", stale="FALSE"
DESCRIBE rtsp://camera.domain.com:14500 RTSP/1.0
Date:  Sun, Feb 28 1971 00:51:09 GMT

DESCRIBE rtsp://camera.domain.com:14500 RTSP/1.0
User-Agent: AndroidXMedia3/1.2.0
CSeq: 2
Authorization: Digest username="user", realm="IP Camera(F9905)", nonce="xxxxxxxxxxxxxxxxxxxxxxxx", uri="rtsp://camera.domain.com:14500", response="yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"

RTSP/1.0 200 OK
CSeq: 2
Content-Type: application/sdp
Content-Base: rtsp://camera.domain.com:14500/
Content-Length: 447

v=0
o=- 36549693291690 36549693291690 IN IP4 192.168.1.104
s=Media Presentation
e=NONE
b=AS:5050
t=0 0
a=control:rtsp://camera.domain.com:14500/
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:5000
a=recvonly
a=x-dimensions:1920,1080
a=control:rtsp://camera.domain.com:14500/trackID=1
a=rtpmap:96 H265/90000
a=Media_header:MEDIAINFO=494D4B48000000000000050000000000000000000000000000000000000000000000000000000000;
a=appversion:1.0

Stack Trace of the ExoPlaybackException

Playback error
androidx.media3.exoplayer.ExoPlaybackException: Source error
  at androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:701)
  at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:677)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loopOnce(Looper.java:201)
  at android.os.Looper.loop(Looper.java:288)
  at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.io.IOException: java.lang.IllegalArgumentException: missing attribute fmtp
  at androidx.media3.exoplayer.rtsp.RtspMediaPeriod$InternalListener.onSessionTimelineRequestFailed(RtspMediaPeriod.java:699)
  at androidx.media3.exoplayer.rtsp.RtspClient.dispatchRtspError(RtspClient.java:334)
  at androidx.media3.exoplayer.rtsp.RtspClient.access$700(RtspClient.java:76)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:694)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:527)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$androidx-media3-exoplayer-rtsp-RtspClient$MessageListener(RtspClient.java:520)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(Unknown Source:4)
  at android.os.Handler.handleCallback(Handler.java:942)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loopOnce(Looper.java:201) 
  at android.os.Looper.loop(Looper.java:288) 
  at android.os.HandlerThread.run(HandlerThread.java:67) 
Caused by: androidx.media3.exoplayer.rtsp.RtspMediaSource$RtspPlaybackException: java.lang.IllegalArgumentException: missing attribute fmtp
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:694) 
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:527) 
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$androidx-media3-exoplayer-rtsp-RtspClient$MessageListener(RtspClient.java:520) 
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(Unknown Source:4) 
  at android.os.Handler.handleCallback(Handler.java:942) 
  at android.os.Handler.dispatchMessage(Handler.java:99) 
  at android.os.Looper.loopOnce(Looper.java:201) 
  at android.os.Looper.loop(Looper.java:288) 
  at android.os.HandlerThread.run(HandlerThread.java:67) 
Caused by: java.lang.IllegalArgumentException: missing attribute fmtp
  at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55)
  at androidx.media3.exoplayer.rtsp.RtspMediaTrack.generatePayloadFormat(RtspMediaTrack.java:282)
  at androidx.media3.exoplayer.rtsp.RtspMediaTrack.<init>(RtspMediaTrack.java:176)
  at androidx.media3.exoplayer.rtsp.RtspClient.buildTrackList(RtspClient.java:366)
  at androidx.media3.exoplayer.rtsp.RtspClient.access$1700(RtspClient.java:76)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.onDescribeResponseReceived(RtspClient.java:728)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:634)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:527) 
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$androidx-media3-exoplayer-rtsp-RtspClient$MessageListener(RtspClient.java:520) 
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(Unknown Source:4) 
  at android.os.Handler.handleCallback(Handler.java:942) 
  at android.os.Handler.dispatchMessage(Handler.java:99) 
  at android.os.Looper.loopOnce(Looper.java:201) 
  at android.os.Looper.loop(Looper.java:288) 
at android.os.HandlerThread.run(HandlerThread.java:67) 

Could you help me to understand the issue ? I'm not sure fmtp attributes is mandatory. I tried to look the other app RTSP frame using Wireshark and the stream works well with the same frame so without fmtp.

Vane101 commented 7 months ago

Same error when using RTSP from Hikvision cameras :

Playback error com.google.android.exoplayer2.ExoPlaybackException: Source error at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:684) at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:660) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:246) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.io.IOException: java.lang.IllegalArgumentException: missing attribute fmtp at com.google.android.exoplayer2.source.rtsp.RtspMediaPeriod$InternalListener.onSessionTimelineRequestFailed(RtspMediaPeriod.java:695) at com.google.android.exoplayer2.source.rtsp.RtspClient.dispatchRtspError(RtspClient.java:330) at com.google.android.exoplayer2.source.rtsp.RtspClient.access$700(RtspClient.java:84) at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:690) at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:523) at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$com-google-android-exoplayer2-source-rtsp-RtspClient$MessageListener(RtspClient.java:516) 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:246)  at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: com.google.android.exoplayer2.source.rtsp.RtspMediaSource$RtspPlaybackException: java.lang.IllegalArgumentException: missing attribute fmtp at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:690)  at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:523)  at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$com-google-android-exoplayer2-source-rtsp-RtspClient$MessageListener(RtspClient.java:516)  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:246)  at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: java.lang.IllegalArgumentException: missing attribute fmtp at com.google.android.exoplayer2.util.Assertions.checkArgument(Assertions.java:62) at com.google.android.exoplayer2.source.rtsp.RtspMediaTrack.generatePayloadFormat(RtspMediaTrack.java:281) at com.google.android.exoplayer2.source.rtsp.RtspMediaTrack.(RtspMediaTrack.java:175) at com.google.android.exoplayer2.source.rtsp.RtspClient.buildTrackList(RtspClient.java:362) at com.google.android.exoplayer2.source.rtsp.RtspClient.access$1700(RtspClient.java:84) at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.onDescribeResponseReceived(RtspClient.java:724) at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:630) at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:523)  at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$com-google-android-exoplayer2-source-rtsp-RtspClient$MessageListener(RtspClient.java:516)  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:246)  at android.os.HandlerThread.run(HandlerThread.java:67) 

Oscar-World commented 5 months ago

I had same error :

Playback error androidx.media3.exoplayer.ExoPlaybackException: Source error at androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:717) at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:693) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.io.IOException: java.lang.IllegalArgumentException: missing attribute fmtp at androidx.media3.exoplayer.rtsp.RtspMediaPeriod$InternalListener.onSessionTimelineRequestFailed(RtspMediaPeriod.java:699) at androidx.media3.exoplayer.rtsp.RtspClient.dispatchRtspError(RtspClient.java:334) at androidx.media3.exoplayer.rtsp.RtspClient.access$700(RtspClient.java:76) at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:694) at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:527) at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$androidx-media3-exoplayer-rtsp-RtspClient$MessageListener(RtspClient.java:520) at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226)  at android.os.Looper.loop(Looper.java:313)  at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: androidx.media3.exoplayer.rtsp.RtspMediaSource$RtspPlaybackException: java.lang.IllegalArgumentException: missing attribute fmtp at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:694)  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:527)  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$androidx-media3-exoplayer-rtsp-RtspClient$MessageListener(RtspClient.java:520)  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)  at android.os.Handler.handleCallback(Handler.java:942)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loopOnce(Looper.java:226)  at android.os.Looper.loop(Looper.java:313)  at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: java.lang.IllegalArgumentException: missing attribute fmtp at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55) at androidx.media3.exoplayer.rtsp.RtspMediaTrack.generatePayloadFormat(RtspMediaTrack.java:282) at androidx.media3.exoplayer.rtsp.RtspMediaTrack.(RtspMediaTrack.java:176) at androidx.media3.exoplayer.rtsp.RtspClient.buildTrackList(RtspClient.java:366) at androidx.media3.exoplayer.rtsp.RtspClient.access$1700(RtspClient.java:76) at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.onDescribeResponseReceived(RtspClient.java:728) at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:634) at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:527)  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$androidx-media3-exoplayer-rtsp-RtspClient$MessageListener(RtspClient.java:520)  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)  at android.os.Handler.handleCallback(Handler.java:942)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loopOnce(Looper.java:226)  at android.os.Looper.loop(Looper.java:313)  at android.os.HandlerThread.run(HandlerThread.java:67) 


Works well on other video players like vlc-android etc. Why do you only need the fmtp attribute in exoplayer? I don't understand.

areehafarooq commented 1 month ago

Facing the same error. Is there any update on this?