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

SimpleExoPlayer getDuration some audio links are getting incorrectly #6241

Closed
zhan2046 opened this issue Jul 30, 2019 · 5 comments
Closed

SimpleExoPlayer getDuration some audio links are getting incorrectly #6241

zhan2046 opened this issue Jul 30, 2019 · 5 comments
Assignees

Comments

@zhan2046
Copy link

[REQUIRED] Issue description

Hello, I found that using simpleExoPlayer.duration, In some audio links, the total duration of playback is incorrect.

For example, a song that takes a total of 2 minutes, but can only play for one minute.

[REQUIRED] Reproduction steps

Use https://pro-audio.xiaoheiban.cn/201907/0fd5f017-cafe-4dfd-9f69-3a06cf4e2651.wav audio link

val url = "https://pro-audio.xiaoheiban.cn/201907/0fd5f017-cafe-4dfd-9f69-3a06cf4e2651.wav"
val mediaMetadataCompat = MediaMetadataCompat.Builder()
    .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, "METADATA_KEY_MEDIA_ID")
    .putString(MediaMetadataCompat.METADATA_KEY_TITLE, "METADATA_KEY_TITLE")
    .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI, url)
    .build()
mediaMetadataCompat.description.extras?.putAll(mediaMetadataCompat.bundle)
val extractorMediaSource = ExtractorMediaSource.Factory(factory)
        .setTag(mediaMetadataCompat.description)
        .createMediaSource(Uri.parse(url))
val concatenatingMediaSource = ConcatenatingMediaSource()
concatenatingMediaSource.addMediaSource(extractorMediaSource)
simpleExoPlayer.prepare(concatenatingMediaSource)
simpleExoPlayer.seekTo(0, 0)

When the music is playing, the total length of the music is found to be wrong.

val duration = simpleExoPlayer.duration

[REQUIRED] Version of ExoPlayer being used

com.google.android.exoplayer:exoplayer:2.10.3
com.google.android.exoplayer:exoplayer-ui:2.10.3
com.google.android.exoplayer:extension-mediasession:2.10.3
@zhan2046
Copy link
Author

I also found this problem in the old version 2.9.6.

@ojw28 ojw28 self-assigned this Jul 30, 2019
@ojw28
Copy link
Contributor

ojw28 commented Jul 30, 2019

Looking at this spec and what's in the file, it appears Subchunk2Size is incorrect in the file (i.e. it specifies a size for the sound data that's larger than the total size of the file).

We can add a check that'll clip the size to the end of the file. The media does seem to be broken though. If this is your media, you should fix it.

@ojw28
Copy link
Contributor

ojw28 commented Jul 30, 2019

Notes:

  • The RIFF chunk descriptor contains the file length, so we can use that rather than relying on the length from the ExtractorInput.
  • It's unclear whether WavExtractor handles a seek to position=0 correctly. This needs checking. We should also check whether the test covers this.

@ojw28 ojw28 removed the needs triage label Aug 1, 2019
@ojw28
Copy link
Contributor

ojw28 commented Aug 1, 2019

Notes:

  • The RIFF chunk descriptor file length is also incorrect in this file. I think what probably happened is that a valid 2 minute long WAV file was generated, and then the file was clipped to just keep the first half. The length of the ExtractorInput needs to be used to check for this case.

ojw28 added a commit that referenced this issue Aug 1, 2019
Issue: #6241
PiperOrigin-RevId: 261126968
@ojw28
Copy link
Contributor

ojw28 commented Aug 1, 2019

Fixed in the dev-v2 branch. This will be picked up in the 2.10.4 release.

@ojw28 ojw28 closed this as completed Aug 1, 2019
ojw28 added a commit that referenced this issue Aug 1, 2019
Issue: #6241
PiperOrigin-RevId: 261126968
@google google locked and limited conversation to collaborators Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants