-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Combining ClippingMediaSource and ConcatenatingMediaSource #4908
Comments
A little bit more insight about the issue: Here is how we are using the val concatenatedMediaSource = someObject?.otherMagic(context)
val soundMediaSource = ExtractorMediaSource.Factory(DefaultDataSourceFactory(context, Util.getUserAgent(context, "someAppName"))).createMediaSource(Uri.fromFile(audioFile))
val concatenatedSoundMediaSource = someObject?.fixedMagic(context, soundMediaSource)
val mergingMediaSource = MergingMediaSource(concatenatedMediaSource, concatenatedSoundMediaSource)
player.prepare(concatenatedSoundMediaSource) and here is the fun SomeObject.otherMagic(context: Context?): ConcatenatingMediaSource {
val dataSourceFactory = DefaultDataSourceFactory(context, Util.getUserAgent(context, "someAppName"))
val mediaSource = ConcatenatingMediaSource(true)
videos.forEach {
val tmpMediaSource = ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.fromFile(it.videoFile))
mediaSource.addMediaSource(tmpMediaSource)
}
return mediaSource
} Now check here: val mergingMediaSource = MergingMediaSource(concatenatedMediaSource, concatenatedSoundMediaSource) If I give the videos first into the |
Is it possible that the audio file you are clipping is not seekable? |
Please provide the media so we can have a look. |
Yes the audio file is definitely seekable, and I am not referring to a single audio file here. I have tried a good many different audio files and they are all seekable. For instance the following code works perfectly for the every audio file I have tried: (the player has the audio as fun instantSeek(timeMs: Int) {
player?.seekTo(timeMs.toLong())
} |
Could you look into the issue that I have pointed out? @AquilesCanta |
@tonihei - I reckon this was probably broken by [Internal CL ref cr/192621719]. Although perhaps it didn't work before that, either :). Behavior of |
Is there any workaround in your mind so that I can get this to work somehow? Basically I want to play a single audio file from |
Can't reproduce with the latest dev branch, but it may have been fixed by this commit. Can you try the the dev-v2 branch to see if it still occurs? The underlying reason is probably a duplicate of #4873. |
Tried the dev-v2 branch through Jitpack within our main project and I'm sure I'm not missing something out but the project doesn't compile and yields a good many I will try it in a fresh project when I have some more time, hope it is indeed fixed. |
Did you have a chance to verify it's working now? We'll also publish a 2.9.1. soon containing the fix above. |
Closing due to inactivity and because we received no further info. |
Hello again,
so I have
n
videos and1
audio file that I am trying to play as a single media. First I tried concatenating thesen
videos using theConcatenatingMediaSource
and then merge that concatenated media source with the audio file usingMergingMediaSource
; however, apparently this is not a possible option due to bunch of internal stuff going on there.Then I tried to clip the audio file into
n
clips accordingly and then concatenate them into a single media source that is only audio, after that I tried merging them with the other concatenated media source ofn
videos. However the sound is restarting fromt=0
every time the concatenated media source of videos switch to the next video.Here is the first sample code I have tried for that:
The problem with this code is that, when I merge this
ConcatenatingMediaSource
with the otherConcatenatingMediaSource
containingn
videos, the first clipped audio has a weird end position and does not end when the video ends so the audio continues but the first video ofn
videos just stops and waits for the sound to end, which takes forever.The second code below, does not have such problem but instead of continuing from the last timestamp, the audio just restarts from the beginning:
How should I calculate the start position for the clipped audio tracks? Thanks in advance.
The text was updated successfully, but these errors were encountered: