Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#29176 closed defect (bug) (fixed)

Wrong length (duration) in wp_read_video_metadata()

Reported by: jrf's profile jrf Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.6
Component: Media Keywords: has-patch
Focuses: Cc:


Ran into this when running some tests on uploaded video files.

The length_formatted value was correct, while the length was x 1000. Turned out to be correct in the original meta data, but wrongly overwritten by the tag data. This might be caused by a bug in getID3.

Issues can easily be reproduced using the attached example file.

Patch attached as well.

Attachments (3)

media.php.patch (577 bytes) - added by jrf 10 years ago.
Patch file
76619.mp3 (266.5 KB) - added by jrf 10 years ago.
Example file which will show the bug if uploaded
29176.diff (1.5 KB) - added by wonderboymusic 10 years ago.

Download all attachments as: .zip

Change History (9)

10 years ago

Patch file

10 years ago

Example file which will show the bug if uploaded

#1 @jrf
10 years ago

  • Keywords has-patch added
  • Summary changed from Wrong video length in wp_read_video_metadata() to Wrong length (duration) in wp_read_video_metadata()

#2 @johnbillion
10 years ago

  • Keywords needs-testing added
  • Version changed from trunk to 3.6

#3 @wonderboymusic
10 years ago

  • Keywords needs-testing removed
  • Milestone changed from Awaiting Review to 4.1

You are correct, it is getting clobbered. Also need to change ceil() to round() in wp_read_video_metadata() and wp_read_audio_metadata().

29176.diff does that.

#4 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 29728:

Don't overwrite the length property unnecessarily when generating metadata for audio and video files.

Props jrf, wonderboymusic.
Fixes #29176.

#5 @jrf
10 years ago

I kind of had the feeling that the ceil() was on purpose as if they are round down, the video could be cut off just before the end.

#6 @wonderboymusic
10 years ago

length_formatted is set to the value of playtime_string, which is a prop returned by getID3::analyze() - it is the only value we ever read directly. length is just there in case you want to format your own time string. Without round(), the values can differ: length would be 46 while length_formatted would be 45. I vote for consistency with the values, since ceil() was already converting the float, there was no chance for the user to make that choice.

Note: See TracTickets for help on using tickets.