172 $info = &$this->getid3->info;
175 $thisfile_audio = &
$info[
'audio'];
176 $thisfile_video = &
$info[
'video'];
178 $thisfile_asf = &
$info[
'asf'];
179 $thisfile_asf[
'comments'] =
array();
180 $thisfile_asf_comments = &$thisfile_asf[
'comments'];
181 $thisfile_asf[
'header_object'] =
array();
182 $thisfile_asf_headerobject = &$thisfile_asf[
'header_object'];
203 $info[
'fileformat'] =
'asf';
205 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
206 $HeaderObjectData =
fread($this->getid3->fp, 30);
208 $thisfile_asf_headerobject[
'objectid'] = substr($HeaderObjectData, 0, 16);
209 $thisfile_asf_headerobject[
'objectid_guid'] = self::BytestringToGUID($thisfile_asf_headerobject[
'objectid']);
210 if ($thisfile_asf_headerobject[
'objectid'] != self::$GETID3_ASF_Header_Object) {
211 $info[
'warning'][] =
'ASF header GUID {' . self::BytestringToGUID($thisfile_asf_headerobject[
'objectid']) .
'} does not match expected "GETID3_ASF_Header_Object" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Header_Object) .
'}';
212 unset(
$info[
'fileformat']);
230 $NextObjectOffset =
ftell($this->getid3->fp);
231 $ASFHeaderData =
fread($this->getid3->fp,
232 $thisfile_asf_headerobject[
'objectsize'] - 30);
235 for ($HeaderObjectsCounter = 0;
236 $HeaderObjectsCounter < $thisfile_asf_headerobject[
'headerobjects'];
237 $HeaderObjectsCounter++) {
238 $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
240 $NextObjectGUIDtext = self::BytestringToGUID($NextObjectGUID);
245 switch ($NextObjectGUID) {
247 case self::$GETID3_ASF_File_Properties_Object:
267 $thisfile_asf[
'file_properties_object'] =
array();
268 $thisfile_asf_filepropertiesobject = &$thisfile_asf[
'file_properties_object'];
270 $thisfile_asf_filepropertiesobject[
'offset'] = $NextObjectOffset + $offset;
271 $thisfile_asf_filepropertiesobject[
'objectid'] = $NextObjectGUID;
272 $thisfile_asf_filepropertiesobject[
'objectid_guid'] = $NextObjectGUIDtext;
273 $thisfile_asf_filepropertiesobject[
'objectsize'] = $NextObjectSize;
274 $thisfile_asf_filepropertiesobject[
'fileid'] = substr($ASFHeaderData,
278 $thisfile_asf_filepropertiesobject[
'fileid_guid'] = self::BytestringToGUID($thisfile_asf_filepropertiesobject[
'fileid']);
286 $thisfile_asf_filepropertiesobject[
'creation_date_unix'] = self::FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject[
'creation_date']);
308 $thisfile_asf_filepropertiesobject[
'flags'][
'broadcast'] = (bool) ($thisfile_asf_filepropertiesobject[
'flags_raw'] & 0x0001);
309 $thisfile_asf_filepropertiesobject[
'flags'][
'seekable'] = (bool) ($thisfile_asf_filepropertiesobject[
'flags_raw'] & 0x0002);
324 if ($thisfile_asf_filepropertiesobject[
'flags'][
'broadcast']) {
327 unset($thisfile_asf_filepropertiesobject[
'filesize']);
328 unset($thisfile_asf_filepropertiesobject[
'data_packets']);
329 unset($thisfile_asf_filepropertiesobject[
'play_duration']);
330 unset($thisfile_asf_filepropertiesobject[
'send_duration']);
331 unset($thisfile_asf_filepropertiesobject[
'min_packet_size']);
332 unset($thisfile_asf_filepropertiesobject[
'max_packet_size']);
336 $info[
'playtime_seconds'] = ($thisfile_asf_filepropertiesobject[
'play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject[
'preroll'] / 1000);
339 $info[
'bitrate'] = ((isset($thisfile_asf_filepropertiesobject[
'filesize']) ? $thisfile_asf_filepropertiesobject[
'filesize'] :
$info[
'filesize']) * 8) /
$info[
'playtime_seconds'];
343 case self::$GETID3_ASF_Stream_Properties_Object:
363 $StreamPropertiesObjectData =
array();
364 $StreamPropertiesObjectData[
'offset'] = $NextObjectOffset + $offset;
365 $StreamPropertiesObjectData[
'objectid'] = $NextObjectGUID;
366 $StreamPropertiesObjectData[
'objectid_guid'] = $NextObjectGUIDtext;
367 $StreamPropertiesObjectData[
'objectsize'] = $NextObjectSize;
368 $StreamPropertiesObjectData[
'stream_type'] = substr($ASFHeaderData,
372 $StreamPropertiesObjectData[
'stream_type_guid'] = self::BytestringToGUID($StreamPropertiesObjectData[
'stream_type']);
373 $StreamPropertiesObjectData[
'error_correct_type'] = substr($ASFHeaderData,
377 $StreamPropertiesObjectData[
'error_correct_guid'] = self::BytestringToGUID($StreamPropertiesObjectData[
'error_correct_type']);
394 $StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData[
'flags_raw'] & 0x007F;
395 $StreamPropertiesObjectData[
'flags'][
'encrypted'] = (bool) ($StreamPropertiesObjectData[
'flags_raw'] & 0x8000);
398 $StreamPropertiesObjectData[
'type_specific_data'] = substr($ASFHeaderData,
400 $StreamPropertiesObjectData[
'type_data_length']);
401 $offset += $StreamPropertiesObjectData[
'type_data_length'];
402 $StreamPropertiesObjectData[
'error_correct_data'] = substr($ASFHeaderData,
404 $StreamPropertiesObjectData[
'error_data_length']);
405 $offset += $StreamPropertiesObjectData[
'error_data_length'];
407 switch ($StreamPropertiesObjectData[
'stream_type']) {
409 case self::$GETID3_ASF_Audio_Media:
410 $thisfile_audio[
'dataformat'] = (!empty($thisfile_audio[
'dataformat']) ? $thisfile_audio[
'dataformat'] :
'asf');
411 $thisfile_audio[
'bitrate_mode'] = (!empty($thisfile_audio[
'bitrate_mode']) ? $thisfile_audio[
'bitrate_mode'] :
'cbr');
416 unset($audiodata[
'raw']);
421 case self::$GETID3_ASF_Video_Media:
422 $thisfile_video[
'dataformat'] = (!empty($thisfile_video[
'dataformat']) ? $thisfile_video[
'dataformat'] :
'asf');
423 $thisfile_video[
'bitrate_mode'] = (!empty($thisfile_video[
'bitrate_mode']) ? $thisfile_video[
'bitrate_mode'] :
'cbr');
426 case self::$GETID3_ASF_Command_Media:
432 $thisfile_asf[
'stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
433 unset($StreamPropertiesObjectData);
436 case self::$GETID3_ASF_Header_Extension_Object:
446 $thisfile_asf[
'header_extension_object'] =
array();
447 $thisfile_asf_headerextensionobject = &$thisfile_asf[
'header_extension_object'];
449 $thisfile_asf_headerextensionobject[
'offset'] = $NextObjectOffset + $offset;
450 $thisfile_asf_headerextensionobject[
'objectid'] = $NextObjectGUID;
451 $thisfile_asf_headerextensionobject[
'objectid_guid'] = $NextObjectGUIDtext;
452 $thisfile_asf_headerextensionobject[
'objectsize'] = $NextObjectSize;
453 $thisfile_asf_headerextensionobject[
'reserved_1'] = substr($ASFHeaderData,
457 $thisfile_asf_headerextensionobject[
'reserved_1_guid'] = self::BytestringToGUID($thisfile_asf_headerextensionobject[
'reserved_1']);
458 if ($thisfile_asf_headerextensionobject[
'reserved_1'] != self::$GETID3_ASF_Reserved_1) {
459 $info[
'warning'][] =
'header_extension_object.reserved_1 GUID (' . self::BytestringToGUID($thisfile_asf_headerextensionobject[
'reserved_1']) .
') does not match expected "GETID3_ASF_Reserved_1" GUID (' . self::BytestringToGUID(self::$GETID3_ASF_Reserved_1) .
')';
467 if ($thisfile_asf_headerextensionobject[
'reserved_2'] != 6) {
468 $info[
'warning'][] =
'header_extension_object.reserved_2 (' .
Helper::PrintHexBytes($thisfile_asf_headerextensionobject[
'reserved_2']) .
') does not match expected value of "6"';
476 $thisfile_asf_headerextensionobject[
'extension_data'] = substr($ASFHeaderData,
478 $thisfile_asf_headerextensionobject[
'extension_data_size']);
479 $unhandled_sections = 0;
481 $unhandled_sections);
482 if ($unhandled_sections === 0) {
483 unset($thisfile_asf_headerextensionobject[
'extension_data']);
485 $offset += $thisfile_asf_headerextensionobject[
'extension_data_size'];
488 case self::$GETID3_ASF_Codec_List_Object:
504 $thisfile_asf[
'codec_list_object'] =
array();
505 $thisfile_asf_codeclistobject = &$thisfile_asf[
'codec_list_object'];
507 $thisfile_asf_codeclistobject[
'offset'] = $NextObjectOffset + $offset;
508 $thisfile_asf_codeclistobject[
'objectid'] = $NextObjectGUID;
509 $thisfile_asf_codeclistobject[
'objectid_guid'] = $NextObjectGUIDtext;
510 $thisfile_asf_codeclistobject[
'objectsize'] = $NextObjectSize;
511 $thisfile_asf_codeclistobject[
'reserved'] = substr($ASFHeaderData,
515 $thisfile_asf_codeclistobject[
'reserved_guid'] = self::BytestringToGUID($thisfile_asf_codeclistobject[
'reserved']);
516 if ($thisfile_asf_codeclistobject[
'reserved'] != self::GUIDtoBytestring(
'86D15241-311D-11D0-A3A4-00A0C90348F6')) {
517 $info[
'warning'][] =
'codec_list_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_codeclistobject[
'reserved']) .
'} does not match expected "GETID3_ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}';
525 for ($CodecEntryCounter = 0;
526 $CodecEntryCounter < $thisfile_asf_codeclistobject[
'codec_entries_count'];
527 $CodecEntryCounter++) {
529 $thisfile_asf_codeclistobject[
'codec_entries'][$CodecEntryCounter] =
array();
530 $thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject[
'codec_entries'][$CodecEntryCounter];
536 $thisfile_asf_codeclistobject_codecentries_current[
'type'] = $this->
ASFCodecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current[
'type_raw']);
542 $thisfile_asf_codeclistobject_codecentries_current[
'name'] = substr($ASFHeaderData,
545 $offset += $CodecNameLength;
551 $thisfile_asf_codeclistobject_codecentries_current[
'description'] = substr($ASFHeaderData,
553 $CodecDescriptionLength);
554 $offset += $CodecDescriptionLength;
560 $thisfile_asf_codeclistobject_codecentries_current[
'information'] = substr($ASFHeaderData,
562 $CodecInformationLength);
563 $offset += $CodecInformationLength;
565 if ($thisfile_asf_codeclistobject_codecentries_current[
'type_raw'] == 2) {
566 if (strpos($thisfile_asf_codeclistobject_codecentries_current[
'description'],
568 $info[
'warning'][] =
'[asf][codec_list_object][codec_entries][' . $CodecEntryCounter .
'][description] expected to contain comma-seperated list of parameters: "' . $thisfile_asf_codeclistobject_codecentries_current[
'description'] .
'"';
571 list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(
',',
572 self::TrimConvert($thisfile_asf_codeclistobject_codecentries_current[
'description']));
573 $thisfile_audio[
'codec'] = self::TrimConvert($thisfile_asf_codeclistobject_codecentries_current[
'name']);
575 if (!isset($thisfile_audio[
'bitrate']) && strstr($AudioCodecBitrate,
577 $thisfile_audio[
'bitrate'] = (int) (trim(str_replace(
'kbps',
579 $AudioCodecBitrate)) * 1000);
582 if (empty($thisfile_video[
'bitrate']) && !empty($thisfile_audio[
'bitrate']) && !empty(
$info[
'bitrate'])) {
584 $thisfile_video[
'bitrate'] =
$info[
'bitrate'] - $thisfile_audio[
'bitrate'];
587 $AudioCodecFrequency = (int) trim(str_replace(
'kHz',
589 $AudioCodecFrequency));
590 switch ($AudioCodecFrequency) {
593 $thisfile_audio[
'sample_rate'] = 8000;
598 $thisfile_audio[
'sample_rate'] = 11025;
603 $thisfile_audio[
'sample_rate'] = 12000;
608 $thisfile_audio[
'sample_rate'] = 16000;
613 $thisfile_audio[
'sample_rate'] = 22050;
618 $thisfile_audio[
'sample_rate'] = 24000;
623 $thisfile_audio[
'sample_rate'] = 32000;
628 $thisfile_audio[
'sample_rate'] = 44100;
633 $thisfile_audio[
'sample_rate'] = 48000;
637 $info[
'warning'][] =
'unknown frequency: "' . $AudioCodecFrequency .
'" (' . self::TrimConvert($thisfile_asf_codeclistobject_codecentries_current[
'description']) .
')';
641 if (!isset($thisfile_audio[
'channels'])) {
642 if (strstr($AudioCodecChannels,
'stereo')) {
643 $thisfile_audio[
'channels'] = 2;
644 } elseif (strstr($AudioCodecChannels,
'mono')) {
645 $thisfile_audio[
'channels'] = 1;
653 case self::$GETID3_ASF_Script_Command_Object:
670 $thisfile_asf[
'script_command_object'] =
array();
671 $thisfile_asf_scriptcommandobject = &$thisfile_asf[
'script_command_object'];
673 $thisfile_asf_scriptcommandobject[
'offset'] = $NextObjectOffset + $offset;
674 $thisfile_asf_scriptcommandobject[
'objectid'] = $NextObjectGUID;
675 $thisfile_asf_scriptcommandobject[
'objectid_guid'] = $NextObjectGUIDtext;
676 $thisfile_asf_scriptcommandobject[
'objectsize'] = $NextObjectSize;
677 $thisfile_asf_scriptcommandobject[
'reserved'] = substr($ASFHeaderData,
681 $thisfile_asf_scriptcommandobject[
'reserved_guid'] = self::BytestringToGUID($thisfile_asf_scriptcommandobject[
'reserved']);
682 if ($thisfile_asf_scriptcommandobject[
'reserved'] != self::GUIDtoBytestring(
'4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
683 $info[
'warning'][] =
'script_command_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_scriptcommandobject[
'reserved']) .
'} does not match expected "GETID3_ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}';
695 for ($CommandTypesCounter = 0;
696 $CommandTypesCounter < $thisfile_asf_scriptcommandobject[
'command_types_count'];
697 $CommandTypesCounter++) {
702 $thisfile_asf_scriptcommandobject[
'command_types'][$CommandTypesCounter][
'name'] = substr($ASFHeaderData,
704 $CommandTypeNameLength);
705 $offset += $CommandTypeNameLength;
707 for ($CommandsCounter = 0;
708 $CommandsCounter < $thisfile_asf_scriptcommandobject[
'commands_count'];
709 $CommandsCounter++) {
710 $thisfile_asf_scriptcommandobject[
'commands'][$CommandsCounter][
'presentation_time'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
714 $thisfile_asf_scriptcommandobject[
'commands'][$CommandsCounter][
'type_index'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
723 $thisfile_asf_scriptcommandobject[
'commands'][$CommandsCounter][
'name'] = substr($ASFHeaderData,
725 $CommandTypeNameLength);
726 $offset += $CommandTypeNameLength;
730 case self::$GETID3_ASF_Marker_Object:
750 $thisfile_asf[
'marker_object'] =
array();
751 $thisfile_asf_markerobject = &$thisfile_asf[
'marker_object'];
753 $thisfile_asf_markerobject[
'offset'] = $NextObjectOffset + $offset;
754 $thisfile_asf_markerobject[
'objectid'] = $NextObjectGUID;
755 $thisfile_asf_markerobject[
'objectid_guid'] = $NextObjectGUIDtext;
756 $thisfile_asf_markerobject[
'objectsize'] = $NextObjectSize;
757 $thisfile_asf_markerobject[
'reserved'] = substr($ASFHeaderData,
760 $thisfile_asf_markerobject[
'reserved_guid'] = self::BytestringToGUID($thisfile_asf_markerobject[
'reserved']);
761 if ($thisfile_asf_markerobject[
'reserved'] != self::GUIDtoBytestring(
'4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) {
762 $info[
'warning'][] =
'marker_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_markerobject[
'reserved_1']) .
'} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}';
773 if ($thisfile_asf_markerobject[
'reserved_2'] != 0) {
774 $info[
'warning'][] =
'marker_object.reserved_2 (' .
Helper::PrintHexBytes($thisfile_asf_markerobject[
'reserved_2']) .
') does not match expected value of "0"';
781 $thisfile_asf_markerobject[
'name'] = substr($ASFHeaderData,
783 $thisfile_asf_markerobject[
'name_length']);
784 $offset += $thisfile_asf_markerobject[
'name_length'];
785 for ($MarkersCounter = 0;
786 $MarkersCounter < $thisfile_asf_markerobject[
'markers_count'];
792 $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'presentation_time'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
796 $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'entry_length'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
800 $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'send_time'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
808 $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'marker_description_length'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
812 $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'marker_description'] = substr($ASFHeaderData,
814 $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'marker_description_length']);
815 $offset += $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'marker_description_length'];
816 $PaddingLength = $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'entry_length'] - 4 - 4 - 4 - $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'marker_description_length'];
817 if ($PaddingLength > 0) {
818 $thisfile_asf_markerobject[
'markers'][$MarkersCounter][
'padding'] = substr($ASFHeaderData,
821 $offset += $PaddingLength;
826 case self::$GETID3_ASF_Bitrate_Mutual_Exclusion_Object:
835 $thisfile_asf[
'bitrate_mutual_exclusion_object'] =
array();
836 $thisfile_asf_bitratemutualexclusionobject = &$thisfile_asf[
'bitrate_mutual_exclusion_object'];
838 $thisfile_asf_bitratemutualexclusionobject[
'offset'] = $NextObjectOffset + $offset;
839 $thisfile_asf_bitratemutualexclusionobject[
'objectid'] = $NextObjectGUID;
840 $thisfile_asf_bitratemutualexclusionobject[
'objectid_guid'] = $NextObjectGUIDtext;
841 $thisfile_asf_bitratemutualexclusionobject[
'objectsize'] = $NextObjectSize;
842 $thisfile_asf_bitratemutualexclusionobject[
'reserved'] = substr($ASFHeaderData,
845 $thisfile_asf_bitratemutualexclusionobject[
'reserved_guid'] = self::BytestringToGUID($thisfile_asf_bitratemutualexclusionobject[
'reserved']);
847 if (($thisfile_asf_bitratemutualexclusionobject[
'reserved'] != self::$GETID3_ASF_Mutex_Bitrate) && ($thisfile_asf_bitratemutualexclusionobject[
'reserved'] != self::$GETID3_ASF_Mutex_Unknown)) {
848 $info[
'warning'][] =
'bitrate_mutual_exclusion_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_bitratemutualexclusionobject[
'reserved']) .
'} does not match expected "GETID3_ASF_Mutex_Bitrate" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Mutex_Bitrate) .
'} or "GETID3_ASF_Mutex_Unknown" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Mutex_Unknown) .
'}';
852 $thisfile_asf_bitratemutualexclusionobject[
'stream_numbers_count'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
856 for ($StreamNumberCounter = 0;
857 $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject[
'stream_numbers_count'];
858 $StreamNumberCounter++) {
859 $thisfile_asf_bitratemutualexclusionobject[
'stream_numbers'][$StreamNumberCounter] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
866 case self::$GETID3_ASF_Error_Correction_Object:
875 $thisfile_asf[
'error_correction_object'] =
array();
876 $thisfile_asf_errorcorrectionobject = &$thisfile_asf[
'error_correction_object'];
878 $thisfile_asf_errorcorrectionobject[
'offset'] = $NextObjectOffset + $offset;
879 $thisfile_asf_errorcorrectionobject[
'objectid'] = $NextObjectGUID;
880 $thisfile_asf_errorcorrectionobject[
'objectid_guid'] = $NextObjectGUIDtext;
881 $thisfile_asf_errorcorrectionobject[
'objectsize'] = $NextObjectSize;
882 $thisfile_asf_errorcorrectionobject[
'error_correction_type'] = substr($ASFHeaderData,
886 $thisfile_asf_errorcorrectionobject[
'error_correction_guid'] = self::BytestringToGUID($thisfile_asf_errorcorrectionobject[
'error_correction_type']);
887 $thisfile_asf_errorcorrectionobject[
'error_correction_data_length'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
891 switch ($thisfile_asf_errorcorrectionobject[
'error_correction_type']) {
892 case self::$GETID3_ASF_No_Error_Correction:
894 $offset += $thisfile_asf_errorcorrectionobject[
'error_correction_data_length'];
897 case self::$GETID3_ASF_Audio_Spread:
921 $thisfile_asf_errorcorrectionobject[
'silence_data'] = substr($ASFHeaderData,
923 $thisfile_asf_errorcorrectionobject[
'silence_data_length']);
924 $offset += $thisfile_asf_errorcorrectionobject[
'silence_data_length'];
928 $info[
'warning'][] =
'error_correction_object.error_correction_type GUID {' . self::BytestringToGUID($thisfile_asf_errorcorrectionobject[
'reserved']) .
'} does not match expected "GETID3_ASF_No_Error_Correction" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_No_Error_Correction) .
'} or "GETID3_ASF_Audio_Spread" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Audio_Spread) .
'}';
935 case self::$GETID3_ASF_Content_Description_Object:
951 $thisfile_asf[
'content_description_object'] =
array();
952 $thisfile_asf_contentdescriptionobject = &$thisfile_asf[
'content_description_object'];
954 $thisfile_asf_contentdescriptionobject[
'offset'] = $NextObjectOffset + $offset;
955 $thisfile_asf_contentdescriptionobject[
'objectid'] = $NextObjectGUID;
956 $thisfile_asf_contentdescriptionobject[
'objectid_guid'] = $NextObjectGUIDtext;
957 $thisfile_asf_contentdescriptionobject[
'objectsize'] = $NextObjectSize;
978 $thisfile_asf_contentdescriptionobject[
'title'] = substr($ASFHeaderData,
980 $thisfile_asf_contentdescriptionobject[
'title_length']);
981 $offset += $thisfile_asf_contentdescriptionobject[
'title_length'];
982 $thisfile_asf_contentdescriptionobject[
'author'] = substr($ASFHeaderData,
984 $thisfile_asf_contentdescriptionobject[
'author_length']);
985 $offset += $thisfile_asf_contentdescriptionobject[
'author_length'];
986 $thisfile_asf_contentdescriptionobject[
'copyright'] = substr($ASFHeaderData,
988 $thisfile_asf_contentdescriptionobject[
'copyright_length']);
989 $offset += $thisfile_asf_contentdescriptionobject[
'copyright_length'];
990 $thisfile_asf_contentdescriptionobject[
'description'] = substr($ASFHeaderData,
992 $thisfile_asf_contentdescriptionobject[
'description_length']);
993 $offset += $thisfile_asf_contentdescriptionobject[
'description_length'];
994 $thisfile_asf_contentdescriptionobject[
'rating'] = substr($ASFHeaderData,
996 $thisfile_asf_contentdescriptionobject[
'rating_length']);
997 $offset += $thisfile_asf_contentdescriptionobject[
'rating_length'];
999 $ASFcommentKeysToCopy =
array(
'title' =>
'title',
'author' =>
'artist',
'copyright' =>
'copyright',
'description' =>
'comment',
'rating' =>
'rating');
1000 foreach ($ASFcommentKeysToCopy as $keytocopyfrom => $keytocopyto) {
1001 if (!empty($thisfile_asf_contentdescriptionobject[$keytocopyfrom])) {
1002 $thisfile_asf_comments[$keytocopyto][] = self::TrimTerm($thisfile_asf_contentdescriptionobject[$keytocopyfrom]);
1007 case self::$GETID3_ASF_Extended_Content_Description_Object:
1026 $thisfile_asf[
'extended_content_description_object'] =
array();
1027 $thisfile_asf_extendedcontentdescriptionobject = &$thisfile_asf[
'extended_content_description_object'];
1029 $thisfile_asf_extendedcontentdescriptionobject[
'offset'] = $NextObjectOffset + $offset;
1030 $thisfile_asf_extendedcontentdescriptionobject[
'objectid'] = $NextObjectGUID;
1031 $thisfile_asf_extendedcontentdescriptionobject[
'objectid_guid'] = $NextObjectGUIDtext;
1032 $thisfile_asf_extendedcontentdescriptionobject[
'objectsize'] = $NextObjectSize;
1033 $thisfile_asf_extendedcontentdescriptionobject[
'content_descriptors_count'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
1037 for ($ExtendedContentDescriptorsCounter = 0;
1038 $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject[
'content_descriptors_count'];
1039 $ExtendedContentDescriptorsCounter++) {
1041 $thisfile_asf_extendedcontentdescriptionobject[
'content_descriptors'][$ExtendedContentDescriptorsCounter] =
array();
1042 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current = &$thisfile_asf_extendedcontentdescriptionobject[
'content_descriptors'][$ExtendedContentDescriptorsCounter];
1044 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'base_offset'] = $offset + 30;
1045 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'name_length'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
1049 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'name'] = substr($ASFHeaderData,
1051 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'name_length']);
1052 $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'name_length'];
1053 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value_type'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
1057 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value_length'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
1061 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value'] = substr($ASFHeaderData,
1063 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value_length']);
1064 $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value_length'];
1065 switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value_type']) {
1074 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value'] = (bool)
Helper::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']);
1080 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value'] =
Helper::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']);
1084 $info[
'warning'][] =
'extended_content_description.content_descriptors.' . $ExtendedContentDescriptorsCounter .
'.value_type is invalid (' . $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value_type'] .
')';
1088 switch (self::TrimConvert(strtolower($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'name']))) {
1090 case 'wm/albumartist':
1093 $thisfile_asf_comments[
'albumartist'] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1096 case 'wm/albumtitle':
1098 $thisfile_asf_comments[
'album'] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1103 $thisfile_asf_comments[
'genre'] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1106 case 'wm/partofset':
1107 $thisfile_asf_comments[
'partofset'] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1110 case 'wm/tracknumber':
1113 $thisfile_asf_comments[
'track'] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1114 foreach ($thisfile_asf_comments[
'track'] as $key => $value) {
1115 if (preg_match(
'/^[0-9\x00]+$/', $value)) {
1116 $thisfile_asf_comments[
'track'][$key] = intval(str_replace(
"\x00",
1124 if (empty($thisfile_asf_comments[
'track'])) {
1125 $thisfile_asf_comments[
'track'] =
array(1 + self::TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1132 $thisfile_asf_comments[
'year'] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1137 $thisfile_asf_comments[
'lyrics'] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1141 if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']) {
1142 $thisfile_audio[
'bitrate_mode'] =
'vbr';
1143 $thisfile_video[
'bitrate_mode'] =
'vbr';
1149 if (class_exists(
'getid3_id3v2')) {
1152 $tempfilehandle = fopen($tempfile,
'wb');
1153 $tempThisfileInfo =
array(
'encoding' =>
$info[
'encoding']);
1154 fwrite($tempfilehandle,
1155 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']);
1156 fclose($tempfilehandle);
1158 $getid3_temp =
new GetId3Core();
1159 $getid3_temp->openfile($tempfile);
1160 $getid3_id3v2 =
new Id3v2($getid3_temp);
1161 $getid3_id3v2->analyze();
1162 $info[
'id3v2'] = $getid3_temp->info[
'id3v2'];
1163 unset($getid3_temp, $getid3_id3v2);
1169 case 'wm/encodingtime':
1170 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'encoding_time_unix'] = self::FILETIMEtoUNIXtime($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']);
1171 $thisfile_asf_comments[
'encoding_time_unix'] =
array($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'encoding_time_unix']);
1175 $WMpicture = $this->
ASF_WMpicture($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']);
1176 foreach ($WMpicture as $key => $value) {
1177 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[$key] = $value;
1221 switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value_type']) {
1223 if (substr(self::TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'name']),
1225 $thisfile_asf_comments[str_replace(
'wm/',
1227 strtolower(self::TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'name'])))] =
array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[
'value']));
1239 case self::$GETID3_ASF_Stream_Bitrate_Properties_Object:
1251 $thisfile_asf[
'stream_bitrate_properties_object'] =
array();
1252 $thisfile_asf_streambitratepropertiesobject = &$thisfile_asf[
'stream_bitrate_properties_object'];
1254 $thisfile_asf_streambitratepropertiesobject[
'offset'] = $NextObjectOffset + $offset;
1255 $thisfile_asf_streambitratepropertiesobject[
'objectid'] = $NextObjectGUID;
1256 $thisfile_asf_streambitratepropertiesobject[
'objectid_guid'] = $NextObjectGUIDtext;
1257 $thisfile_asf_streambitratepropertiesobject[
'objectsize'] = $NextObjectSize;
1258 $thisfile_asf_streambitratepropertiesobject[
'bitrate_records_count'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
1262 for ($BitrateRecordsCounter = 0;
1263 $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject[
'bitrate_records_count'];
1264 $BitrateRecordsCounter++) {
1265 $thisfile_asf_streambitratepropertiesobject[
'bitrate_records'][$BitrateRecordsCounter][
'flags_raw'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
1269 $thisfile_asf_streambitratepropertiesobject[
'bitrate_records'][$BitrateRecordsCounter][
'flags'][
'stream_number'] = $thisfile_asf_streambitratepropertiesobject[
'bitrate_records'][$BitrateRecordsCounter][
'flags_raw'] & 0x007F;
1270 $thisfile_asf_streambitratepropertiesobject[
'bitrate_records'][$BitrateRecordsCounter][
'bitrate'] =
Helper::LittleEndian2Int(substr($ASFHeaderData,
1277 case self::$GETID3_ASF_Padding_Object:
1284 $thisfile_asf[
'padding_object'] =
array();
1285 $thisfile_asf_paddingobject = &$thisfile_asf[
'padding_object'];
1287 $thisfile_asf_paddingobject[
'offset'] = $NextObjectOffset + $offset;
1288 $thisfile_asf_paddingobject[
'objectid'] = $NextObjectGUID;
1289 $thisfile_asf_paddingobject[
'objectid_guid'] = $NextObjectGUIDtext;
1290 $thisfile_asf_paddingobject[
'objectsize'] = $NextObjectSize;
1291 $thisfile_asf_paddingobject[
'padding_length'] = $thisfile_asf_paddingobject[
'objectsize'] - 16 - 8;
1292 $thisfile_asf_paddingobject[
'padding'] = substr($ASFHeaderData,
1294 $thisfile_asf_paddingobject[
'padding_length']);
1295 $offset += ($NextObjectSize - 16 - 8);
1298 case self::$GETID3_ASF_Extended_Content_Encryption_Object:
1299 case self::$GETID3_ASF_Content_Encryption_Object:
1301 $offset += ($NextObjectSize - 16 - 8);
1306 if (self::GUIDname($NextObjectGUIDtext)) {
1307 $info[
'warning'][] =
'unhandled GUID "' . self::GUIDname($NextObjectGUIDtext) .
'" {' . $NextObjectGUIDtext .
'} in ASF header at offset ' . ($offset - 16 - 8);
1309 $info[
'warning'][] =
'unknown GUID {' . $NextObjectGUIDtext .
'} in ASF header at offset ' . ($offset - 16 - 8);
1311 $offset += ($NextObjectSize - 16 - 8);
1315 if (isset($thisfile_asf_streambitrateproperties[
'bitrate_records_count'])) {
1316 $ASFbitrateAudio = 0;
1317 $ASFbitrateVideo = 0;
1318 for ($BitrateRecordsCounter = 0;
1319 $BitrateRecordsCounter < $thisfile_asf_streambitrateproperties[
'bitrate_records_count'];
1320 $BitrateRecordsCounter++) {
1321 if (isset($thisfile_asf_codeclistobject[
'codec_entries'][$BitrateRecordsCounter])) {
1322 switch ($thisfile_asf_codeclistobject[
'codec_entries'][$BitrateRecordsCounter][
'type_raw']) {
1324 $ASFbitrateVideo += $thisfile_asf_streambitrateproperties[
'bitrate_records'][$BitrateRecordsCounter][
'bitrate'];
1328 $ASFbitrateAudio += $thisfile_asf_streambitrateproperties[
'bitrate_records'][$BitrateRecordsCounter][
'bitrate'];
1337 if ($ASFbitrateAudio > 0) {
1338 $thisfile_audio[
'bitrate'] = $ASFbitrateAudio;
1340 if ($ASFbitrateVideo > 0) {
1341 $thisfile_video[
'bitrate'] = $ASFbitrateVideo;
1344 if (isset($thisfile_asf[
'stream_properties_object']) && is_array($thisfile_asf[
'stream_properties_object'])) {
1346 $thisfile_audio[
'bitrate'] = 0;
1347 $thisfile_video[
'bitrate'] = 0;
1349 foreach ($thisfile_asf[
'stream_properties_object'] as $streamnumber => $streamdata) {
1351 switch ($streamdata[
'stream_type']) {
1352 case self::$GETID3_ASF_Audio_Media:
1363 $thisfile_asf[
'audio_media'][$streamnumber] =
array();
1364 $thisfile_asf_audiomedia_currentstream = &$thisfile_asf[
'audio_media'][$streamnumber];
1366 $audiomediaoffset = 0;
1371 $audiomediaoffset += 16;
1373 $thisfile_audio[
'lossless'] =
false;
1374 switch ($thisfile_asf_audiomedia_currentstream[
'raw'][
'wFormatTag']) {
1377 $thisfile_audio[
'lossless'] =
true;
1381 if (!empty($thisfile_asf[
'stream_bitrate_properties_object'][
'bitrate_records'])) {
1382 foreach ($thisfile_asf[
'stream_bitrate_properties_object'][
'bitrate_records'] as $dummy => $dataarray) {
1383 if (isset($dataarray[
'flags'][
'stream_number']) && ($dataarray[
'flags'][
'stream_number'] == $streamnumber)) {
1384 $thisfile_asf_audiomedia_currentstream[
'bitrate'] = $dataarray[
'bitrate'];
1385 $thisfile_audio[
'bitrate'] += $dataarray[
'bitrate'];
1390 if (!empty($thisfile_asf_audiomedia_currentstream[
'bytes_sec'])) {
1391 $thisfile_audio[
'bitrate'] += $thisfile_asf_audiomedia_currentstream[
'bytes_sec'] * 8;
1392 } elseif (!empty($thisfile_asf_audiomedia_currentstream[
'bitrate'])) {
1393 $thisfile_audio[
'bitrate'] += $thisfile_asf_audiomedia_currentstream[
'bitrate'];
1396 $thisfile_audio[
'streams'][$streamnumber] = $thisfile_asf_audiomedia_currentstream;
1397 $thisfile_audio[
'streams'][$streamnumber][
'wformattag'] = $thisfile_asf_audiomedia_currentstream[
'raw'][
'wFormatTag'];
1398 $thisfile_audio[
'streams'][$streamnumber][
'lossless'] = $thisfile_audio[
'lossless'];
1399 $thisfile_audio[
'streams'][$streamnumber][
'bitrate'] = $thisfile_audio[
'bitrate'];
1400 $thisfile_audio[
'streams'][$streamnumber][
'dataformat'] =
'wma';
1401 unset($thisfile_audio[
'streams'][$streamnumber][
'raw']);
1403 $thisfile_asf_audiomedia_currentstream[
'codec_data_size'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1406 $audiomediaoffset += 2;
1407 $thisfile_asf_audiomedia_currentstream[
'codec_data'] = substr($streamdata[
'type_specific_data'],
1409 $thisfile_asf_audiomedia_currentstream[
'codec_data_size']);
1410 $audiomediaoffset += $thisfile_asf_audiomedia_currentstream[
'codec_data_size'];
1414 case self::$GETID3_ASF_Video_Media:
1434 $thisfile_asf[
'video_media'][$streamnumber] =
array();
1435 $thisfile_asf_videomedia_currentstream = &$thisfile_asf[
'video_media'][$streamnumber];
1437 $videomediaoffset = 0;
1438 $thisfile_asf_videomedia_currentstream[
'image_width'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1441 $videomediaoffset += 4;
1442 $thisfile_asf_videomedia_currentstream[
'image_height'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1445 $videomediaoffset += 4;
1446 $thisfile_asf_videomedia_currentstream[
'flags'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1449 $videomediaoffset += 1;
1450 $thisfile_asf_videomedia_currentstream[
'format_data_size'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1453 $videomediaoffset += 2;
1454 $thisfile_asf_videomedia_currentstream[
'format_data'][
'format_data_size'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1457 $videomediaoffset += 4;
1458 $thisfile_asf_videomedia_currentstream[
'format_data'][
'image_width'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1461 $videomediaoffset += 4;
1462 $thisfile_asf_videomedia_currentstream[
'format_data'][
'image_height'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1465 $videomediaoffset += 4;
1466 $thisfile_asf_videomedia_currentstream[
'format_data'][
'reserved'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1469 $videomediaoffset += 2;
1470 $thisfile_asf_videomedia_currentstream[
'format_data'][
'bits_per_pixel'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1473 $videomediaoffset += 2;
1474 $thisfile_asf_videomedia_currentstream[
'format_data'][
'codec_fourcc'] = substr($streamdata[
'type_specific_data'],
1477 $videomediaoffset += 4;
1478 $thisfile_asf_videomedia_currentstream[
'format_data'][
'image_size'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1481 $videomediaoffset += 4;
1482 $thisfile_asf_videomedia_currentstream[
'format_data'][
'horizontal_pels'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1485 $videomediaoffset += 4;
1486 $thisfile_asf_videomedia_currentstream[
'format_data'][
'vertical_pels'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1489 $videomediaoffset += 4;
1490 $thisfile_asf_videomedia_currentstream[
'format_data'][
'colors_used'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1493 $videomediaoffset += 4;
1494 $thisfile_asf_videomedia_currentstream[
'format_data'][
'colors_important'] =
Helper::LittleEndian2Int(substr($streamdata[
'type_specific_data'],
1497 $videomediaoffset += 4;
1498 $thisfile_asf_videomedia_currentstream[
'format_data'][
'codec_data'] = substr($streamdata[
'type_specific_data'],
1501 if (!empty($thisfile_asf[
'stream_bitrate_properties_object'][
'bitrate_records'])) {
1502 foreach ($thisfile_asf[
'stream_bitrate_properties_object'][
'bitrate_records'] as $dummy => $dataarray) {
1503 if (isset($dataarray[
'flags'][
'stream_number']) && ($dataarray[
'flags'][
'stream_number'] == $streamnumber)) {
1504 $thisfile_asf_videomedia_currentstream[
'bitrate'] = $dataarray[
'bitrate'];
1505 $thisfile_video[
'streams'][$streamnumber][
'bitrate'] = $dataarray[
'bitrate'];
1506 $thisfile_video[
'bitrate'] += $dataarray[
'bitrate'];
1512 $thisfile_asf_videomedia_currentstream[
'format_data'][
'codec'] =
Riff::RIFFfourccLookup($thisfile_asf_videomedia_currentstream[
'format_data'][
'codec_fourcc']);
1514 $thisfile_video[
'streams'][$streamnumber][
'fourcc'] = $thisfile_asf_videomedia_currentstream[
'format_data'][
'codec_fourcc'];
1515 $thisfile_video[
'streams'][$streamnumber][
'codec'] = $thisfile_asf_videomedia_currentstream[
'format_data'][
'codec'];
1516 $thisfile_video[
'streams'][$streamnumber][
'resolution_x'] = $thisfile_asf_videomedia_currentstream[
'image_width'];
1517 $thisfile_video[
'streams'][$streamnumber][
'resolution_y'] = $thisfile_asf_videomedia_currentstream[
'image_height'];
1518 $thisfile_video[
'streams'][$streamnumber][
'bits_per_sample'] = $thisfile_asf_videomedia_currentstream[
'format_data'][
'bits_per_pixel'];
1525 }
while (
ftell($this->getid3->fp) <
$info[
'avdataend']) {
1526 $NextObjectDataHeader =
fread($this->getid3->fp, 24);
1528 $NextObjectGUID = substr($NextObjectDataHeader, 0, 16);
1530 $NextObjectGUIDtext = self::BytestringToGUID($NextObjectGUID);
1536 switch ($NextObjectGUID) {
1537 case self::$GETID3_ASF_Data_Object:
1546 $thisfile_asf[
'data_object'] =
array();
1547 $thisfile_asf_dataobject = &$thisfile_asf[
'data_object'];
1549 $DataObjectData = $NextObjectDataHeader .
fread($this->getid3->fp,
1553 $thisfile_asf_dataobject[
'objectid'] = $NextObjectGUID;
1554 $thisfile_asf_dataobject[
'objectid_guid'] = $NextObjectGUIDtext;
1555 $thisfile_asf_dataobject[
'objectsize'] = $NextObjectSize;
1557 $thisfile_asf_dataobject[
'fileid'] = substr($DataObjectData,
1560 $thisfile_asf_dataobject[
'fileid_guid'] = self::BytestringToGUID($thisfile_asf_dataobject[
'fileid']);
1569 if ($thisfile_asf_dataobject[
'reserved'] != 0x0101) {
1570 $info[
'warning'][] =
'data_object.reserved (' .
Helper::PrintHexBytes($thisfile_asf_dataobject[
'reserved']) .
') does not match expected value of "0x0101"';
1583 $info[
'avdataoffset'] =
ftell($this->getid3->fp);
1584 fseek($this->getid3->fp,
1585 ($thisfile_asf_dataobject[
'objectsize'] - 50),
1587 $info[
'avdataend'] =
ftell($this->getid3->fp);
1590 case self::$GETID3_ASF_Simple_Index_Object:
1603 $thisfile_asf[
'simple_index_object'] =
array();
1604 $thisfile_asf_simpleindexobject = &$thisfile_asf[
'simple_index_object'];
1606 $SimpleIndexObjectData = $NextObjectDataHeader .
fread($this->getid3->fp,
1610 $thisfile_asf_simpleindexobject[
'objectid'] = $NextObjectGUID;
1611 $thisfile_asf_simpleindexobject[
'objectid_guid'] = $NextObjectGUIDtext;
1612 $thisfile_asf_simpleindexobject[
'objectsize'] = $NextObjectSize;
1614 $thisfile_asf_simpleindexobject[
'fileid'] = substr($SimpleIndexObjectData,
1618 $thisfile_asf_simpleindexobject[
'fileid_guid'] = self::BytestringToGUID($thisfile_asf_simpleindexobject[
'fileid']);
1619 $thisfile_asf_simpleindexobject[
'index_entry_time_interval'] =
Helper::LittleEndian2Int(substr($SimpleIndexObjectData,
1632 $IndexEntriesData = $SimpleIndexObjectData .
fread($this->getid3->fp,
1633 6 * $thisfile_asf_simpleindexobject[
'index_entries_count']);
1634 for ($IndexEntriesCounter = 0;
1635 $IndexEntriesCounter < $thisfile_asf_simpleindexobject[
'index_entries_count'];
1636 $IndexEntriesCounter++) {
1637 $thisfile_asf_simpleindexobject[
'index_entries'][$IndexEntriesCounter][
'packet_number'] =
Helper::LittleEndian2Int(substr($IndexEntriesData,
1641 $thisfile_asf_simpleindexobject[
'index_entries'][$IndexEntriesCounter][
'packet_count'] =
Helper::LittleEndian2Int(substr($IndexEntriesData,
1649 case self::$GETID3_ASF_Index_Object:
1671 $thisfile_asf[
'asf_index_object'] =
array();
1672 $thisfile_asf_asfindexobject = &$thisfile_asf[
'asf_index_object'];
1674 $ASFIndexObjectData = $NextObjectDataHeader .
fread($this->getid3->fp,
1678 $thisfile_asf_asfindexobject[
'objectid'] = $NextObjectGUID;
1679 $thisfile_asf_asfindexobject[
'objectid_guid'] = $NextObjectGUIDtext;
1680 $thisfile_asf_asfindexobject[
'objectsize'] = $NextObjectSize;
1695 $ASFIndexObjectData .=
fread($this->getid3->fp,
1696 4 * $thisfile_asf_asfindexobject[
'index_specifiers_count']);
1697 for ($IndexSpecifiersCounter = 0;
1698 $IndexSpecifiersCounter < $thisfile_asf_asfindexobject[
'index_specifiers_count'];
1699 $IndexSpecifiersCounter++) {
1704 $thisfile_asf_asfindexobject[
'index_specifiers'][$IndexSpecifiersCounter][
'stream_number'] = $IndexSpecifierStreamNumber;
1705 $thisfile_asf_asfindexobject[
'index_specifiers'][$IndexSpecifiersCounter][
'index_type'] =
Helper::LittleEndian2Int(substr($ASFIndexObjectData,
1709 $thisfile_asf_asfindexobject[
'index_specifiers'][$IndexSpecifiersCounter][
'index_type_text'] = $this->
ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject[
'index_specifiers'][$IndexSpecifiersCounter][
'index_type']);
1712 $ASFIndexObjectData .=
fread($this->getid3->fp, 4);
1718 $ASFIndexObjectData .=
fread($this->getid3->fp,
1719 8 * $thisfile_asf_asfindexobject[
'index_specifiers_count']);
1720 for ($IndexSpecifiersCounter = 0;
1721 $IndexSpecifiersCounter < $thisfile_asf_asfindexobject[
'index_specifiers_count'];
1722 $IndexSpecifiersCounter++) {
1723 $thisfile_asf_asfindexobject[
'block_positions'][$IndexSpecifiersCounter] =
Helper::LittleEndian2Int(substr($ASFIndexObjectData,
1729 $ASFIndexObjectData .=
fread($this->getid3->fp,
1730 4 * $thisfile_asf_asfindexobject[
'index_specifiers_count'] * $thisfile_asf_asfindexobject[
'index_entry_count']);
1731 for ($IndexEntryCounter = 0;
1732 $IndexEntryCounter < $thisfile_asf_asfindexobject[
'index_entry_count'];
1733 $IndexEntryCounter++) {
1734 for ($IndexSpecifiersCounter = 0;
1735 $IndexSpecifiersCounter < $thisfile_asf_asfindexobject[
'index_specifiers_count'];
1736 $IndexSpecifiersCounter++) {
1737 $thisfile_asf_asfindexobject[
'offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] =
Helper::LittleEndian2Int(substr($ASFIndexObjectData,
1748 if (self::GUIDname($NextObjectGUIDtext)) {
1749 $info[
'warning'][] =
'unhandled GUID "' . self::GUIDname($NextObjectGUIDtext) .
'" {' . $NextObjectGUIDtext .
'} in ASF body at offset ' . ($offset - 16 - 8);
1751 $info[
'warning'][] =
'unknown GUID {' . $NextObjectGUIDtext .
'} in ASF body at offset ' . (
ftell($this->getid3->fp) - 16 - 8);
1753 fseek($this->getid3->fp, ($NextObjectSize - 16 - 8),
1759 if (isset($thisfile_asf_codeclistobject[
'codec_entries']) && is_array($thisfile_asf_codeclistobject[
'codec_entries'])) {
1760 foreach ($thisfile_asf_codeclistobject[
'codec_entries'] as $streamnumber => $streamdata) {
1761 switch ($streamdata[
'information']) {
1771 $thisfile_video[
'dataformat'] =
'wmv';
1772 $info[
'mime_type'] =
'video/x-ms-wmv';
1779 $thisfile_video[
'dataformat'] =
'asf';
1780 $info[
'mime_type'] =
'video/x-ms-asf';
1784 switch ($streamdata[
'type_raw']) {
1786 if (strstr(self::TrimConvert($streamdata[
'name']),
1788 $thisfile_video[
'dataformat'] =
'wmv';
1789 if (
$info[
'mime_type'] ==
'video/x-ms-asf') {
1790 $info[
'mime_type'] =
'video/x-ms-wmv';
1796 if (strstr(self::TrimConvert($streamdata[
'name']),
1798 $thisfile_audio[
'dataformat'] =
'wma';
1799 if (
$info[
'mime_type'] ==
'video/x-ms-asf') {
1800 $info[
'mime_type'] =
'audio/x-ms-wma';
1810 switch (isset($thisfile_audio[
'codec']) ? $thisfile_audio[
'codec'] :
'') {
1811 case 'MPEG Layer-3':
1812 $thisfile_audio[
'dataformat'] =
'mp3';
1819 if (isset($thisfile_asf_codeclistobject[
'codec_entries'])) {
1820 foreach ($thisfile_asf_codeclistobject[
'codec_entries'] as $streamnumber => $streamdata) {
1821 switch ($streamdata[
'type_raw']) {
1824 $thisfile_video[
'encoder'] = self::TrimConvert($thisfile_asf_codeclistobject[
'codec_entries'][$streamnumber][
'name']);
1828 $thisfile_audio[
'encoder'] = self::TrimConvert($thisfile_asf_codeclistobject[
'codec_entries'][$streamnumber][
'name']);
1831 $thisfile_audio[
'encoder_options'] = self::TrimConvert($thisfile_asf_codeclistobject[
'codec_entries'][0][
'description']);
1833 $thisfile_audio[
'codec'] = $thisfile_audio[
'encoder'];
1837 $info[
'warning'][] =
'Unknown streamtype: [codec_list_object][codec_entries][' . $streamnumber .
'][type_raw] == ' . $streamdata[
'type_raw'];
1843 if (isset(
$info[
'audio'])) {
1844 $thisfile_audio[
'lossless'] = (isset($thisfile_audio[
'lossless']) ? $thisfile_audio[
'lossless'] :
false);
1845 $thisfile_audio[
'dataformat'] = (!empty($thisfile_audio[
'dataformat']) ? $thisfile_audio[
'dataformat'] :
'asf');
1847 if (!empty($thisfile_video[
'dataformat'])) {
1848 $thisfile_video[
'lossless'] = (isset($thisfile_audio[
'lossless']) ? $thisfile_audio[
'lossless'] :
false);
1849 $thisfile_video[
'pixel_aspect_ratio'] = (isset($thisfile_audio[
'pixel_aspect_ratio']) ? $thisfile_audio[
'pixel_aspect_ratio'] : (float) 1);
1850 $thisfile_video[
'dataformat'] = (!empty($thisfile_video[
'dataformat']) ? $thisfile_video[
'dataformat'] :
'asf');
1852 if (!empty($thisfile_video[
'streams'])) {
1853 $thisfile_video[
'streams'][
'resolution_x'] = 0;
1854 $thisfile_video[
'streams'][
'resolution_y'] = 0;
1855 foreach ($thisfile_video[
'streams'] as $key => $valuearray) {
1856 if (($valuearray[
'resolution_x'] > $thisfile_video[
'streams'][
'resolution_x']) || ($valuearray[
'resolution_y'] > $thisfile_video[
'streams'][
'resolution_y'])) {
1857 $thisfile_video[
'resolution_x'] = $valuearray[
'resolution_x'];
1858 $thisfile_video[
'resolution_y'] = $valuearray[
'resolution_y'];
1862 $info[
'bitrate'] = (isset($thisfile_audio[
'bitrate']) ? $thisfile_audio[
'bitrate'] : 0) + (isset($thisfile_video[
'bitrate']) ? $thisfile_video[
'bitrate'] : 0);
1864 if ((!isset(
$info[
'playtime_seconds']) || (
$info[
'playtime_seconds'] <= 0)) && (
$info[
'bitrate'] > 0)) {
1865 $info[
'playtime_seconds'] = (
$info[
'filesize'] -
$info[
'avdataoffset']) / (
$info[
'bitrate'] / 8);
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
static RIFFparseWAVEFORMATex($WaveFormatExData)
static RIFFfourccLookup($fourcc)
fseek($bytes, $whence=SEEK_SET)
static ASFIndexObjectIndexTypeLookup($id)
Create styles array
The data for the language used.
static ASFCodecListObjectTypeLookup($CodecListType)
ASF_HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections)
static LittleEndian2Int($byteword, $signed=false)
static array_merge_noclobber($array1, $array2)