Page MenuHomePhabricator

Midi files with duration 0 due to not having tempo events
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
which all run into the dividebyzero problem. It seems this is because getID3 doesnt support calculating the duration for files that have no tempo events. I think we can create some fallback logic for this.

What should have happened instead?:
The files should have a duration

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

TheDJ renamed this task from Midi files without to Midi files with duration 0 due to not having tempo events.Jan 14 2026, 11:17 PM

Change #1226975 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/extensions/TimedMediaHandler@master] Fix duration of midi files without tempo events

https://gerrit.wikimedia.org/r/1226975

Change #1226975 merged by jenkins-bot:

[mediawiki/extensions/TimedMediaHandler@master] Fix duration of midi files without tempo events

https://gerrit.wikimedia.org/r/1226975

TheDJ moved this task from Inbox to For-review on the User-TheDJ board.
TheDJ moved this task from Backlog to Patch proposed upstream on the Upstream board.

The files mentioned in the OP are very short. However, there are many much longer files that also show a zero duration e.g. https://commons.wikimedia.org/wiki/File:Erik_Satie_-_Ogive_No.2.mid – strangely, https://commons.wikimedia.org/wiki/File:Erik_Satie_-_Ogive_No.1.mid shows the correct time of 1:30. Many others, like https://commons.wikimedia.org/wiki/File:Ludwig_van_Beethoven_-_Bagatelles_Op._126.mid , show a drastically shorter time than they should, 2:50 instead of 18:58.

The files mentioned in the OP are very short. However, there are many much longer files that also show a zero duration

Yes this is known, there is a patch in the works for most of these. but that will still take a bit to land, and then we need to run a script to find and update the database entries for all those files.

e.g. https://commons.wikimedia.org/wiki/File:Erik_Satie_-_Ogive_No.2.mid – strangely, https://commons.wikimedia.org/wiki/File:Erik_Satie_-_Ogive_No.1.mid shows the correct time of 1:30. Many others, like https://commons.wikimedia.org/wiki/File:Ludwig_van_Beethoven_-_Bagatelles_Op._126.mid , show a drastically shorter time than they should, 2:50 instead of 18:58.

This might be a different issue, or it might simply be that the duration information in the file itself is incorrect. When I have time, I'll take a look.

a) Bump. b) A thought: The player shows the correct time as soon as the play button is hit, so it knows the correct time, presumably from a transcoded sound file. This may be a pathway to show the correct length.

We are just waiting for upstream to make a new release with php 8.5 compatibility as well

Now that T414875 was merged, we should be able to run

php maintenance/run.php refreshImageMetadata --force --mediatype AUDIO --mime audio/midi

for each wiki

This will refresh the metadata of all midi files.. unfortunately it's not easy to detect the ones which are broken, as there is no --metadata-contains-not flag for the job. but the set of midi files is only 7,065 files on Commons and 3500 are effected, so not worth being super targeted here.

After running the script, the count of files without duration listed at: https://quarry.wmcloud.org/query/103868 should reduce significantly (currently 3657). And the files listed in this ticket's description should no longer be 0

Mentioned in SAL (#wikimedia-operations) [2026-05-05T07:50:39Z] <zabe> zabe@deploy1003:~$ foreachwiki refreshImageMetadata --force --mediatype AUDIO --mime audio/midi # T414645

It now looks good to me. @TheDJ could you double check?

TheDJ claimed this task.

Yep, fixed. Thank you Zabe !

FYI, https://commons.wikimedia.org/wiki/File:Ludwig_van_Beethoven_-_Bagatelles_Op._126.mid still shows 2:50 instead of 18:58. The other files mentioned in this thread show the correct lengths.

FYI, https://commons.wikimedia.org/wiki/File:Ludwig_van_Beethoven_-_Bagatelles_Op._126.mid still shows 2:50 instead of 18:58. The other files mentioned in this thread show the correct lengths.

Incorrect duration != 0 duration. I'm sure there are lots of files with all kinds of problems, but that is sort of expected. I'll see if I kind find out what this problem is, but it is not related to this ticket.