Skip to content

Commit 638be01

Browse files
committed
#452 handle ISO639-2/T Quicktime language code
#452
1 parent 59abfe6 commit 638be01

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

getid3/getid3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class getID3
387387
*/
388388
protected $startup_warning = '';
389389

390-
const VERSION = '1.9.24-202510151030';
390+
const VERSION = '1.9.24-202510161031';
391391
const FREAD_BUFFER_SIZE = 32768;
392392

393393
const ATTACHMENTS_NONE = false;

getid3/module.audio-video.quicktime.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset
473473
} else {
474474
// Apple item list box atom handler
475475
$atomoffset = 0;
476+
// todo (2025-10-16): 0x10B5 is probably Packed ISO639-2/T language code so this code block is likely incorrect
477+
// need to locate sample file to figure out what is going on here and why this code was written as such
478+
// https://developer.apple.com/documentation/quicktime-file-format/language_code_values
476479
if (substr($atom_data, 2, 2) == "\x10\xB5") {
477480
// not sure what it means, but observed on iPhone4 data.
478481
// Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data
@@ -1754,17 +1757,20 @@ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset
17541757
break;
17551758

17561759
case 'data': // metaDATA atom
1757-
// seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in one sample I have; 0x15C7 in another), remainder is useful data
1758-
$atom_structure['language'] = substr($atom_data, 4 + 0, 2);
1759-
$atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
1760-
$atom_structure['data'] = substr($atom_data, 4 + 4);
1760+
// seems to be 2 bytes language code (ASCII), 2 bytes language code (probably packed ISO639-2/T), remainder is useful data
1761+
$atom_structure['lang2'] = substr($atom_data, 4 + 0, 2);
1762+
$atom_structure['lang3'] = $this->QuicktimeLanguageLookup(getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2)));
1763+
$atom_structure['data'] = substr($atom_data, 4 + 4);
17611764
$atom_structure['key_name'] = (isset($info['quicktime']['temp_meta_key_names'][$this->metaDATAkey]) ? $info['quicktime']['temp_meta_key_names'][$this->metaDATAkey] : '');
17621765
$this->metaDATAkey++;
17631766

17641767
switch ($atom_structure['key_name']) {
17651768
case 'com.android.capture.fps':
17661769
$atom_structure['data'] = getid3_lib::BigEndian2Float($atom_structure['data']);
17671770
break;
1771+
case 'com.apple.quicktime.camera.focal_length.35mm_equivalent':
1772+
$atom_structure['data'] = getid3_lib::BigEndian2Int($atom_structure['data']);
1773+
break;
17681774
}
17691775

17701776
if ($atom_structure['key_name'] && $atom_structure['data']) {
@@ -2363,6 +2369,7 @@ public function quicktime_read_mp4_descr_length($data, &$offset) {
23632369
*/
23642370
public function QuicktimeLanguageLookup($languageid) {
23652371
// http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-34353
2372+
// https://developer.apple.com/documentation/quicktime-file-format/language_code_values
23662373
static $QuicktimeLanguageLookup = array();
23672374
if (empty($QuicktimeLanguageLookup)) {
23682375
$QuicktimeLanguageLookup[0] = 'English';

0 commit comments

Comments
 (0)