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: can't open stream from OBS #10944

Open ArtRoman opened 1 year ago

ArtRoman commented 1 year ago

ExoPlayer can't open RTSP stream from OBS Studio with "OBS-RTSP Server" plugin. Nothing happens, only these http headers appears in logcat:

RtspClient: OPTIONS rtsp://192.168.1.10:8554/live RTSP/1.0
RtspClient: User-Agent: ExoPlayerLib/2.18.2
RtspClient: CSeq: 0
RtspClient: 
RtspClient: RTSP/1.0 200 OK
RtspClient: CSeq: 0
RtspClient: Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY
RtspClient: DESCRIBE rtsp://192.168.1.10:8554/live RTSP/1.0
RtspClient: User-Agent: ExoPlayerLib/2.18.2
RtspClient: CSeq: 1
RtspClient: 

Can it be related to headers issue? (https://github.com/google/ExoPlayer/issues/10919)

VLC player opens the steam OK on desktop player and Android devices (both real device and emulator).

Repro: Run OBS Studio 29.0.0 with OBS-RTSP Server plugin https://github.com/iamscottxu/obs-rtspserver/releases I'm using v3.0.0-beta3 which is required for OBS 29 on macOS. I think stable version 2.3.0 with previous versions of OBS will do same.

Run OBS, add anything to sources (I'm using macOS screen capture) Set encoding in Settings - Output (I'm using H264 Hardware encoder, rescale to 720p, 5000 Kbps CBR, high profile) Open Tools - RTSP Server, disable Multicast, press Start.

Try to open rtsp://192.168.1.10:8554/live in ExoPlayer (replace IP-address to yours):

ExoPlayer.Builder(requireContext())
            .build()
            .apply {
                val mediaSource = RtspMediaSource.Factory()
                    .setDebugLoggingEnabled(true)
                    //.setForceUseRtpTcp(true)
                    .createMediaSource(MediaItem.fromUri("rtsp://192.168.1.10:8554/live"))

                addListener(playerListener)

                setVideoTextureView(view?.findViewById(R.id.live_texture_view))
                setMediaSource(mediaSource)
                prepare()
                play()
            }

Checked on Emulator running Android 11 (API 30) arm64-v8a and Tinkerboard S running Android 7 with ExoPlayer library 2.18.2

claincly commented 1 year ago

It seems the RTSP server did not respond to the DESCRIBE request. I wonder if VLC is able to play the stream? If so can you take a look at the VLC log to see the RTSP message transfers? (to turn on VLC logging)

Can it be related to headers issue? (https://github.com/google/ExoPlayer/issues/10919)

Maybe, but I'd guess is less likely, can't say for sure though. Can you also try the method that we suggested there?

ArtRoman commented 1 year ago

VLC is able to open stream with no problem. Enable logs doesn't help because even with debugging level log file doesn't contain http headers, "Messages" window too.

Launching VLC from command line with "-vvv" param did the right thing:

~ % /Applications/VLC.app/Contents/MacOS/VLC -vvv rtsp://192.168.1.53:8554/live
VLC media player 3.0.18 Vetinari (revision 3.0.18-0-ge9eceaed4d)
Opening connection to 192.168.1.53, port 8554...
...remote connection opened
Sending request: OPTIONS rtsp://192.168.1.53:8554/live RTSP/1.0
CSeq: 2
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)

Received 78 new bytes of response data.
Received a complete OPTIONS response:
RTSP/1.0 200 OK
CSeq: 2
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY

Sending request: DESCRIBE rtsp://192.168.1.53:8554/live RTSP/1.0
CSeq: 3
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)
Accept: application/sdp

Received 210 new bytes of response data.
Received a complete DESCRIBE response:
RTSP/1.0 200 OK
CSeq: 3
Content-Length: 130
Content-Type: application/sdp

v=0
o=- 91674741728 1 IN IP4 192.168.1.53
t=0 0
a=control:*
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000

a=control:track0

Sending request: SETUP rtsp://192.168.1.53:8554/live/track0 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)
Transport: RTP/AVP;unicast;client_port=64416-64417

Received 120 new bytes of response data.
Received a complete SETUP response:
RTSP/1.0 200 OK
CSeq: 4
Transport: RTP/AVP;unicast;client_port=64416-64417;server_port=26900-26901
Session: 19624

Sending request: PLAY rtsp://192.168.1.53:8554/live RTSP/1.0
CSeq: 5
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)
Session: 19624
Range: npt=0.000-

Received 75 new bytes of response data.
Received a complete PLAY response:
RTSP/1.0 200 OK
CSeq: 5
Range: npt=0.000-
Session: 19624; timeout=60

2023-01-26 20:02:08.733 VLC[23995:11388090] Can't find app with identifier com.apple.iTunes
2023-01-26 20:02:11.963 VLC[23995:11388090] Can't find app with identifier com.apple.iTunes
Sending request: TEARDOWN rtsp://192.168.1.53:8554/live RTSP/1.0
CSeq: 6
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)
Session: 19624

Also attaching generated log file: vlc.log