Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#26845 closed defect (bug) (worksforme)

MP3 ID3 Tag Metadata Malformed

Reported by: chipbennett's profile chipbennett Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Media Keywords:
Focuses: Cc:

Description

Issue:

Retrieving audio/mp3 attachment metadata returns malformed serialized data for metadata generated from ID3 tags.

To reproduce:

  1. Upload/attach mp3 file containing valid ID3 tags to a post
  2. Query attached audio files:
    $tracks = get_children( array(
    	'post_parent' => $post->ID,
    	'post_type' => 'attachment',
    	'post_mime_type' => 'audio',
    ) );
    // Loop through them
    foreach ( $tracks as $track ) {} 
    
  3. Attempt to retrieve metadata using either method:
    $metadata = get_post_meta( $track->ID, '_wp_attachment_metadata', true );
    // or
    $metadata = wp_get_attachment_metadata( $track->ID );
    

Example

Above procedure performed on a small mp3 file with valid ID3 tags produces the following output:

a:29:{s:10:"dataformat";s:3:"mp3";s:8:"channels";i:2;s:11:"sample_rate";i:44100;s:7:"bitrate";d:237594.2401960784;s:11:"channelmode";s:12:"joint stereo";s:12:"bitrate_mode";s:3:"abr";s:5:"codec";s:4:"LAME";s:7:"encoder";s:15:"LAME3.98 (beta)";s:8:"lossless";b:0;s:15:"encoder_options";s:3:"ABR";s:17:"compression_ratio";d:0.16836326544506688;s:10:"fileformat";s:3:"mp3";s:8:"filesize";i:531738;s:9:"mime_type";s:10:"audio/mpeg";s:6:"length";i:10;s:16:"length_formatted";s:4:"0:09";s:5:"title";s:5:"There";s:6:"artist";s:20:"They Might Be Giants";s:5:"album";s:8:"Nanobots";s:5:"genre";s:16:"Alternative Rock";s:8:"composer";s:14:"Not Documented";s:9:"conductor";s:2:""

And dumping it:

var_dump( $metadata );

Results in:

bool(false)

Attempting to correct malformed syntax like so:

a:22:{s:10:"dataformat";s:3:"mp3";s:8:"channels";i:2;s:11:"sample_rate";i:44100;s:7:"bitrate";d:237594.2401960784;s:11:"channelmode";s:12:"joint stereo";s:12:"bitrate_mode";s:3:"abr";s:5:"codec";s:4:"LAME";s:7:"encoder";s:15:"LAME3.98 (beta)";s:8:"lossless";b:0;s:15:"encoder_options";s:3:"ABR";s:17:"compression_ratio";d:0.16836326544506688;s:10:"fileformat";s:3:"mp3";s:8:"filesize";i:531738;s:9:"mime_type";s:10:"audio/mpeg";s:6:"length";i:10;s:16:"length_formatted";s:4:"0:09";s:5:"title";s:5:"There";s:6:"artist";s:20:"They Might Be Giants";s:5:"album";s:8:"Nanobots";s:5:"genre";s:16:"Alternative Rock";s:8:"composer";s:14:"Not Documented";s:9:"conductor";s:2:"na";}

And dumping it:

var_dump( $metadata );

Results in:

array(22) { ["dataformat"]=> string(3) "mp3" ["channels"]=> int(2) ["sample_rate"]=> int(44100) ["bitrate"]=> float(237594.24019608) ["channelmode"]=> string(12) "joint stereo" ["bitrate_mode"]=> string(3) "abr" ["codec"]=> string(4) "LAME" ["encoder"]=> string(15) "LAME3.98 (beta)" ["lossless"]=> bool(false) ["encoder_options"]=> string(3) "ABR" ["compression_ratio"]=> float(0.16836326544507) ["fileformat"]=> string(3) "mp3" ["filesize"]=> int(531738) ["mime_type"]=> string(10) "audio/mpeg" ["length"]=> int(10) ["length_formatted"]=> string(4) "0:09" ["title"]=> string(5) "There" ["artist"]=> string(20) "They Might Be Giants" ["album"]=> string(8) "Nanobots" ["genre"]=> string(16) "Alternative Rock" ["composer"]=> string(14) "Not Documented" ["conductor"]=> string(2) "na" }

Reproducibility

I repeated the process with four different MP3 files from the same album. I then repeated the process with three different MP3 files from a different album.

All appear to have a serialization issue at/after "conductor". The serialization halts, resulting in only 22 of the 29 array keys being added to the serialized string, and the 22nd ("conductor") being malformed.

Attachments (1)

Death Grips - I've Seen Footage.mp3 (3.1 MB) - added by matthewhaworth 10 years ago.
(Free) MP3 with valid ID3 tags

Change History (5)

#1 follow-up: @wonderboymusic
10 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.9

will take a look

@matthewhaworth
10 years ago

(Free) MP3 with valid ID3 tags

#2 in reply to: ↑ 1 @matthewhaworth
10 years ago

  • Resolution set to worksforme
  • Status changed from new to closed
  • Version changed from 3.8 to trunk

I tried to replicate with this code:

<?php    
include_once 'wp-config.php';
include_once 'wp-load.php';
include_once 'wp-includes/wp-db.php';
include_once 'wp-includes/pluggable.php';    
$tracks = get_children( array(
        'post_parent' => 4,
        'post_type' => 'attachment',
        'post_mime_type' => 'audio',
));
// Loop through them
foreach ( $tracks as $track ) {
    $metadata = get_post_meta( $track->ID, '_wp_attachment_metadata', true );
    var_dump($metadata);    
    $metadata = wp_get_attachment_metadata( $track->ID );
    var_dump($metadata);
}

After I had uploaded the file attached, I ran this and got the following output:

array(21) {
  ["dataformat"]=>
  string(3) "mp3"
  ["channels"]=>
  int(2)
  ["sample_rate"]=>
  int(44100)
  ["bitrate"]=>
  int(128000)
  ["channelmode"]=>
  string(6) "stereo"
  ["bitrate_mode"]=>
  string(3) "cbr"
  ["codec"]=>
  string(4) "LAME"
  ["encoder"]=>
  string(15) "LAME3.98 (beta)"
  ["lossless"]=>
  bool(false)
  ["encoder_options"]=>
  string(6) "CBR128"
  ["compression_ratio"]=>
  float(0.090702947845805)
  ["fileformat"]=>
  string(3) "mp3"
  ["filesize"]=>
  int(3247099)
  ["mime_type"]=>
  string(10) "audio/mpeg"
  ["length"]=>
  int(203)
  ["length_formatted"]=>
  string(4) "3:23"
  ["title"]=>
  string(17) "I've Seen Footage"
  ["artist"]=>
  string(11) "Death Grips"
  ["album"]=>
  string(15) "The Money Store"
  ["track_number"]=>
  string(1) "6"
  ["comment"]=>
  string(74) "Free download from http://www.last.fm/music/Death+Grips and http://MP3.com"
}
array(21) {
  ["dataformat"]=>
  string(3) "mp3"
  ["channels"]=>
  int(2)
  ["sample_rate"]=>
  int(44100)
  ["bitrate"]=>
  int(128000)
  ["channelmode"]=>
  string(6) "stereo"
  ["bitrate_mode"]=>
  string(3) "cbr"
  ["codec"]=>
  string(4) "LAME"
  ["encoder"]=>
  string(15) "LAME3.98 (beta)"
  ["lossless"]=>
  bool(false)
  ["encoder_options"]=>
  string(6) "CBR128"
  ["compression_ratio"]=>
  float(0.090702947845805)
  ["fileformat"]=>
  string(3) "mp3"
  ["filesize"]=>
  int(3247099)
  ["mime_type"]=>
  string(10) "audio/mpeg"
  ["length"]=>
  int(203)
  ["length_formatted"]=>
  string(4) "3:23"
  ["title"]=>
  string(17) "I've Seen Footage"
  ["artist"]=>
  string(11) "Death Grips"
  ["album"]=>
  string(15) "The Money Store"
  ["track_number"]=>
  string(1) "6"
  ["comment"]=>
  string(74) "Free download from http://www.last.fm/music/Death+Grips and http://MP3.com"
}

#3 @chipbennett
10 years ago

Thanks for attaching the file. I'll test the upload and see if it works the same for me.

#4 @SergeyBiryukov
10 years ago

  • Keywords needs-patch removed
  • Milestone 3.9 deleted
Note: See TracTickets for help on using tickets.