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

getDuration() returns zero for Opus WebM codec #1578

Open
2 tasks done
putnokiabel opened this issue Jul 22, 2023 · 8 comments
Open
2 tasks done

getDuration() returns zero for Opus WebM codec #1578

putnokiabel opened this issue Jul 22, 2023 · 8 comments
Labels
bug platform-android Affects the android platform reproducible Bug can be reproduced

Comments

@putnokiabel
Copy link

putnokiabel commented Jul 22, 2023

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

When calling audioPlayer.getDuration() with an audiofile that's encoded with an Opus WebM codec, the method returns Duration.zero.

I've tested on both Android and on Chrome, both of which support the Opus WebM codec.
On both platforms, the audio playback with audioplayers works properly, just the duration is incorrect (it always returns Duration.zero).

Expected behaviour

audioPlayer.getDuration() returns the actual duration of the audio file.

Steps to reproduce

Run code sample with example URL provided below.

Code sample

Code sample
final audioPlayer = AudioPlayer();

await audioPlayer.setSourceUrl(url);

final duration = await audioPlayer.getDuration();
print(duration);

Affected platforms

Android, Windows

Platform details

  • Platform 1: Chrome Version 114.0.5735.198 (Official Build) (arm64)
  • Platform 2: Android version 13

AudioPlayers Version

main

Build mode

Debug mode.

Audio Files/URLs/Sources

https://firebasestorage.googleapis.com/v0/b/obedience-app.appspot.com/o/audio%2F9f4edbb3-34a0-4146-b7f7-85cca3640a3b.opus?alt=media&token=feed7a95-1dcb-4e93-924e-645539d82cef

Logs

No relevant logs.

Flutter doctor:

Output of: flutter doctor -v
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F82 darwin-arm64, locale
  en-NL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] VS Code (version 1.80.1)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

Related issues / more information

No response

Working on PR

no way

@Gustl22 Gustl22 added platform-android Affects the android platform platform-windows Affects the windows platform labels Jul 31, 2023
@Gustl22
Copy link
Collaborator

Gustl22 commented Jul 31, 2023

See #1255. Some codecs are not supported on every platform

@putnokiabel
Copy link
Author

Hi @Gustl22 ,
I did check the supported codecs, and both Android and Chrome have support for this codec.
There is also no problem playing the audio, there is only an issue with getting the duration of the audio file, which leads me to believe that this is a bug, rather than an issue with the codec not being supported.

@Gustl22
Copy link
Collaborator

Gustl22 commented Sep 11, 2023

On Chrome and Firefox, I can get the duration just fine:
https://bluefireteam.github.io/audioplayers/

On Android, ineed, I don't get the duration, don't know if worth fixing, (or if it's even the fault of AudioPlayers). I'd rather work on an implementation of Exoplayer, see #1526

@Gustl22 Gustl22 removed the platform-windows Affects the windows platform label Sep 11, 2023
@putnokiabel
Copy link
Author

Alright. For now I chose to convert my audio files from WebM to a different format using a backend service, so this is no longer an issue for me.

@Gustl22 Gustl22 added the reproducible Bug can be reproduced label Sep 25, 2023
@Gustl22
Copy link
Collaborator

Gustl22 commented Sep 25, 2023

I leave it open, as it's a valid snd reproducible bug. We either resolve it directly or wait for the Exoplayer implementation.

@Gustl22 Gustl22 reopened this Sep 25, 2023
@dernoun
Copy link

dernoun commented Jan 23, 2024

Alright. For now I chose to convert my audio files from WebM to a different format using a backend service, so this is no longer an issue for me.

@putnokiabel Is that the only solution you found? I am recording audio from the web where OpusWebM is my only choice to save it, I am not able to get the duration of the audio as well!

@putnokiabel
Copy link
Author

Alright. For now I chose to convert my audio files from WebM to a different format using a backend service, so this is no longer an issue for me.

@putnokiabel Is that the only solution you found? I am recording audio from the web where OpusWebM is my only choice to save it, I am not able to get the duration of the audio as well!

I haven't looked into other solutions since this one seemed to work for now. If converting to a different format is not an option because you need the files in WebM, you might consider using a web service or a different library to get the duration of the file (until this issue is fixed).

@FaizanAhmad127
Copy link

Same issue here. Is there any package worth trying to convert webm to mp3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-android Affects the android platform reproducible Bug can be reproduced
Projects
None yet
Development

No branches or pull requests

4 participants