Пример #1
0
function getID3v1Filepointer(&$fd, &$ThisFileInfo)
{
    fseek($fd, -128, SEEK_END);
    $id3v1tag = fread($fd, 128);
    if (substr($id3v1tag, 0, 3) == 'TAG') {
        $ThisFileInfo['avdataend'] = $ThisFileInfo['filesize'] - 128;
        require_once GETID3_INCLUDEPATH . 'getid3.id3.php';
        $ThisFileInfo['id3v1']['title'] = trim(substr($id3v1tag, 3, 30));
        $ThisFileInfo['id3v1']['artist'] = trim(substr($id3v1tag, 33, 30));
        $ThisFileInfo['id3v1']['album'] = trim(substr($id3v1tag, 63, 30));
        $ThisFileInfo['id3v1']['year'] = trim(substr($id3v1tag, 93, 4));
        $ThisFileInfo['id3v1']['comment'] = substr($id3v1tag, 97, 30);
        // can't remove nulls yet, track detection depends on them
        $ThisFileInfo['id3v1']['genreid'] = ord(substr($id3v1tag, 127, 1));
        if (substr($ThisFileInfo['id3v1']['comment'], 28, 1) === chr(0) && substr($ThisFileInfo['id3v1']['comment'], 29, 1) !== chr(0)) {
            $ThisFileInfo['id3v1']['track'] = ord(substr($ThisFileInfo['id3v1']['comment'], 29, 1));
            $ThisFileInfo['id3v1']['comment'] = substr($ThisFileInfo['id3v1']['comment'], 0, 28);
        }
        $ThisFileInfo['id3v1']['comment'] = trim($ThisFileInfo['id3v1']['comment']);
        $ThisFileInfo['id3v1']['genre'] = LookupGenre($ThisFileInfo['id3v1']['genreid']);
        $ThisFileInfo['tags'][] = 'id3v1';
        // Do not change fileformat if already set
        if (empty($ThisFileInfo['fileformat'])) {
            $ThisFileInfo['fileformat'] = 'id3';
        }
        // ID3v1 has lowest preference. We add if $ThisFileInfo[comments] is empty - this will override empty tags of higher preference, or add comments to root if not already present
        if (isset($ThisFileInfo['id3v1'])) {
            CopyFormatCommentsToRootComments($ThisFileInfo['id3v1'], $ThisFileInfo, true, false, false);
        }
    }
    return true;
}
function getID3v1Filepointer($fd)
{
    $offset = 0;
    fseek($fd, -128, SEEK_END);
    $id3v1tag = fread($fd, 128);
    $id3v1info['title'] = trim(substr($id3v1tag, 3, 30));
    $id3v1info['artist'] = trim(substr($id3v1tag, 33, 30));
    $id3v1info['album'] = trim(substr($id3v1tag, 63, 30));
    $id3v1info['year'] = trim(substr($id3v1tag, 93, 4));
    $id3v1info['comment'] = substr($id3v1tag, 97, 30);
    // can't remove NULLs yet, track detection depends on them
    $id3v1info['genreid'] = ord(substr($id3v1tag, 127, 1));
    if (substr($id3v1info['comment'], 28, 1) === chr(0) && substr($id3v1info['comment'], 29, 1) !== chr(0)) {
        $id3v1info['track'] = ord(substr($id3v1info['comment'], 29, 1));
        $id3v1info['comment'] = substr($id3v1info['comment'], 0, 28);
    }
    $id3v1info['comment'] = trim($id3v1info['comment']);
    $id3v1info['genre'] = LookupGenre($id3v1info['genreid']);
    return $id3v1info;
}
Пример #3
0
function getID3v1Filepointer(&$fd, &$ThisFileInfo)
{
    fseek($fd, -128, SEEK_END);
    $id3v1tag = fread($fd, 128);
    if (substr($id3v1tag, 0, 3) == 'TAG') {
        require_once GETID3_INCLUDEPATH . 'getid3.id3.php';
        $ThisFileInfo['id3v1']['title'] = trim(substr($id3v1tag, 3, 30));
        $ThisFileInfo['id3v1']['artist'] = trim(substr($id3v1tag, 33, 30));
        $ThisFileInfo['id3v1']['album'] = trim(substr($id3v1tag, 63, 30));
        $ThisFileInfo['id3v1']['year'] = trim(substr($id3v1tag, 93, 4));
        $ThisFileInfo['id3v1']['comment'] = substr($id3v1tag, 97, 30);
        // can't remove nulls yet, track detection depends on them
        $ThisFileInfo['id3v1']['genreid'] = ord(substr($id3v1tag, 127, 1));
        if (substr($ThisFileInfo['id3v1']['comment'], 28, 1) === chr(0) && substr($ThisFileInfo['id3v1']['comment'], 29, 1) !== chr(0)) {
            $ThisFileInfo['id3v1']['track'] = ord(substr($ThisFileInfo['id3v1']['comment'], 29, 1));
            $ThisFileInfo['id3v1']['comment'] = substr($ThisFileInfo['id3v1']['comment'], 0, 28);
        }
        $ThisFileInfo['id3v1']['comment'] = trim($ThisFileInfo['id3v1']['comment']);
        $ThisFileInfo['id3v1']['genre'] = LookupGenre($ThisFileInfo['id3v1']['genreid']);
        return true;
    }
    return false;
}
Пример #4
0
function getASFHeaderFilepointer(&$fd, &$ThisFileInfo)
{
    // ASF structure:
    // * Header Object [required]
    //   * File Properties Object [required]   (global file attributes)
    //   * Stream Properties Object [required] (defines media stream & characteristics)
    //   * Header Extension Object [required]  (additional functionality)
    //   * Content Description Object          (bibliographic information)
    //   * Script Command Object               (commands for during playback)
    //   * Marker Object                       (named jumped points within the file)
    // * Data Object [required]
    //   * Data Packets
    // * Index Object
    // Header Object: (mandatory, one only)
    // Field Name                   Field Type   Size (bits)
    // Object ID                    GUID         128             // GUID for header object - ASF_Header_Object
    // Object Size                  QWORD        64              // size of header object, including 30 bytes of Header Object header
    // Number of Header Objects     DWORD        32              // number of objects in header object
    // Reserved1                    BYTE         8               // hardcoded: 0x01
    // Reserved2                    BYTE         8               // hardcoded: 0x02
    $ThisFileInfo['fileformat'] = 'asf';
    $ThisFileInfo['audio']['lossless'] = false;
    $ThisFileInfo['video']['lossless'] = false;
    fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
    $HeaderObjectData = fread($fd, 30);
    $ThisFileInfo['asf']['header_object']['objectid'] = substr($HeaderObjectData, 0, 16);
    $ThisFileInfo['asf']['header_object']['objectid_guid'] = BytestringToGUID($ThisFileInfo['asf']['header_object']['objectid']);
    if ($ThisFileInfo['asf']['header_object']['objectid'] != ASF_Header_Object) {
        $ThisFileInfo['warning'] .= "\n" . 'ASF header GUID {' . BytestringToGUID($ThisFileInfo['asf']['header_object']['objectid']) . '} does not match expected "ASF_Header_Object" GUID {' . BytestringToGUID(ASF_Header_Object) . '}';
        //return false;
        break;
    }
    $ThisFileInfo['asf']['header_object']['objectsize'] = LittleEndian2Int(substr($HeaderObjectData, 16, 8));
    $ThisFileInfo['asf']['header_object']['headerobjects'] = LittleEndian2Int(substr($HeaderObjectData, 24, 4));
    $ThisFileInfo['asf']['header_object']['reserved1'] = LittleEndian2Int(substr($HeaderObjectData, 28, 1));
    $ThisFileInfo['asf']['header_object']['reserved2'] = LittleEndian2Int(substr($HeaderObjectData, 29, 1));
    //$ASFHeaderData  = $HeaderObjectData;
    $ASFHeaderData = fread($fd, $ThisFileInfo['asf']['header_object']['objectsize'] - 30);
    //$offset = 30;
    $offset = 0;
    for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $ThisFileInfo['asf']['header_object']['headerobjects']; $HeaderObjectsCounter++) {
        $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
        $offset += 16;
        $NextObjectGUIDtext = BytestringToGUID($NextObjectGUID);
        $NextObjectSize = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
        $offset += 8;
        switch ($NextObjectGUID) {
            case ASF_File_Properties_Object:
                // File Properties Object: (mandatory, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for file properties object - ASF_File_Properties_Object
                // Object Size                  QWORD        64              // size of file properties object, including 104 bytes of File Properties Object header
                // File ID                      GUID         128             // unique ID - identical to File ID in Data Object
                // File Size                    QWORD        64              // entire file in bytes. Invalid if Broadcast Flag == 1
                // Creation Date                QWORD        64              // date & time of file creation. Maybe invalid if Broadcast Flag == 1
                // Data Packets Count           QWORD        64              // number of data packets in Data Object. Invalid if Broadcast Flag == 1
                // Play Duration                QWORD        64              // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1
                // Send Duration                QWORD        64              // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1
                // Preroll                      QWORD        64              // time to buffer data before starting to play file, in 1-millisecond units. If <> 0, PlayDuration and PresentationTime have been offset by this amount
                // Flags                        DWORD        32              //
                // * Broadcast Flag             bits         1  (0x01)       // file is currently being written, some header values are invalid
                // * Seekable Flag              bits         1  (0x02)       // is file seekable
                // * Reserved                   bits         30 (0xFFFFFFFC) // reserved - set to zero
                // Minimum Data Packet Size     DWORD        32              // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1
                // Maximum Data Packet Size     DWORD        32              // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1
                // Maximum Bitrate              DWORD        32              // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead
                $ThisFileInfo['asf']['file_properties_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['file_properties_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['file_properties_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['file_properties_object']['fileid'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['file_properties_object']['fileid_guid'] = BytestringToGUID($ThisFileInfo['asf']['file_properties_object']['fileid']);
                $ThisFileInfo['asf']['file_properties_object']['filesize'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                $offset += 8;
                $ThisFileInfo['asf']['file_properties_object']['creation_date'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                $ThisFileInfo['asf']['file_properties_object']['creation_date_unix'] = FILETIMEtoUNIXtime($ThisFileInfo['asf']['file_properties_object']['creation_date']);
                $offset += 8;
                $ThisFileInfo['asf']['file_properties_object']['data_packets'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                $offset += 8;
                $ThisFileInfo['asf']['file_properties_object']['play_duration'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                $offset += 8;
                $ThisFileInfo['asf']['file_properties_object']['send_duration'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                $offset += 8;
                $ThisFileInfo['asf']['file_properties_object']['preroll'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                $offset += 8;
                $ThisFileInfo['playtime_seconds'] = $ThisFileInfo['asf']['file_properties_object']['play_duration'] / 10000000 - $ThisFileInfo['asf']['file_properties_object']['preroll'] / 1000;
                $ThisFileInfo['asf']['file_properties_object']['flags_raw'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['asf']['file_properties_object']['flags']['broadcast'] = (bool) ($ThisFileInfo['asf']['file_properties_object']['flags_raw'] & 0x1);
                $ThisFileInfo['asf']['file_properties_object']['flags']['seekable'] = (bool) ($ThisFileInfo['asf']['file_properties_object']['flags_raw'] & 0x2);
                $ThisFileInfo['asf']['file_properties_object']['min_packet_size'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['asf']['file_properties_object']['max_packet_size'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['asf']['file_properties_object']['max_bitrate'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['bitrate'] = $ThisFileInfo['asf']['file_properties_object']['max_bitrate'];
                break;
            case ASF_Stream_Properties_Object:
                // Stream Properties Object: (mandatory, one per media stream)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for stream properties object - ASF_Stream_Properties_Object
                // Object Size                  QWORD        64              // size of stream properties object, including 78 bytes of Stream Properties Object header
                // Stream Type                  GUID         128             // ASF_Audio_Media, ASF_Video_Media or ASF_Command_Media
                // Error Correction Type        GUID         128             // ASF_Audio_Spread for audio-only streams, ASF_No_Error_Correction for other stream types
                // Time Offset                  QWORD        64              // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream
                // Type-Specific Data Length    DWORD        32              // number of bytes for Type-Specific Data field
                // Error Correction Data Length DWORD        32              // number of bytes for Error Correction Data field
                // Flags                        WORD         16              //
                // * Stream Number              bits         7 (0x007F)      // number of this stream.  1 <= valid <= 127
                // * Reserved                   bits         8 (0x7F80)      // reserved - set to zero
                // * Encrypted Content Flag     bits         1 (0x8000)      // stream contents encrypted if set
                // Reserved                     DWORD        32              // reserved - set to zero
                // Type-Specific Data           BYTESTREAM   variable        // type-specific format data, depending on value of Stream Type
                // Error Correction Data        BYTESTREAM   variable        // error-correction-specific format data, depending on value of Error Correct Type
                // There is one ASF_Stream_Properties_Object for each stream (audio, video) but the
                // stream number isn't known until halfway through decoding the structure, hence it
                // it is decoded to a temporary variable and then stuck in the appropriate index later
                $StreamPropertiesObjectData['objectid'] = $NextObjectGUID;
                $StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext;
                $StreamPropertiesObjectData['objectsize'] = $NextObjectSize;
                $StreamPropertiesObjectData['stream_type'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $StreamPropertiesObjectData['stream_type_guid'] = BytestringToGUID($StreamPropertiesObjectData['stream_type']);
                $StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $StreamPropertiesObjectData['error_correct_guid'] = BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);
                $StreamPropertiesObjectData['time_offset'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                $offset += 8;
                $StreamPropertiesObjectData['type_data_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $StreamPropertiesObjectData['error_data_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $StreamPropertiesObjectData['flags_raw'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData['flags_raw'] & 0x7f;
                $StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
                $offset += 4;
                // reserved - DWORD
                $StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
                $offset += $StreamPropertiesObjectData['type_data_length'];
                $StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
                $offset += $StreamPropertiesObjectData['error_data_length'];
                switch ($StreamPropertiesObjectData['stream_type']) {
                    case ASF_Audio_Media:
                        if (empty($ThisFileInfo['audio']['bitrate_mode'])) {
                            $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
                        }
                        require_once GETID3_INCLUDEPATH . 'getid3.riff.php';
                        $audiodata = RIFFparseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
                        unset($audiodata['raw']);
                        $ThisFileInfo['audio'] = array_merge_noclobber($audiodata, $ThisFileInfo['audio']);
                        break;
                    case ASF_Video_Media:
                        if (empty($ThisFileInfo['video']['bitrate_mode'])) {
                            $ThisFileInfo['video']['bitrate_mode'] = 'cbr';
                        }
                        break;
                    case ASF_Command_Media:
                    default:
                        // do nothing
                        break;
                }
                $ThisFileInfo['asf']['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
                unset($StreamPropertiesObjectData);
                // clear for next stream, if any
                break;
            case ASF_Header_Extension_Object:
                // Header Extension Object: (mandatory, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Header Extension object - ASF_Header_Extension_Object
                // Object Size                  QWORD        64              // size of Header Extension object, including 46 bytes of Header Extension Object header
                // Reserved Field 1             GUID         128             // hardcoded: ASF_Reserved_1
                // Reserved Field 2             WORD         16              // hardcoded: 0x00000006
                // Header Extension Data Size   DWORD        32              // in bytes. valid: 0, or > 24. equals object size minus 46
                // Header Extension Data        BYTESTREAM   variable        // array of zero or more extended header objects
                $ThisFileInfo['asf']['header_extension_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['header_extension_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['header_extension_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['header_extension_object']['reserved_1'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['header_extension_object']['reserved_1_guid'] = BytestringToGUID($ThisFileInfo['asf']['header_extension_object']['reserved_1']);
                if ($ThisFileInfo['asf']['header_extension_object']['reserved_1'] != ASF_Reserved_1) {
                    $ThisFileInfo['warning'] .= "\n" . 'header_extension_object.reserved_1 GUID (' . BytestringToGUID($ThisFileInfo['asf']['header_extension_object']['reserved_1']) . ') does not match expected "ASF_Reserved_1" GUID (' . BytestringToGUID(ASF_Reserved_1) . ')';
                    //return false;
                    break;
                }
                $ThisFileInfo['asf']['header_extension_object']['reserved_2'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                if ($ThisFileInfo['asf']['header_extension_object']['reserved_2'] != 6) {
                    $ThisFileInfo['warning'] .= "\n" . 'header_extension_object.reserved_2 (' . PrintHexBytes($ThisFileInfo['asf']['header_extension_object']['reserved_2']) . ') does not match expected value of "6"';
                    //return false;
                    break;
                }
                $ThisFileInfo['asf']['header_extension_object']['extension_data_size'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['asf']['header_extension_object']['extension_data'] = LittleEndian2Int(substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['header_extension_object']['extension_data_size']));
                $offset += $ThisFileInfo['asf']['header_extension_object']['extension_data_size'];
                break;
            case ASF_Codec_List_Object:
                // Codec List Object: (optional, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Codec List object - ASF_Codec_List_Object
                // Object Size                  QWORD        64              // size of Codec List object, including 44 bytes of Codec List Object header
                // Reserved                     GUID         128             // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6
                // Codec Entries Count          DWORD        32              // number of entries in Codec Entries array
                // Codec Entries                array of:    variable        //
                // * Type                       WORD         16              // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec
                // * Codec Name Length          WORD         16              // number of Unicode characters stored in the Codec Name field
                // * Codec Name                 WCHAR        variable        // array of Unicode characters - name of codec used to create the content
                // * Codec Description Length   WORD         16              // number of Unicode characters stored in the Codec Description field
                // * Codec Description          WCHAR        variable        // array of Unicode characters - description of format used to create the content
                // * Codec Information Length   WORD         16              // number of Unicode characters stored in the Codec Information field
                // * Codec Information          BYTESTREAM   variable        // opaque array of information bytes about the codec used to create the content
                $ThisFileInfo['asf']['codec_list']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['codec_list']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['codec_list']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['codec_list']['reserved'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['codec_list']['reserved_guid'] = BytestringToGUID($ThisFileInfo['asf']['codec_list']['reserved']);
                if ($ThisFileInfo['asf']['codec_list']['reserved'] != GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) {
                    $ThisFileInfo['warning'] .= "\n" . 'codec_list_object.reserved GUID {' . BytestringToGUID($ThisFileInfo['asf']['codec_list']['reserved']) . '} does not match expected "ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}';
                    //return false;
                    break;
                }
                $ThisFileInfo['asf']['codec_list']['codec_entries_count'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                for ($CodecEntryCounter = 0; $CodecEntryCounter < $ThisFileInfo['asf']['codec_list']['codec_entries_count']; $CodecEntryCounter++) {
                    $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['type_raw'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['type'] = ASFCodecListObjectTypeLookup($ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['type_raw']);
                    $CodecNameLength = LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                    // 2 bytes per character
                    $offset += 2;
                    $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['name'] = substr($ASFHeaderData, $offset, $CodecNameLength);
                    $offset += $CodecNameLength;
                    $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['name_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['name'], 2);
                    $CodecDescriptionLength = LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                    // 2 bytes per character
                    $offset += 2;
                    $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['description'] = substr($ASFHeaderData, $offset, $CodecDescriptionLength);
                    $offset += $CodecDescriptionLength;
                    $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['description_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['description'], 2);
                    $CodecInformationLength = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength);
                    $offset += $CodecInformationLength;
                    if ($ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['type_raw'] == 2) {
                        // audio codec
                        $ThisFileInfo['audio']['codec'] = $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['name_ascii'];
                        list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['description_ascii']);
                        if (!isset($ThisFileInfo['audio']['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
                            $ThisFileInfo['audio']['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000);
                        }
                        if (!isset($ThisFileInfo['video']['bitrate']) && isset($ThisFileInfo['audio']['bitrate']) && isset($ThisFileInfo['asf']['file_properties_object']['max_bitrate']) && $ThisFileInfo['asf']['codec_list']['codec_entries_count'] > 1) {
                            $ThisFileInfo['video']['bitrate'] = $ThisFileInfo['asf']['file_properties_object']['max_bitrate'] - $ThisFileInfo['audio']['bitrate'];
                        }
                        $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
                        switch ($AudioCodecFrequency) {
                            case 8:
                                $ThisFileInfo['audio']['sample_rate'] = 8000;
                                break;
                            case 11:
                                $ThisFileInfo['audio']['sample_rate'] = 11025;
                                break;
                            case 12:
                                $ThisFileInfo['audio']['sample_rate'] = 12000;
                                break;
                            case 16:
                                $ThisFileInfo['audio']['sample_rate'] = 16000;
                                break;
                            case 22:
                                $ThisFileInfo['audio']['sample_rate'] = 22050;
                                break;
                            case 24:
                                $ThisFileInfo['audio']['sample_rate'] = 24000;
                                break;
                            case 32:
                                $ThisFileInfo['audio']['sample_rate'] = 32000;
                                break;
                            case 44:
                                $ThisFileInfo['audio']['sample_rate'] = 44100;
                                break;
                            case 48:
                                $ThisFileInfo['audio']['sample_rate'] = 48000;
                                break;
                            default:
                                $ThisFileInfo['warning'] .= "\n" . 'unknown frequency: "' . $AudioCodecFrequency . '" (' . $ThisFileInfo['asf']['codec_list']['codec_entries'][$CodecEntryCounter]['description_ascii'] . ')';
                                //								return false;
                                break;
                        }
                        if (!isset($ThisFileInfo['audio']['channels'])) {
                            if (strstr($AudioCodecChannels, 'stereo')) {
                                $ThisFileInfo['audio']['channels'] = 2;
                            } elseif (strstr($AudioCodecChannels, 'mono')) {
                                $ThisFileInfo['audio']['channels'] = 1;
                            }
                        }
                    }
                }
                break;
            case ASF_Script_Command_Object:
                // Script Command Object: (optional, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Script Command object - ASF_Script_Command_Object
                // Object Size                  QWORD        64              // size of Script Command object, including 44 bytes of Script Command Object header
                // Reserved                     GUID         128             // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6
                // Commands Count               WORD         16              // number of Commands structures in the Script Commands Objects
                // Command Types Count          WORD         16              // number of Command Types structures in the Script Commands Objects
                // Command Types                array of:    variable        //
                // * Command Type Name Length   WORD         16              // number of Unicode characters for Command Type Name
                // * Command Type Name          WCHAR        variable        // array of Unicode characters - name of a type of command
                // Commands                     array of:    variable        //
                // * Presentation Time          DWORD        32              // presentation time of that command, in milliseconds
                // * Type Index                 WORD         16              // type of this command, as a zero-based index into the array of Command Types of this object
                // * Command Name Length        WORD         16              // number of Unicode characters for Command Name
                // * Command Name               WCHAR        variable        // array of Unicode characters - name of this command
                $ThisFileInfo['asf']['script_command_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['script_command_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['script_command_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['script_command_object']['reserved'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['script_command_object']['reserved_guid'] = BytestringToGUID($ThisFileInfo['asf']['script_command_object']['reserved']);
                if ($ThisFileInfo['asf']['script_command_object']['reserved'] != GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
                    $ThisFileInfo['warning'] .= "\n" . 'script_command_object.reserved GUID {' . BytestringToGUID($ThisFileInfo['asf']['script_command_object']['reserved']) . '} does not match expected "ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}';
                    //return false;
                    break;
                }
                $ThisFileInfo['asf']['script_command_object']['commands_count'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['script_command_object']['command_types_count'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                for ($CommandTypesCounter = 0; $CommandTypesCounter < $ThisFileInfo['asf']['script_command_object']['command_types_count']; $CommandTypesCounter++) {
                    $CommandTypeNameLength = LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                    // 2 bytes per character
                    $offset += 2;
                    $ThisFileInfo['asf']['script_command_object']['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
                    $offset += $CommandTypeNameLength;
                    $ThisFileInfo['asf']['script_command_object']['command_types'][$CommandTypesCounter]['name_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['script_command_object']['command_types'][$CommandTypesCounter]['name'], 2);
                }
                for ($CommandsCounter = 0; $CommandsCounter < $ThisFileInfo['asf']['script_command_object']['commands_count']; $CommandsCounter++) {
                    $ThisFileInfo['asf']['script_command_object']['commands'][$CommandsCounter]['presentation_time'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                    $offset += 4;
                    $ThisFileInfo['asf']['script_command_object']['commands'][$CommandsCounter]['type_index'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $CommandTypeNameLength = LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                    // 2 bytes per character
                    $offset += 2;
                    $ThisFileInfo['asf']['script_command_object']['commands'][$CommandsCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
                    $offset += $CommandTypeNameLength;
                    $ThisFileInfo['asf']['script_command_object']['commands'][$CommandsCounter]['name_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['script_command_object']['commands'][$CommandsCounter]['name'], 2);
                }
                break;
            case ASF_Marker_Object:
                // Marker Object: (optional, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Marker object - ASF_Marker_Object
                // Object Size                  QWORD        64              // size of Marker object, including 48 bytes of Marker Object header
                // Reserved                     GUID         128             // hardcoded: 4CFEDB20-75F6-11CF-9C0F-00A0C90349CB
                // Markers Count                DWORD        32              // number of Marker structures in Marker Object
                // Reserved                     WORD         16              // hardcoded: 0x0000
                // Name Length                  WORD         16              // number of bytes in the Name field
                // Name                         WCHAR        variable        // name of the Marker Object
                // Markers                      array of:    variable        //
                // * Offset                     QWORD        64              // byte offset into Data Object
                // * Presentation Time          QWORD        64              // in 100-nanosecond units
                // * Entry Length               WORD         16              // length in bytes of (Send Time + Flags + Marker Description Length + Marker Description + Padding)
                // * Send Time                  DWORD        32              // in milliseconds
                // * Flags                      DWORD        32              // hardcoded: 0x00000000
                // * Marker Description Length  DWORD        32              // number of bytes in Marker Description field
                // * Marker Description         WCHAR        variable        // array of Unicode characters - description of marker entry
                // * Padding                    BYTESTREAM   variable        // optional padding bytes
                $ThisFileInfo['asf']['marker_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['marker_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['marker_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['marker_object']['reserved'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['marker_object']['reserved_guid'] = BytestringToGUID($ThisFileInfo['asf']['marker_object']['reserved']);
                if ($ThisFileInfo['asf']['marker_object']['reserved'] != GUIDtoBytestring('4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) {
                    $ThisFileInfo['warning'] .= "\n" . 'marker_object.reserved GUID {' . BytestringToGUID($ThisFileInfo['asf']['marker_object']['reserved_1']) . '} does not match expected "ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}';
                    //return false;
                    break;
                }
                $ThisFileInfo['asf']['marker_object']['markers_count'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['asf']['marker_object']['reserved_2'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                if ($ThisFileInfo['asf']['marker_object']['reserved_2'] != 0) {
                    $ThisFileInfo['warning'] .= "\n" . 'marker_object.reserved_2 (' . PrintHexBytes($ThisFileInfo['asf']['marker_object']['reserved_2']) . ') does not match expected value of "0"';
                    //return false;
                    break;
                }
                $ThisFileInfo['asf']['marker_object']['name_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['marker_object']['name'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['marker_object']['name_length']);
                $offset += $ThisFileInfo['asf']['marker_object']['name_length'];
                $ThisFileInfo['asf']['marker_object']['name_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['marker_object']['name'], 2);
                for ($MarkersCounter = 0; $MarkersCounter < $ThisFileInfo['asf']['marker_object']['markers_count']; $MarkersCounter++) {
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['offset'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                    $offset += 8;
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['presentation_time'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                    $offset += 8;
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['entry_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['send_time'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                    $offset += 4;
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['flags'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                    $offset += 4;
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['marker_description_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                    $offset += 4;
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['marker_description'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['marker_description_length']);
                    $offset += $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['marker_description_length'];
                    $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['marker_description_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['marker_description'], 2);
                    $PaddingLength = $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['entry_length'] - 4 - 4 - 4 - $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['marker_description_length'];
                    if ($PaddingLength > 0) {
                        $ThisFileInfo['asf']['marker_object']['markers'][$MarkersCounter]['padding'] = substr($ASFHeaderData, $offset, $PaddingLength);
                        $offset += $PaddingLength;
                    }
                }
                break;
            case ASF_Bitrate_Mutual_Exclusion_Object:
                // Bitrate Mutual Exclusion Object: (optional)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Bitrate Mutual Exclusion object - ASF_Bitrate_Mutual_Exclusion_Object
                // Object Size                  QWORD        64              // size of Bitrate Mutual Exclusion object, including 42 bytes of Bitrate Mutual Exclusion Object header
                // Exlusion Type                GUID         128             // nature of mutual exclusion relationship. one of: (ASF_Mutex_Bitrate, ASF_Mutex_Unknown)
                // Stream Numbers Count         WORD         16              // number of video streams
                // Stream Numbers               WORD         variable        // array of mutually exclusive video stream numbers. 1 <= valid <= 127
                $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['reserved'] = substr($ASFHeaderData, $offset, 16);
                $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['reserved_guid'] = BytestringToGUID($ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['reserved']);
                $offset += 16;
                if ($ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['reserved'] != ASF_Mutex_Bitrate && $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['reserved'] != ASF_Mutex_Unknown) {
                    $ThisFileInfo['warning'] .= "\n" . 'bitrate_mutual_exclusion_object.reserved GUID {' . BytestringToGUID($ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['reserved']) . '} does not match expected "ASF_Mutex_Bitrate" GUID {' . BytestringToGUID(ASF_Mutex_Bitrate) . '} or  "ASF_Mutex_Unknown" GUID {' . BytestringToGUID(ASF_Mutex_Unknown) . '}';
                    //return false;
                    break;
                }
                $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['stream_numbers_count'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                for ($StreamNumberCounter = 0; $StreamNumberCounter < $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['stream_numbers_count']; $StreamNumberCounter++) {
                    $ThisFileInfo['asf']['bitrate_mutual_exclusion_object']['stream_numbers'][$StreamNumberCounter] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                }
                break;
            case ASF_Error_Correction_Object:
                // Error Correction Object: (optional, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Error Correction object - ASF_Error_Correction_Object
                // Object Size                  QWORD        64              // size of Error Correction object, including 44 bytes of Error Correction Object header
                // Error Correction Type        GUID         128             // type of error correction. one of: (ASF_No_Error_Correction, ASF_Audio_Spread)
                // Error Correction Data Length DWORD        32              // number of bytes in Error Correction Data field
                // Error Correction Data        BYTESTREAM   variable        // structure depends on value of Error Correction Type field
                $ThisFileInfo['asf']['error_correction_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['error_correction_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['error_correction_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['error_correction_object']['error_correction_type'] = substr($ASFHeaderData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['error_correction_object']['error_correction_guid'] = BytestringToGUID($ThisFileInfo['asf']['error_correction_object']['error_correction_type']);
                $ThisFileInfo['asf']['error_correction_object']['error_correction_data_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                $offset += 4;
                switch ($ThisFileInfo['asf']['error_correction_object']['error_correction_type']) {
                    case ASF_No_Error_Correction:
                        // should be no data, but just in case there is, skip to the end of the field
                        $offset += $ThisFileInfo['asf']['error_correction_object']['error_correction_data_length'];
                        break;
                    case ASF_Audio_Spread:
                        // Field Name                   Field Type   Size (bits)
                        // Span                         BYTE         8               // number of packets over which audio will be spread.
                        // Virtual Packet Length        WORD         16              // size of largest audio payload found in audio stream
                        // Virtual Chunk Length         WORD         16              // size of largest audio payload found in audio stream
                        // Silence Data Length          WORD         16              // number of bytes in Silence Data field
                        // Silence Data                 BYTESTREAM   variable        // hardcoded: 0x00 * (Silence Data Length) bytes
                        $ThisFileInfo['asf']['error_correction_object']['span'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 1));
                        $offset += 1;
                        $ThisFileInfo['asf']['error_correction_object']['virtual_packet_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                        $offset += 2;
                        $ThisFileInfo['asf']['error_correction_object']['virtual_chunk_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                        $offset += 2;
                        $ThisFileInfo['asf']['error_correction_object']['silence_data_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                        $offset += 2;
                        $ThisFileInfo['asf']['error_correction_object']['silence_data'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['error_correction_object']['silence_data_length']);
                        $offset += $ThisFileInfo['asf']['error_correction_object']['silence_data_length'];
                        break;
                    default:
                        $ThisFileInfo['warning'] .= "\n" . 'error_correction_object.error_correction_type GUID {' . BytestringToGUID($ThisFileInfo['asf']['error_correction_object']['reserved']) . '} does not match expected "ASF_No_Error_Correction" GUID {' . BytestringToGUID(ASF_No_Error_Correction) . '} or  "ASF_Audio_Spread" GUID {' . BytestringToGUID(ASF_Audio_Spread) . '}';
                        //return false;
                        break;
                }
                break;
            case ASF_Content_Description_Object:
                // Content Description Object: (optional, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Content Description object - ASF_Content_Description_Object
                // Object Size                  QWORD        64              // size of Content Description object, including 34 bytes of Content Description Object header
                // Title Length                 WORD         16              // number of bytes in Title field
                // Author Length                WORD         16              // number of bytes in Author field
                // Copyright Length             WORD         16              // number of bytes in Copyright field
                // Description Length           WORD         16              // number of bytes in Description field
                // Rating Length                WORD         16              // number of bytes in Rating field
                // Title                        WCHAR        16              // array of Unicode characters - Title
                // Author                       WCHAR        16              // array of Unicode characters - Author
                // Copyright                    WCHAR        16              // array of Unicode characters - Copyright
                // Description                  WCHAR        16              // array of Unicode characters - Description
                // Rating                       WCHAR        16              // array of Unicode characters - Rating
                $ThisFileInfo['asf']['content_description']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['content_description']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['content_description']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['content_description']['title_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['content_description']['author_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['content_description']['copyright_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['content_description']['description_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['content_description']['rating_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['content_description']['title'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['content_description']['title_length']);
                $offset += $ThisFileInfo['asf']['content_description']['title_length'];
                $ThisFileInfo['asf']['content_description']['title_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['content_description']['title'], 2);
                $ThisFileInfo['asf']['content_description']['author'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['content_description']['author_length']);
                $offset += $ThisFileInfo['asf']['content_description']['author_length'];
                $ThisFileInfo['asf']['content_description']['author_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['content_description']['author'], 2);
                $ThisFileInfo['asf']['content_description']['copyright'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['content_description']['copyright_length']);
                $offset += $ThisFileInfo['asf']['content_description']['copyright_length'];
                $ThisFileInfo['asf']['content_description']['copyright_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['content_description']['copyright'], 2);
                $ThisFileInfo['asf']['content_description']['description'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['content_description']['description_length']);
                $offset += $ThisFileInfo['asf']['content_description']['description_length'];
                $ThisFileInfo['asf']['content_description']['description_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['content_description']['description'], 2);
                $ThisFileInfo['asf']['content_description']['rating'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['content_description']['rating_length']);
                $offset += $ThisFileInfo['asf']['content_description']['rating_length'];
                $ThisFileInfo['asf']['content_description']['rating_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['content_description']['rating'], 2);
                foreach (array('title', 'author', 'copyright', 'description', 'rating') as $keytocopy) {
                    if (!empty($ThisFileInfo['asf']['content_description'][$keytocopy . '_ascii'])) {
                        $ThisFileInfo['asf']['comments']["{$keytocopy}"] = $ThisFileInfo['asf']['content_description'][$keytocopy . '_ascii'];
                    }
                }
                // ASF tags have highest priority
                if (!empty($ThisFileInfo['asf']['comments'])) {
                    CopyFormatCommentsToRootComments($ThisFileInfo['asf']['comments'], $ThisFileInfo, true, true, true);
                    // add tag to array of tags
                    $ThisFileInfo['tags'][] = 'asf';
                }
                break;
            case ASF_Extended_Content_Description_Object:
                // Extended Content Description Object: (optional, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Extended Content Description object - ASF_Extended_Content_Description_Object
                // Object Size                  QWORD        64              // size of ExtendedContent Description object, including 26 bytes of Extended Content Description Object header
                // Content Descriptors Count    WORD         16              // number of entries in Content Descriptors list
                // Content Descriptors          array of:    variable        //
                // * Descriptor Name Length     WORD         16              // size in bytes of Descriptor Name field
                // * Descriptor Name            WCHAR        variable        // array of Unicode characters - Descriptor Name
                // * Descriptor Value Data Type WORD         16              // Lookup array:
                // 0x0000 = Unicode String (variable length)
                // 0x0001 = BYTE array     (variable length)
                // 0x0002 = BOOL           (DWORD, 32 bits)
                // 0x0003 = DWORD          (DWORD, 32 bits)
                // 0x0004 = QWORD          (QWORD, 64 bits)
                // 0x0005 = WORD           (WORD,  16 bits)
                // * Descriptor Value Length    WORD         16              // number of bytes stored in Descriptor Value field
                // * Descriptor Value           variable     variable        // value for Content Descriptor
                $ThisFileInfo['asf']['extended_content_description']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['extended_content_description']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['extended_content_description']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['extended_content_description']['content_descriptors_count'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $ThisFileInfo['asf']['extended_content_description']['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
                    $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['name_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['name'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['name_length']);
                    $offset += $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['name_length'];
                    $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['name_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['name'], 2);
                    $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_type'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_length'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_length']);
                    $offset += $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_length'];
                    switch ($ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_type']) {
                        case 0x0:
                            // Unicode string
                            $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value'], 2);
                            break;
                        case 0x1:
                            // BYTE array
                            // do nothing
                            break;
                        case 0x2:
                            // BOOL
                            $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value'] = (bool) LittleEndian2Int($ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value']);
                            break;
                        case 0x3:
                            // DWORD
                        // DWORD
                        case 0x4:
                            // QWORD
                        // QWORD
                        case 0x5:
                            // WORD
                            $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value'] = LittleEndian2Int($ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value']);
                            break;
                        default:
                            $ThisFileInfo['warning'] .= "\n" . 'extended_content_description.content_descriptors.' . $ExtendedContentDescriptorsCounter . '.value_type is invalid (' . $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_type'] . ')';
                            //return false;
                            break;
                    }
                    switch ($ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['name_ascii']) {
                        case 'WM/AlbumTitle':
                            $ThisFileInfo['asf']['comments']['album'] = $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_ascii'];
                            break;
                        case 'WM/Genre':
                            $ThisFileInfo['asf']['comments']['genre'] = $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_ascii'];
                            require_once GETID3_INCLUDEPATH . 'getid3.id3.php';
                            $CleanedGenre = LookupGenre(LookupGenre($ThisFileInfo['asf']['comments']['genre'], true));
                            // convert to standard GenreID and back to standard spelling/capitalization
                            if ($CleanedGenre != $ThisFileInfo['asf']['comments']['genre']) {
                                $ThisFileInfo['asf']['comments']['genre'] = $CleanedGenre;
                            }
                            break;
                        case 'WM/TrackNumber':
                            $ThisFileInfo['asf']['comments']['track'] = $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value'];
                            break;
                        case 'WM/Track':
                            if (empty($ThisFileInfo['asf']['comments']['track'])) {
                                $ThisFileInfo['asf']['comments']['track'] = 1 + $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value'];
                            }
                            break;
                        case 'WM/Year':
                            $ThisFileInfo['asf']['comments']['year'] = $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value_ascii'];
                            break;
                        case 'IsVBR':
                            if ($ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value']) {
                                $ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
                                $ThisFileInfo['video']['bitrate_mode'] = 'vbr';
                            }
                            break;
                        case 'ID3':
                            if ($tempfilehandle = tmpfile()) {
                                require_once GETID3_INCLUDEPATH . 'getid3.id3v2.php';
                                $tempThisfileInfo = array();
                                fwrite($tempfilehandle, $ThisFileInfo['asf']['extended_content_description']['content_descriptors'][$ExtendedContentDescriptorsCounter]['value']);
                                getID3v2Filepointer($tempfilehandle, $tempThisfileInfo);
                                fclose($tempfilehandle);
                                $ThisFileInfo['id3v2'] = $tempThisfileInfo['id3v2'];
                            }
                            break;
                        default:
                            // do nothing
                            break;
                    }
                    // ASF tags have highest priority
                    if (!empty($ThisFileInfo['asf']['comments'])) {
                        CopyFormatCommentsToRootComments($ThisFileInfo['asf']['comments'], $ThisFileInfo, true, true, true);
                    }
                }
                break;
            case ASF_Stream_Bitrate_Properties_Object:
                // Stream Bitrate Properties Object: (optional, one only)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Stream Bitrate Properties object - ASF_Stream_Bitrate_Properties_Object
                // Object Size                  QWORD        64              // size of Extended Content Description object, including 26 bytes of Stream Bitrate Properties Object header
                // Bitrate Records Count        WORD         16              // number of records in Bitrate Records
                // Bitrate Records              array of:    variable        //
                // * Flags                      WORD         16              //
                // * * Stream Number            bits         7  (0x007F)     // number of this stream
                // * * Reserved                 bits         9  (0xFF80)     // hardcoded: 0
                // * Average Bitrate            DWORD        32              // in bits per second
                $ThisFileInfo['asf']['stream_bitrate_properties']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['stream_bitrate_properties']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['stream_bitrate_properties']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records_count'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                $offset += 2;
                for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records_count']; $BitrateRecordsCounter++) {
                    $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x7f;
                    $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records'][$BitrateRecordsCounter]['bitrate'] = LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                    $offset += 4;
                }
                break;
            case ASF_Padding_Object:
                // Padding Object: (optional)
                // Field Name                   Field Type   Size (bits)
                // Object ID                    GUID         128             // GUID for Padding object - ASF_Padding_Object
                // Object Size                  QWORD        64              // size of Padding object, including 24 bytes of ASF Padding Object header
                // Padding Data                 BYTESTREAM   variable        // ignore
                $ThisFileInfo['asf']['padding_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['padding_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['padding_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['padding_object']['padding_length'] = $ThisFileInfo['asf']['padding_object']['objectsize'] - 16 - 8;
                $ThisFileInfo['asf']['padding_object']['padding'] = substr($ASFHeaderData, $offset, $ThisFileInfo['asf']['padding_object']['padding_length']);
                break;
            default:
                // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
                if (GUIDname($NextObjectGUIDtext)) {
                    $ThisFileInfo['warning'] .= "\n" . 'unhandled GUID "' . GUIDname($NextObjectGUIDtext) . '" {' . $NextObjectGUIDtext . '} in ASF header at offset ' . ($offset - 16 - 8);
                } else {
                    $ThisFileInfo['warning'] .= "\n" . 'unknown GUID {' . $NextObjectGUIDtext . '} in ASF header at offset ' . ($offset - 16 - 8);
                }
                $offset += $NextObjectSize - 16 - 8;
                break;
        }
    }
    if (isset($ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records_count'])) {
        $ASFbitrateAudio = 0;
        $ASFbitrateVideo = 0;
        for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records_count']; $BitrateRecordsCounter++) {
            if (isset($ThisFileInfo['asf']['codec_list']['codec_entries'][$BitrateRecordsCounter])) {
                switch ($ThisFileInfo['asf']['codec_list']['codec_entries'][$BitrateRecordsCounter]['type_raw']) {
                    case 1:
                        $ASFbitrateVideo += $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
                        break;
                    case 2:
                        $ASFbitrateAudio += $ThisFileInfo['asf']['stream_bitrate_properties']['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
                        break;
                    default:
                        // do nothing
                        break;
                }
            }
        }
        if ($ASFbitrateAudio > 0) {
            $ThisFileInfo['audio']['bitrate'] = $ASFbitrateAudio;
        }
        if ($ASFbitrateVideo > 0) {
            $ThisFileInfo['video']['bitrate'] = $ASFbitrateVideo;
        }
    }
    if (isset($ThisFileInfo['asf']['stream_properties_object']) && is_array($ThisFileInfo['asf']['stream_properties_object'])) {
        require_once GETID3_INCLUDEPATH . 'getid3.riff.php';
        foreach ($ThisFileInfo['asf']['stream_properties_object'] as $streamnumber => $streamdata) {
            switch ($streamdata['stream_type']) {
                case ASF_Audio_Media:
                    // Field Name                   Field Type   Size (bits)
                    // Codec ID / Format Tag        WORD         16              // unique ID of audio codec - defined as wFormatTag field of WAVEFORMATEX structure
                    // Number of Channels           WORD         16              // number of channels of audio - defined as nChannels field of WAVEFORMATEX structure
                    // Samples Per Second           DWORD        32              // in Hertz - defined as nSamplesPerSec field of WAVEFORMATEX structure
                    // Average number of Bytes/sec  DWORD        32              // bytes/sec of audio stream  - defined as nAvgBytesPerSec field of WAVEFORMATEX structure
                    // Block Alignment              WORD         16              // block size in bytes of audio codec - defined as nBlockAlign field of WAVEFORMATEX structure
                    // Bits per sample              WORD         16              // bits per sample of mono data. set to zero for variable bitrate codecs. defined as wBitsPerSample field of WAVEFORMATEX structure
                    // Codec Specific Data Size     WORD         16              // size in bytes of Codec Specific Data buffer - defined as cbSize field of WAVEFORMATEX structure
                    // Codec Specific Data          BYTESTREAM   variable        // array of codec-specific data bytes
                    $audiomediaoffset = 0;
                    require_once GETID3_INCLUDEPATH . 'getid3.riff.php';
                    $ThisFileInfo['asf']['audio_media'][$streamnumber] = RIFFparseWAVEFORMATex(substr($streamdata['type_specific_data'], $audiomediaoffset, 16));
                    $audiomediaoffset += 16;
                    if (!isset($ThisFileInfo['audio']['bitrate'])) {
                        $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['asf']['audio_media'][$streamnumber]['bytes_sec'] * 8;
                    }
                    $ThisFileInfo['asf']['audio_media'][$streamnumber]['codec_data_size'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $audiomediaoffset, 2));
                    $audiomediaoffset += 2;
                    $ThisFileInfo['asf']['audio_media'][$streamnumber]['codec_data'] = substr($streamdata['type_specific_data'], $audiomediaoffset, $ThisFileInfo['asf']['audio_media'][$streamnumber]['codec_data_size']);
                    $audiomediaoffset += $ThisFileInfo['asf']['audio_media'][$streamnumber]['codec_data_size'];
                    break;
                case ASF_Video_Media:
                    // Field Name                   Field Type   Size (bits)
                    // Encoded Image Width          DWORD        32              // width of image in pixels
                    // Encoded Image Height         DWORD        32              // height of image in pixels
                    // Reserved Flags               BYTE         8               // hardcoded: 0x02
                    // Format Data Size             WORD         16              // size of Format Data field in bytes
                    // Format Data                  array of:    variable        //
                    // * Format Data Size           DWORD        32              // number of bytes in Format Data field, in bytes - defined as biSize field of BITMAPINFOHEADER structure
                    // * Image Width                LONG         32              // width of encoded image in pixels - defined as biWidth field of BITMAPINFOHEADER structure
                    // * Image Height               LONG         32              // height of encoded image in pixels - defined as biHeight field of BITMAPINFOHEADER structure
                    // * Reserved                   WORD         16              // hardcoded: 0x0001 - defined as biPlanes field of BITMAPINFOHEADER structure
                    // * Bits Per Pixel Count       WORD         16              // bits per pixel - defined as biBitCount field of BITMAPINFOHEADER structure
                    // * Compression ID             FOURCC       32              // fourcc of video codec - defined as biCompression field of BITMAPINFOHEADER structure
                    // * Image Size                 DWORD        32              // image size in bytes - defined as biSizeImage field of BITMAPINFOHEADER structure
                    // * Horizontal Pixels / Meter  DWORD        32              // horizontal resolution of target device in pixels per meter - defined as biXPelsPerMeter field of BITMAPINFOHEADER structure
                    // * Vertical Pixels / Meter    DWORD        32              // vertical resolution of target device in pixels per meter - defined as biYPelsPerMeter field of BITMAPINFOHEADER structure
                    // * Colors Used Count          DWORD        32              // number of color indexes in the color table that are actually used - defined as biClrUsed field of BITMAPINFOHEADER structure
                    // * Important Colors Count     DWORD        32              // number of color index required for displaying bitmap. if zero, all colors are required. defined as biClrImportant field of BITMAPINFOHEADER structure
                    // * Codec Specific Data        BYTESTREAM   variable        // array of codec-specific data bytes
                    $videomediaoffset = 0;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['image_width'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['image_height'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['flags'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 1));
                    $videomediaoffset += 1;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data_size'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
                    $videomediaoffset += 2;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['format_data_size'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['image_width'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['image_height'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['reserved'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
                    $videomediaoffset += 2;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['bits_per_pixel'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
                    $videomediaoffset += 2;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['codec_fourcc'] = substr($streamdata['type_specific_data'], $videomediaoffset, 4);
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['image_size'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['horizontal_pels'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['vertical_pels'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['colors_used'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['colors_important'] = LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                    $videomediaoffset += 4;
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset);
                    $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['codec'] = RIFFfourccLookup($ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['codec_fourcc']);
                    $ThisFileInfo['video']['codec'] = $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['codec'];
                    $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['asf']['video_media'][$streamnumber]['image_width'];
                    $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['asf']['video_media'][$streamnumber]['image_height'];
                    $ThisFileInfo['video']['bits_per_sample'] = $ThisFileInfo['asf']['video_media'][$streamnumber]['format_data']['bits_per_pixel'];
                    break;
                default:
                    break;
            }
        }
    }
    while (ftell($fd) < $ThisFileInfo['avdataend']) {
        $NextObjectDataHeader = fread($fd, 24);
        $offset = 0;
        $NextObjectGUID = substr($NextObjectDataHeader, 0, 16);
        $offset += 16;
        $NextObjectGUIDtext = BytestringToGUID($NextObjectGUID);
        $NextObjectSize = LittleEndian2Int(substr($NextObjectDataHeader, $offset, 8));
        $offset += 8;
        switch ($NextObjectGUID) {
            case ASF_Data_Object:
                // Data Object: (mandatory, one only)
                // Field Name                       Field Type   Size (bits)
                // Object ID                        GUID         128             // GUID for Data object - ASF_Data_Object
                // Object Size                      QWORD        64              // size of Data object, including 50 bytes of Data Object header. may be 0 if FilePropertiesObject.BroadcastFlag == 1
                // File ID                          GUID         128             // unique identifier. identical to File ID field in Header Object
                // Total Data Packets               QWORD        64              // number of Data Packet entries in Data Object. invalid if FilePropertiesObject.BroadcastFlag == 1
                // Reserved                         WORD         16              // hardcoded: 0x0101
                $DataObjectData = $NextObjectDataHeader . fread($fd, 50 - 24);
                $offset = 24;
                $ThisFileInfo['asf']['data_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['data_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['data_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['data_object']['fileid'] = substr($DataObjectData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['data_object']['fileid_guid'] = BytestringToGUID($ThisFileInfo['asf']['data_object']['fileid']);
                $ThisFileInfo['asf']['data_object']['total_data_packets'] = LittleEndian2Int(substr($DataObjectData, $offset, 8));
                $offset += 8;
                $ThisFileInfo['asf']['data_object']['reserved'] = LittleEndian2Int(substr($DataObjectData, $offset, 2));
                $offset += 2;
                if ($ThisFileInfo['asf']['data_object']['reserved'] != 0x101) {
                    $ThisFileInfo['warning'] .= "\n" . 'data_object.reserved (' . PrintHexBytes($ThisFileInfo['asf']['data_object']['reserved']) . ') does not match expected value of "0x0101"';
                    //return false;
                    break;
                }
                // Data Packets                     array of:    variable        //
                // * Error Correction Flags         BYTE         8               //
                // * * Error Correction Data Length bits         4               // if Error Correction Length Type == 00, size of Error Correction Data in bytes, else hardcoded: 0000
                // * * Opaque Data Present          bits         1               //
                // * * Error Correction Length Type bits         2               // number of bits for size of the error correction data. hardcoded: 00
                // * * Error Correction Present     bits         1               // If set, use Opaque Data Packet structure, else use Payload structure
                // * Error Correction Data
                $ThisFileInfo['avdataoffset'] = ftell($fd);
                fseek($fd, $ThisFileInfo['asf']['data_object']['objectsize'] - 50, SEEK_CUR);
                // skip actual audio/video data
                $ThisFileInfo['avdataend'] = ftell($fd);
                break;
            case ASF_Simple_Index_Object:
                // Simple Index Object: (optional, recommended, one per video stream)
                // Field Name                       Field Type   Size (bits)
                // Object ID                        GUID         128             // GUID for Simple Index object - ASF_Data_Object
                // Object Size                      QWORD        64              // size of Simple Index object, including 56 bytes of Simple Index Object header
                // File ID                          GUID         128             // unique identifier. may be zero or identical to File ID field in Data Object and Header Object
                // Index Entry Time Interval        QWORD        64              // interval between index entries in 100-nanosecond units
                // Maximum Packet Count             DWORD        32              // maximum packet count for all index entries
                // Index Entries Count              DWORD        32              // number of Index Entries structures
                // Index Entries                    array of:    variable        //
                // * Packet Number                  DWORD        32              // number of the Data Packet associated with this index entry
                // * Packet Count                   WORD         16              // number of Data Packets to sent at this index entry
                $SimpleIndexObjectData = $NextObjectDataHeader . fread($fd, 56 - 24);
                $offset = 24;
                $ThisFileInfo['asf']['simple_index_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['simple_index_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['simple_index_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['simple_index_object']['fileid'] = substr($SimpleIndexObjectData, $offset, 16);
                $offset += 16;
                $ThisFileInfo['asf']['simple_index_object']['fileid_guid'] = BytestringToGUID($ThisFileInfo['asf']['simple_index_object']['fileid']);
                $ThisFileInfo['asf']['simple_index_object']['index_entry_time_interval'] = LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 8));
                $offset += 8;
                $ThisFileInfo['asf']['simple_index_object']['maximum_packet_count'] = LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['asf']['simple_index_object']['index_entries_count'] = LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
                $offset += 4;
                $IndexEntriesData = $SimpleIndexObjectData . fread($fd, 6 * $ThisFileInfo['asf']['simple_index_object']['index_entries_count']);
                for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $ThisFileInfo['asf']['simple_index_object']['index_entries_count']; $IndexEntriesCounter++) {
                    $ThisFileInfo['asf']['simple_index_object']['index_entries'][$IndexEntriesCounter]['packet_number'] = LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
                    $offset += 4;
                    $ThisFileInfo['asf']['simple_index_object']['index_entries'][$IndexEntriesCounter]['packet_count'] = LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
                    $offset += 2;
                }
                break;
            case ASF_Index_Object:
                // 6.2 ASF top-level Index Object (optional but recommended when appropriate, 0 or 1)
                // Field Name                       Field Type   Size (bits)
                // Object ID                        GUID         128             // GUID for the Index Object - ASF_Index_Object
                // Object Size                      QWORD        64              // Specifies the size, in bytes, of the Index Object, including at least 34 bytes of Index Object header
                // Index Entry Time Interval        DWORD        32              // Specifies the time interval between each index entry in ms.
                // Index Specifiers Count           WORD         16              // Specifies the number of Index Specifiers structures in this Index Object.
                // Index Blocks Count               DWORD        32              // Specifies the number of Index Blocks structures in this Index Object.
                // Index Entry Time Interval        DWORD        32              // Specifies the time interval between index entries in milliseconds.  This value cannot be 0.
                // Index Specifiers Count           WORD         16              // Specifies the number of entries in the Index Specifiers list.  Valid values are 1 and greater.
                // Index Specifiers                 array of:    varies          //
                // * Stream Number                  WORD         16              // Specifies the stream number that the Index Specifiers refer to. Valid values are between 1 and 127.
                // * Index Type                     WORD         16              // Specifies Index Type values as follows:
                //   1 = Nearest Past Data Packet - indexes point to the data packet whose presentation time is closest to the index entry time.
                //   2 = Nearest Past Media Object - indexes point to the closest data packet containing an entire object or first fragment of an object.
                //   3 = Nearest Past Cleanpoint. - indexes point to the closest data packet containing an entire object (or first fragment of an object) that has the Cleanpoint Flag set.
                //   Nearest Past Cleanpoint is the most common type of index.
                // Index Entry Count                DWORD        32              // Specifies the number of Index Entries in the block.
                // * Block Positions                QWORD        varies          // Specifies a list of byte offsets of the beginnings of the blocks relative to the beginning of the first Data Packet (i.e., the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed.
                // * Index Entries                  array of:    varies          //
                // * * Offsets                      DWORD        varies          // An offset value of 0xffffffff indicates an invalid offset value
                $ASFIndexObjectData = $NextObjectDataHeader . fread($fd, 34 - 24);
                $offset = 24;
                $ThisFileInfo['asf']['asf_index_object']['objectid'] = $NextObjectGUID;
                $ThisFileInfo['asf']['asf_index_object']['objectid_guid'] = $NextObjectGUIDtext;
                $ThisFileInfo['asf']['asf_index_object']['objectsize'] = $NextObjectSize;
                $ThisFileInfo['asf']['asf_index_object']['entry_time_interval'] = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                $offset += 4;
                $ThisFileInfo['asf']['asf_index_object']['index_specifiers_count'] = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
                $offset += 2;
                $ThisFileInfo['asf']['asf_index_object']['index_blocks_count'] = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                $offset += 4;
                $ASFIndexObjectData .= fread($fd, 4 * $ThisFileInfo['asf']['asf_index_object']['index_specifiers_count']);
                for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $ThisFileInfo['asf']['asf_index_object']['index_specifiers_count']; $IndexSpecifiersCounter++) {
                    $IndexSpecifierStreamNumber = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['asf_index_object']['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber;
                    $ThisFileInfo['asf']['asf_index_object']['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
                    $offset += 2;
                    $ThisFileInfo['asf']['asf_index_object']['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = ASFIndexObjectIndexTypeLookup($ThisFileInfo['asf']['asf_index_object']['index_specifiers'][$IndexSpecifiersCounter]['index_type']);
                }
                $ASFIndexObjectData .= fread($fd, 4);
                $ThisFileInfo['asf']['asf_index_object']['index_entry_count'] = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                $offset += 4;
                $ASFIndexObjectData .= fread($fd, 8 * $ThisFileInfo['asf']['asf_index_object']['index_specifiers_count']);
                for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $ThisFileInfo['asf']['asf_index_object']['index_specifiers_count']; $IndexSpecifiersCounter++) {
                    $ThisFileInfo['asf']['asf_index_object']['block_positions'][$IndexSpecifiersCounter] = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8));
                    $offset += 8;
                }
                $ASFIndexObjectData .= fread($fd, 4 * $ThisFileInfo['asf']['asf_index_object']['index_specifiers_count'] * $ThisFileInfo['asf']['asf_index_object']['index_entry_count']);
                for ($IndexEntryCounter = 0; $IndexEntryCounter < $ThisFileInfo['asf']['asf_index_object']['index_entry_count']; $IndexEntryCounter++) {
                    for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $ThisFileInfo['asf']['asf_index_object']['index_specifiers_count']; $IndexSpecifiersCounter++) {
                        $ThisFileInfo['asf']['asf_index_object']['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                        $offset += 4;
                    }
                }
                break;
            default:
                // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
                if (GUIDname($NextObjectGUIDtext)) {
                    $ThisFileInfo['warning'] .= "\n" . 'unhandled GUID "' . GUIDname($NextObjectGUIDtext) . '" {' . $NextObjectGUIDtext . '} in ASF body at offset ' . ($offset - 16 - 8);
                } else {
                    $ThisFileInfo['warning'] .= "\n" . 'unknown GUID {' . $NextObjectGUIDtext . '} in ASF body at offset ' . (ftell($fd) - 16 - 8);
                }
                fseek($fd, $NextObjectSize - 16 - 8, SEEK_CUR);
                break;
        }
    }
    if (isset($ThisFileInfo['asf']['codec_list']['codec_entries']) && is_array($ThisFileInfo['asf']['codec_list']['codec_entries'])) {
        foreach ($ThisFileInfo['asf']['codec_list']['codec_entries'] as $streamnumber => $streamdata) {
            switch ($streamdata['information']) {
                case 'WMV1':
                case 'WMV2':
                case 'WMV3':
                    $ThisFileInfo['video']['dataformat'] = 'wmv';
                    $ThisFileInfo['mime_type'] = 'video/x-ms-wmv';
                    break;
                case 'MP42':
                case 'MP43':
                case 'MP4S':
                case 'mp4s':
                    $ThisFileInfo['video']['dataformat'] = 'asf';
                    $ThisFileInfo['mime_type'] = 'video/x-ms-asf';
                    break;
                default:
                    switch ($streamdata['type_raw']) {
                        case 1:
                            if (strstr($streamdata['name_ascii'], 'Windows Media')) {
                                $ThisFileInfo['video']['dataformat'] = 'wmv';
                                if ($ThisFileInfo['mime_type'] == 'video/x-ms-asf') {
                                    $ThisFileInfo['mime_type'] = 'video/x-ms-wmv';
                                }
                            }
                            break;
                        case 2:
                            if (strstr($streamdata['name_ascii'], 'Windows Media')) {
                                $ThisFileInfo['audio']['dataformat'] = 'wma';
                                if ($ThisFileInfo['mime_type'] == 'video/x-ms-asf') {
                                    $ThisFileInfo['mime_type'] = 'audio/x-ms-wma';
                                }
                            }
                            break;
                    }
                    break;
            }
        }
    }
    if (!empty($ThisFileInfo['audio']) && empty($ThisFileInfo['audio']['dataformat'])) {
        $ThisFileInfo['audio']['dataformat'] = 'asf';
    }
    if (!empty($ThisFileInfo['video']) && empty($ThisFileInfo['video']['dataformat'])) {
        $ThisFileInfo['video']['dataformat'] = 'asf';
    }
    switch ($ThisFileInfo['audio']['codec']) {
        case 'MPEG Layer-3':
            $ThisFileInfo['audio']['dataformat'] = 'mp3';
            $ThisFileInfo['audio']['bits_per_sample'] = 16;
            break;
        default:
            break;
    }
    if (isset($ThisFileInfo['asf']['codec_list']['codec_entries'])) {
        foreach ($ThisFileInfo['asf']['codec_list']['codec_entries'] as $streamnumber => $streamdata) {
            switch ($streamdata['type_raw']) {
                case 1:
                    // video
                    $ThisFileInfo['video']['encoder'] = $ThisFileInfo['asf']['codec_list']['codec_entries'][$streamnumber]['name_ascii'];
                    break;
                case 2:
                    // audio
                    $ThisFileInfo['audio']['encoder'] = $ThisFileInfo['asf']['codec_list']['codec_entries'][$streamnumber]['name_ascii'];
                    $ThisFileInfo['audio']['codec'] = $ThisFileInfo['audio']['encoder'];
                    break;
                default:
                    $ThisFileInfo['warning'] .= "\n" . 'Unknown streamtype: [codec_list][codec_entries][' . $streamnumber . '][type_raw] == ' . $streamdata['type_raw'];
                    break;
            }
        }
    }
    return true;
}
Пример #5
0
     echo '<TR><TD ALIGN="RIGHT"><B>Track</B></TD><TD><INPUT TYPE="TEXT" SIZE="2" NAME="EditorTrack" VALUE="' . FixTextFields(isset($OldThisfileInfo['comments']['track'][0]) ? $OldThisfileInfo['comments']['track'][0] : '') . '"></TD></TR>';
     echo '<TR><TD ALIGN="RIGHT"><B>Genre</B></TD><TD><SELECT NAME="EditorGenre">';
     require_once GETID3_INCLUDEPATH . 'getid3.id3.php';
     $ArrayOfGenres = ArrayOfGenres();
     // get the array of genres
     unset($ArrayOfGenres['CR']);
     // take off these special cases
     unset($ArrayOfGenres['RX']);
     unset($ArrayOfGenres[255]);
     asort($ArrayOfGenres);
     // sort into alphabetical order
     $ArrayOfGenres[255] = '-Unknown-';
     // and put the special cases back on the end
     $ArrayOfGenres['CR'] = '-Cover-';
     $ArrayOfGenres['RX'] = '-Remix-';
     $EditorGenre = isset($OldThisfileInfo['comments']['genre'][0]) ? LookupGenre($OldThisfileInfo['comments']['genre'][0], true) : 255;
     foreach ($ArrayOfGenres as $key => $value) {
         echo '<OPTION VALUE="' . $key . '"' . ($EditorGenre == $key ? ' SELECTED' : '') . '>' . $value . '</OPTION>';
     }
     echo '</SELECT></TD></TR>';
     echo '<TR><TD ALIGN="RIGHT"><B>Comment</B></TD><TD><TEXTAREA COLS="30" ROWS="3" NAME="EditorComment" WRAP="VIRTUAL">' . (isset($OldThisfileInfo['comment']) ? $OldThisfileInfo['comment'] : '') . '</TEXTAREA></TD></TR>';
     if ($OldThisfileInfo['fileformat'] == 'mp3') {
         echo '<TR><TD ALIGN="RIGHT"><B>Picture</B></TD><TD><INPUT TYPE="FILE" NAME="userfile" ACCEPT="image/jpeg, image/gif, image/png"></TD></TR>';
         echo '<INPUT TYPE="HIDDEN" NAME="WriteID3v2TagNow" VALUE="1">';
         echo '<TR><TD ALIGN="CENTER" COLSPAN="2"><INPUT TYPE="RADIO" NAME="WriteOrDelete" VALUE="W" CHECKED> Write <INPUT TYPE="RADIO" NAME="WriteOrDelete" VALUE="D"> Delete</TD></TR>';
         echo '<TR><TD ALIGN="CENTER" COLSPAN="2"><INPUT TYPE="CHECKBOX" NAME="VersionToEdit1" VALUE="1"> ID3v1 <INPUT TYPE="CHECKBOX" NAME="VersionToEdit2" VALUE="2" CHECKED> ID3v2</TD></TR>';
     } elseif ($OldThisfileInfo['fileformat'] == 'ogg') {
         echo '<INPUT TYPE="HIDDEN" NAME="WriteOggCommentTagNow" VALUE="1">';
     }
     echo '<TR><TD ALIGN="CENTER" COLSPAN="2"><INPUT TYPE="SUBMIT" VALUE="Save Changes"> <INPUT TYPE="RESET" VALUE="Reset"></TD></TR>';
 } else {
}
echo '<A HREF="' . $PHP_SELF . '">Start Over</A><BR>';
echo '<TABLE BORDER="0"><FORM ACTION="' . $PHP_SELF . '" METHOD="POST" ENCTYPE="multipart/form-data">';
echo '<TR><TD ALIGN="CENTER" COLSPAN="2"><B>Sample ID3v2 editor</B></TD></TR>';
echo '<TR><TD ALIGN="RIGHT"><B>Filename</B></TD><TD><INPUT TYPE="TEXT" SIZE="40" NAME="EditorFilename" VALUE="' . FixTextFields($EditorFilename) . '"></TD></TR>';
if ($EditorFilename) {
    if (file_exists($EditorFilename)) {
        $OldMP3fileInfo = GetAllMP3info($EditorFilename);
        $EditorTitle = $OldMP3fileInfo['title'];
        $EditorArtist = $OldMP3fileInfo['artist'];
        $EditorAlbum = $OldMP3fileInfo['album'];
        $EditorYear = $OldMP3fileInfo['year'];
        $EditorTrack = $OldMP3fileInfo['track'];
        $EditorComment = $OldMP3fileInfo['comment'];
        if (isset($OldMP3fileInfo['genre'])) {
            $EditorGenre = LookupGenre($OldMP3fileInfo['genre'], TRUE);
        } else {
            $EditorGenre = 255;
        }
        echo '<TR><TD ALIGN="RIGHT"><B>Title</B></TD><TD><INPUT TYPE="TEXT" SIZE="40" NAME="EditorTitle" VALUE="' . FixTextFields($EditorTitle) . '"></TD></TR>';
        echo '<TR><TD ALIGN="RIGHT"><B>Artist</B></TD><TD><INPUT TYPE="TEXT" SIZE="40" NAME="EditorArtist" VALUE="' . FixTextFields($EditorArtist) . '"></TD></TR>';
        echo '<TR><TD ALIGN="RIGHT"><B>Album</B></TD><TD><INPUT TYPE="TEXT" SIZE="40" NAME="EditorAlbum" VALUE="' . FixTextFields($EditorAlbum) . '"></TD></TR>';
        echo '<TR><TD ALIGN="RIGHT"><B>Year</B></TD><TD><INPUT TYPE="TEXT" SIZE="4" NAME="EditorYear" VALUE="' . FixTextFields($EditorYear) . '"></TD></TR>';
        echo '<TR><TD ALIGN="RIGHT"><B>Track</B></TD><TD><INPUT TYPE="TEXT" SIZE="2" NAME="EditorTrack" VALUE="' . FixTextFields($EditorTrack) . '"></TD></TR>';
        echo '<TR><TD ALIGN="RIGHT"><B>Genre</B></TD><TD><SELECT NAME="EditorGenre">';
        $ArrayOfGenres = ArrayOfGenres();
        // get the array of genres
        unset($ArrayOfGenres['CR']);
        // take off these special cases
        unset($ArrayOfGenres['RX']);
        unset($ArrayOfGenres[255]);
Пример #7
0
function ParseID3v2GenreString($genrestring)
{
    // Parse genres into arrays of genreName and genreID
    // ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)'
    // ID3v2.4.x: '21' $00 'Eurodisco' $00
    $returnarray = null;
    if (strpos($genrestring, chr(0)) !== false) {
        $unprocessed = trim($genrestring);
        // trailing nulls will cause an infinite loop.
        $genrestring = '';
        while (strpos($unprocessed, chr(0)) !== false) {
            // convert null-seperated v2.4-format into v2.3 ()-seperated format
            $endpos = strpos($unprocessed, chr(0));
            $genrestring .= '(' . substr($unprocessed, 0, $endpos) . ')';
            $unprocessed = substr($unprocessed, $endpos + 1);
        }
        unset($unprocessed);
    }
    while (strpos($genrestring, '(') !== false) {
        $startpos = strpos($genrestring, '(');
        $endpos = strpos($genrestring, ')');
        if (substr($genrestring, $startpos + 1, 1) == '(') {
            $genrestring = substr($genrestring, 0, $startpos) . substr($genrestring, $startpos + 1);
            $endpos--;
        }
        $element = substr($genrestring, $startpos + 1, $endpos - ($startpos + 1));
        $genrestring = substr($genrestring, 0, $startpos) . substr($genrestring, $endpos + 1);
        if (LookupGenre($element) !== '') {
            // $element is a valid genre id/abbreviation
            if (!is_array($returnarray['genre']) || !in_array(LookupGenre($element), $returnarray['genre'])) {
                // avoid duplicate entires
                if ($element == 'CR' && $element == 'RX') {
                    $returnarray['genreid'][] = $element;
                } else {
                    $returnarray['genreid'][] = (int) $element;
                }
                $returnarray['genre'][] = LookupGenre($element);
            }
        } else {
            if (!is_array($returnarray['genre']) || !in_array($element, $returnarray['genre'])) {
                // avoid duplicate entires
                $returnarray['genreid'][] = '';
                $returnarray['genre'][] = $element;
            }
        }
    }
    if ($genrestring) {
        if (!is_array($returnarray['genre']) || !in_array($genrestring, $returnarray['genre'])) {
            // avoid duplicate entires
            $returnarray['genreid'][] = '';
            $returnarray['genre'][] = $genrestring;
        }
    }
    return $returnarray;
}