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

How to play rtmp stream without audio in Exoplayer? #6719

Closed khyatiChitroda closed 4 years ago

khyatiChitroda commented 4 years ago

I am integrating Exoplayer into my application and into this I am getting problem when I am trying to play video without audio it can not play, but if I am enabling the audio it will play the video properly, my code :

player = ExoPlayerFactory.newSimpleInstance(this, trackSelector)

val playerView = findViewById<PlayerView>(R.id.simple_player)
playerView.player = player
val rtmpDataSourceFactory = RtmpDataSourceFactory()
val url = mVideoPath
val videoSource = ExtractorMediaSource.Factory(rtmpDataSourceFactory)
  .createMediaSource(Uri.parse(url))

player.prepare(videoSource)

player.playWhenReady = true
kim-vde commented 4 years ago

Please provide the video path (with and without audio) as described here.

khyatiChitroda commented 4 years ago

PLease check mail, I had sent you url, once you check let me know I will add audio into that

kim-vde commented 4 years ago

ExoPlayer fails with the following stack trace when trying to open the rtmp url:

net.butterflytv.rtmp_client.RtmpClient$RtmpIOException: RTMP error: -3
        at net.butterflytv.rtmp_client.RtmpClient.open(RtmpClient.java:222)
        at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:49)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:177)
        at com.google.android.exoplayer2.upstream.cache.CacheDataSource.openNextSource(CacheDataSource.java:462)
        at com.google.android.exoplayer2.upstream.cache.CacheDataSource.open(CacheDataSource.java:286)
        at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
        at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:961)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:394)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

There is probably something wrong with the url or with the file because it also fails to play with ffplay.

khyatiChitroda commented 4 years ago

if you will try with VLC it will work properly, and even if I will add audio into this url then also it will working properly, you just try now I had enabled audio.

kim-vde commented 4 years ago

I still get the same error with ExoPlayer and with ffplay.

Note that, when trying to play the file with ExoPlayer, the error is not thrown by ExoPlayer but by net.butterflytv.rtmp_client.RtmpClient, which indicates that there is probably something wrong with the url.

I also tried with VLC (version 3.0.8) and got the following error: "Your input can't be opened: VLC is unable to open the MRL ''. Check the log for details." And in the logs "avio error: Failed to open : Operation not permitted".

What version of VLC are you using? Do you use Media > Open Network Stream to play the file?

khyatiChitroda commented 4 years ago

try this,

actually everyday we expired our links for security purpose,

please try this one

rtmp://media1.ambicam.com:1938/dvr30/f9cf7e97-3fcf-4a9d-a7be-dd9ddbaa73f4

Sorry for inconvenience

On Wed, Dec 4, 2019 at 5:09 PM kim-vde notifications@github.com wrote:

I still get the same error with ExoPlayer and with ffplay.

Note that, when trying to play the file with ExoPlayer, the error is not thrown by ExoPlayer but by net.butterflytv.rtmp_client.RtmpClient, which indicates that there is probably something wrong with the url.

I also tried with VLC (version 3.0.8) and got the following error: "Your input can't be opened: VLC is unable to open the MRL ''. Check the log for details." And in the logs "avio error: Failed to open : Operation not permitted".

What version of VLC are you using? Do you use Media > Open Network Stream to play the file?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/ExoPlayer/issues/6719?email_source=notifications&email_token=AEGTBGDQKTSYFTR5XQAOAPDQW6JIBA5CNFSM4JUTCVU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF4XDWI#issuecomment-561607129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGTBGGBAZ7FNIUDIJ6NNPDQW6JIBANCNFSM4JUTCVUQ .

kim-vde commented 4 years ago

I can play this URL with ExoPlayer without problem.

Can you do it as well? Did you build you app with the ExoPlayer RTMP extension?

umangsaini commented 4 years ago

Multiple RTMP issues were resolved with the release of v2.10.5. Older versions may have the issue described. Latest ExoPlayer uses the fixed version of RTMP library - net.butterflytv.utils:rtmp-client:3.1.0.

Regarding audio, in the Demo application, I am able to disable audio track from the "Select Tracks" menu, and video-only playback continues as expected.

Which version of Exoplayer are you working with, and have you tried disabling audio in the Demo Application?

ExoPlayer_Rtmp_Video_Only

khyatiChitroda commented 4 years ago

I am using extension rtmp and library - net.butterflytv.utils:rtmp-client:3.1.0. same as you said,

PFA, for my demo

https://drive.google.com/file/d/1WSbIJgTY9b3As-W1NM3F_WP11seP5PXR/view?usp=sharing

On Wed, Dec 4, 2019 at 10:47 PM Umang Saini notifications@github.com wrote:

Multiple RTMP issues were resolved with the release of v2.10.5. Older versions may have the issue described. Latest ExoPlayer uses the fixed version of RTMP library - net.butterflytv.utils:rtmp-client:3.1.0.

Regarding audio, in the Demo application, I am able to disable audio track from the "Select Tracks" menu, and video-only playback continues as expected.

Which version of Exoplayer are you working with, and have you tried disabling audio in the Demo Application?

[image: ExoPlayer_Rtmp_Video_Only] https://user-images.githubusercontent.com/51775549/70164896-01676b00-16e8-11ea-9ee7-605bca053df1.jpg

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/ExoPlayer/issues/6719?email_source=notifications&email_token=AEGTBGA4FJCRHEHHKCM5NH3QW7Q25A5CNFSM4JUTCVU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF5YPBY#issuecomment-561743751, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGTBGHHZJTUZKQZDO5CSYTQW7Q25ANCNFSM4JUTCVUQ .

umangsaini commented 4 years ago

The RTMP content URL your demo app is trying to play is not video-only. It's FLV header is advertising both audio and video tracks, which is why ExoPlayer will not play the same.

Refer to this link and its solution.

Your FLV header should say only video track present for Exoplayer to play the same. Below is a screenshot of FLVExtractor showing hasAudio flag is true, even when audio track is not present.

RTMP_Video_Only

khyatiChitroda commented 4 years ago

okay Thank you for your response, I need to talk with my team member for this, as we have to done changes into our URL side.