Skip to content

Commit 17d9649

Browse files
committed
bugfix: #2121 MP4 Chapters
http://www.getid3.org/phpBB3/viewtopic.php?t=2121 Add support for Quicktime/MP4 "chpl" atom
1 parent ba9f1d4 commit 17d9649

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

getid3/getid3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class getID3
120120
protected $startup_error = '';
121121
protected $startup_warning = '';
122122

123-
const VERSION = '1.9.14-201709251450';
123+
const VERSION = '1.9.14-201709291043';
124124
const FREAD_BUFFER_SIZE = 32768;
125125

126126
const ATTACHMENTS_NONE = false;

getid3/module.audio-video.quicktime.php

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,18 +1700,38 @@ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset
17001700
break;
17011701

17021702
case 'loci':// 3GP location (El Loco)
1703-
$info['quicktime']['comments']['gps_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1704-
$info['quicktime']['comments']['gps_lang'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
1705-
$loffset = 0;
1706-
$info['quicktime']['comments']['gps_location'] = $this->LociString(substr($atom_data, 6), $loffset);
1707-
$loci_data=substr($atom_data, 6 + $loffset);
1708-
$info['quicktime']['comments']['gps_role'] = getid3_lib::BigEndian2Int(substr($loci_data, 0, 1));
1709-
$info['quicktime']['comments']['gps_longitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 1, 4));
1710-
$info['quicktime']['comments']['gps_latitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 5, 4));
1711-
$info['quicktime']['comments']['gps_altitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 9, 4));
1712-
$info['quicktime']['comments']['gps_body'] = $this->LociString(substr($loci_data, 13), $loffset);
1713-
$info['quicktime']['comments']['gps_notes'] = $this->LociString(substr($loci_data, 13 + $loffset), $loffset);
1714-
break;
1703+
$loffset = 0;
1704+
$info['quicktime']['comments']['gps_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1705+
$info['quicktime']['comments']['gps_lang'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
1706+
$info['quicktime']['comments']['gps_location'] = $this->LociString(substr($atom_data, 6), $loffset);
1707+
$loci_data = substr($atom_data, 6 + $loffset);
1708+
$info['quicktime']['comments']['gps_role'] = getid3_lib::BigEndian2Int(substr($loci_data, 0, 1));
1709+
$info['quicktime']['comments']['gps_longitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 1, 4));
1710+
$info['quicktime']['comments']['gps_latitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 5, 4));
1711+
$info['quicktime']['comments']['gps_altitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 9, 4));
1712+
$info['quicktime']['comments']['gps_body'] = $this->LociString(substr($loci_data, 13 ), $loffset);
1713+
$info['quicktime']['comments']['gps_notes'] = $this->LociString(substr($loci_data, 13 + $loffset), $loffset);
1714+
break;
1715+
1716+
case 'chpl': // CHaPter List
1717+
// https://www.adobe.com/content/dam/Adobe/en/devnet/flv/pdfs/video_file_format_spec_v10.pdf
1718+
$chpl_version = getid3_lib::BigEndian2Int(substr($atom_data, 4, 1)); // Expected to be 0
1719+
$chpl_flags = getid3_lib::BigEndian2Int(substr($atom_data, 5, 3)); // Reserved, set to 0
1720+
$chpl_count = getid3_lib::BigEndian2Int(substr($atom_data, 8, 1));
1721+
$chpl_offset = 9;
1722+
for ($i = 0; $i < $chpl_count; $i++) {
1723+
if (($chpl_offset + 9) >= strlen($atom_data)) {
1724+
$this->warning('QuickTime chapter '.$i.' extends beyond end of "chpl" atom');
1725+
break;
1726+
}
1727+
$info['quicktime']['chapters'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($atom_data, $chpl_offset, 8)) / 10000000; // timestamps are stored as 100-nanosecond units
1728+
$chpl_offset += 8;
1729+
$chpl_title_size = getid3_lib::BigEndian2Int(substr($atom_data, $chpl_offset, 1));
1730+
$chpl_offset += 1;
1731+
$info['quicktime']['chapters'][$i]['title'] = substr($atom_data, $chpl_offset, $chpl_title_size);
1732+
$chpl_offset += $chpl_title_size;
1733+
}
1734+
break;
17151735

17161736
default:
17171737
$this->warning('Unknown QuickTime atom type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset);

0 commit comments

Comments
 (0)