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

OGG Vorbis: wrong (playback) duration / length reported on opus audio #593

Closed
ewaldc opened this issue Jan 19, 2023 · 1 comment
Closed

Comments

@ewaldc
Copy link

ewaldc commented Jan 19, 2023

First of all: a huge "thank you" for this great library!

Mutagen version: 1.46.0
Python version: 3.10
Problem: audio length reported by mutagen does not correspond with real playback duration as measured with stopwatch and reported by tools like MediaInfo, OpusTools (opusinfo) etc. as well as media players (e.g. VLC and many others). The error is bigger with larger files e.g. ~4 to ~6 seconds on 6 minutes

Code

    def audio_file_duration(audio_file):
        if (path_exists(audio_file)):
            _file = mutagen.File(audio_file)
            if _file is not None and _file.info is not None:
                return _file.info.length, _file.info.length * 1000
        return None, 0

UPDATE
I have been able to reproduce the errors. There were 2 root causes:

  • In some cases, silence at the end of an Opus audio file is not counted, but this is not a mutagen issue. Other tools like mediainfo report the same length. I have added code to detect these situations.
  • In some cases, Mutagen's OggPage.find_last returns the wrong page, but the corruption happens in one of the supporting byte IO libraries, not mutagen. The actual root of the problem could end up being in my code as it happens only on very long lists of audio samples (100000+). I was confused because it always seemed to go wrong on the same audio files, but when shuffling the sample lists, it became obvious that it was not related to particular audio files.

Hence, I will close this issue as Mutagen is not at fault.

@ewaldc ewaldc closed this as completed Jan 20, 2023
@ewaldc
Copy link
Author

ewaldc commented Jan 20, 2023

Closing issue as not directly caused by Mutagen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant