Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergingMediaSource with delay #6977

Closed
karen-1996 opened this issue Feb 14, 2020 · 5 comments
Closed

MergingMediaSource with delay #6977

karen-1996 opened this issue Feb 14, 2020 · 5 comments
Assignees
Labels

Comments

@karen-1996
Copy link

Hi
I have MergingMediaSource with audio and video sources and want to add delay to the audio file, like to play audio after 2 seconds from the video.
My audio and video sources are ProgressiveMediaSource and I can't find a solution for this.

I look forward to your reply.

@kim-vde
Copy link
Contributor

kim-vde commented Feb 14, 2020

If possible, the easiest way is to update the audio stream directly.

If not, you can concatenate the audio with a SilenceMediaSource, but then you will not be able to merge the resulting media source with the video, as they don't have the same number of periods anymore. You will therefore need to use 2 different players (one for audio, one for video) and to implement the synchronisation by yourself.

Another solution would be to do something like concat(merge(clip(video, 0, 2), silence(2)), merge(clip(video, 2, end), audio)) but you might encounter a slight pause in the video.

@karen-1996
Copy link
Author

karen-1996 commented Feb 17, 2020

I try to concatenate 2 media sources but played only first, here is what I try
val concatenatingMediaSource =
ConcatenatingMediaSource(
ClippingMediaSource(videoSource, 0, 40000000),
ClippingMediaSource(videoSource, 4000000, 15000000)
)

After this, my video played from 0 to 4 seconds and ended

@kim-vde
Copy link
Contributor

kim-vde commented Feb 17, 2020

ConcatenatingMediaSource creates playlist items. By default, the 2 ClippingMediaSources should be played one after the other, as playlist items. You can play the videos as if it was a single media by setting setShowMultiWindowTimeBar.

@karen-1996
Copy link
Author

karen-1996 commented Feb 17, 2020

Great, this problem solved. Now I try something like this

val mediaSource = ConcatenatingMediaSource(
                MergingMediaSource(
                    ClippingMediaSource(videoSource, 0, 2000000),
                    SilenceMediaSource(2000000)
                ),
                MergingMediaSource(
                    ClippingMediaSource(videoSource, 2000000, 15000000),
                    audioSource
                )
            )

Here the video starts and there is no sound, everything looks good. After 2 seconds audio starts playing, and it was playing from 2 seconds, not from 0 seconds.
Why ???

@tonihei
Copy link
Collaborator

tonihei commented Feb 17, 2020

That's a known bug, see #6103.

@kim-vde kim-vde closed this as completed Mar 4, 2020
@ojw28 ojw28 added duplicate and removed duplicate labels Mar 9, 2020
@google google locked and limited conversation to collaborators May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants