Skip to content

Merging RTSP stream fails while RTSP alone works #577

Closed

Description

@hasan-mohammadi

I am trying to merge an RTSP stream along with other media sources using a MergingMediaSource, but while the RTSP stream plays correctly by itself, the video fails to render when part of the merged source.

To reproduce:

1.Create RTSP media source:
val rtspSource = RtspMediaSource.Factory().createMediaSource(mediItem)

2.Create MergingMediaSource
val mergingSource = MergingMediaSource(rtspSource, audioSource)

  1. Set merging source on ExoPlayer
  2. Video track fails to render

I have tried:

Simplifying to just RTSP + audio and just RTSP
Confirming audio, text sources merge correctly alone
It seems to be an issue specifically merging this type of RTSP stream, while other formats work fine. Please advise if I am missing anything or if this could be a bug.

Let me know if any other details would be helpful!

Activity

  1. self-assigned this
    on Aug 14, 2023
  2. microkatz commented on Aug 18, 2023

    @microkatz
    Contributor

    Hello @hasan-mohammadi,

    Thank you for reporting your issue! The problem arises from how the encapsulating MergingMediaPeriod queries the RtspMediaPeriod for if it can continue loading data. It got stuck in a never-ending loop as the RtspMediaPeriod.isLoading() only checked if it's loadables finished executing, not if it had sent its RTSP SETUP/PLAY requests.

    I'm working on committing a fix and will update this thread when the fix has been pushed to the main branch.

    In addition, may I ask about why you are using a MergingMediaSource? A requirement is that the media being merged have the same duration. Even after this fix to allow RtspMediaSource with MergingMediaSource, you might still run into some issues in use.

  3. hasan-mohammadi commented on Aug 19, 2023

    @hasan-mohammadi
    Author

    thank you for answering, I'm trying to add external dubb audios and multiple subtitles to the video streamed by RTSP.
    considering I can change the stream protocol, which protocol is better to use for this use case with Exoplayer on older android api versions and low config devices?

  4. microkatz commented on Sep 5, 2023

    @microkatz
    Contributor

    If the additional streams have the same duration as the RTSP video then it may still work. cf3fd1f has been pushed to the androidx/media main branch. Hopefully that commit addresses the MergingMediaSource incompatibility.

    I'm going to close this issue as the commit fixed the specific problem of MergingMediaSource being incompatible with RtspMediaSource.

    If you have additional queries or problems then please create a new issue.

    Thank you!

  5. locked and limited conversation to collaborators on Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions