diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-09 16:41:27 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-09 16:41:27 +0000 |
commit | 547494de2924c9709a03db6f0b596e9d5a6540eb (patch) | |
tree | 0fe26dc5fa2785dce23ad25c37c524124b89891a | |
parent | 7e5654af67f1f24211c9cde4136cd396a71903b7 (diff) | |
download | ampache-547494de2924c9709a03db6f0b596e9d5a6540eb.tar.gz ampache-547494de2924c9709a03db6f0b596e9d5a6540eb.tar.bz2 ampache-547494de2924c9709a03db6f0b596e9d5a6540eb.zip |
some logic fixes for auto-transcoding
-rwxr-xr-x | docs/CHANGELOG | 1 | ||||
-rw-r--r-- | lib/class/song.class.php | 37 | ||||
-rw-r--r-- | modules/id3/getid3/getid3.lib.php | 129 | ||||
-rw-r--r-- | modules/id3/getid3/module.audio-video.asf.php | 81 | ||||
-rw-r--r-- | modules/id3/getid3/module.audio-video.flv.php | 403 | ||||
-rw-r--r-- | modules/id3/getid3/module.audio-video.quicktime.php | 6 | ||||
-rw-r--r-- | modules/id3/getid3/module.graphic.svg.php | 52 | ||||
-rw-r--r-- | modules/id3/getid3/write.apetag.php | 3 | ||||
-rw-r--r-- | modules/id3/getid3/write.id3v2.php | 16 | ||||
-rw-r--r-- | modules/id3/getid3/write.php | 2 | ||||
-rwxr-xr-x | modules/id3/vainfo.class.php | 11 |
11 files changed, 519 insertions, 222 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 116b6caa..80cc1302 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.3.2-Beta3 + - Upgraded to Getid3() 1.7.6 - Fixed an issue where the new song->get_url() wasn't respecting the force_http_play, this also fixes a long outstanding bug with localplay + https + force_http_play diff --git a/lib/class/song.class.php b/lib/class/song.class.php index bc86c922..d85e0a53 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -48,6 +48,9 @@ class Song { var $addition_time; var $update_time; + /* Setting Variables */ + var $_transcoded = false; + /*! @function Song @discussion Song class, for modifing a song. @@ -744,23 +747,32 @@ class Song { */ function native_stream() { + if ($this->_transcode) { return false; } + switch ($this->type) { //TODO: fill out these cases once we have it working for m4a - case "m4a": - $return = conf('transcode_m4a'); + case 'm4a': + if (conf('transcode_m4a')) { break; } + return true; break; case 'flac': - $return = conf('transcode_flac'); + if (conf('transcode_flac')) { break; } + return true; break; case 'mpc': - $return = conf('transcode_mpc'); + if (conf('transcode_mpc')) { break; } + return true; break; default: - $return = true; + return true; break; } // end switch - return $return; + /* If we've made it this far then we must be trying to transcode */ + $this->_transcode = true; + $this->format_type(); + + return false; } // end native_stream @@ -775,16 +787,23 @@ class Song { if (!$this->native_stream()) { switch ($this->type) { - case "m4a": - $return = "stream_cmd_m4a"; + case 'm4a': + $return = 'stream_cmd_m4a'; + break; + case 'flac': + $return = 'stream_cmd_flac'; + break; + case 'mpc': + $return = 'stream_cmd_mpc'; break; default: - $return = "downsample_cmd"; + $return = 'downsample_cmd'; break; } // end switch } // end if not native_stream return $return; + } // end stream_cmd } // end of song class diff --git a/modules/id3/getid3/getid3.lib.php b/modules/id3/getid3/getid3.lib.php index 26c474db..46bcc84c 100644 --- a/modules/id3/getid3/getid3.lib.php +++ b/modules/id3/getid3/getid3.lib.php @@ -7,54 +7,10 @@ // // // getid3.lib.php - part of getID3() // // See readme.txt for more details // -// // -///////////////////////////////////////////////////////////////// -// getid3_lib::GetURLImageSize( $urlpic ) determines the // -// dimensions of local/remote URL pictures. // -// returns array with ($width, $height, $type) // -// // -// Thanks to: Oyvind Hallsteinsen aka Gosub / ELq - // -// gosubØelq*org for the original size determining code // -// // -// PHP Hack by Filipe Laborde-Basto Oct 21/2000 // -// FREELY DISTRIBUTABLE -- use at your sole discretion! :) // -// Enjoy. (Not to be sold in commercial packages though, // -// keep it free!) Feel free to contact me at filØrezox*com // -// (http://www.rezox.com) // -// // -// Modified by James Heinrich <getid3Øusers*sourceforge*net> // -// June 1, 2001 - created GetDataImageSize($imgData) by // -// seperating the fopen() stuff to GetURLImageSize($urlpic) // -// which then calls GetDataImageSize($imgData). The idea being // -// you can call GetDataImageSize($imgData) with image data // -// from a database etc. // // /// ///////////////////////////////////////////////////////////////// -define('GETID3_GIF_SIG', "\x47\x49\x46"); // 'GIF' -define('GETID3_PNG_SIG', "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A"); -define('GETID3_JPG_SIG', "\xFF\xD8\xFF"); -define('GETID3_JPG_SOS', "\xDA"); // Start Of Scan - image data start -define('GETID3_JPG_SOF0', "\xC0"); // Start Of Frame N -define('GETID3_JPG_SOF1', "\xC1"); // N indicates which compression process -define('GETID3_JPG_SOF2', "\xC2"); // Only SOF0-SOF2 are now in common use -define('GETID3_JPG_SOF3', "\xC3"); -// NB: codes C4 and CC are *not* SOF markers -define('GETID3_JPG_SOF5', "\xC5"); -define('GETID3_JPG_SOF6', "\xC6"); -define('GETID3_JPG_SOF7', "\xC7"); -define('GETID3_JPG_SOF9', "\xC9"); -define('GETID3_JPG_SOF10', "\xCA"); -define('GETID3_JPG_SOF11', "\xCB"); -// NB: codes C4 and CC are *not* SOF markers -define('GETID3_JPG_SOF13', "\xCD"); -define('GETID3_JPG_SOF14', "\xCE"); -define('GETID3_JPG_SOF15', "\xCF"); -define('GETID3_JPG_EOI', "\xD9"); // End Of Image (end of datastream) - - - class getid3_lib { @@ -1211,84 +1167,19 @@ class getid3_lib } - function GetURLImageSize($urlpic) { - if ($fd = @fopen($urlpic, 'rb')){ - $imgData = fread($fd, filesize($urlpic)); - fclose($fd); - return getid3_lib::GetDataImageSize($imgData); + function GetDataImageSize($imgData) { + $GetDataImageSize = false; + if ($tempfilename = tempnam('*', 'getID3')) { + if ($tmp = @fopen($tempfilename, 'rb')) { + fwrite($tmp, $imgData); + fclose($tmp); + $GetDataImageSize = @GetImageSize($tempfilename); + } + unlink($tempfilename); } - return array('', '', ''); + return $GetDataImageSize; } - - function GetDataImageSize($imgData) { - $height = ''; - $width = ''; - $type = ''; - if ((substr($imgData, 0, 3) == GETID3_GIF_SIG) && (strlen($imgData) > 10)) { - $dim = unpack('v2dim', substr($imgData, 6, 4)); - $width = $dim['dim1']; - $height = $dim['dim2']; - $type = 1; - } elseif ((substr($imgData, 0, 8) == GETID3_PNG_SIG) && (strlen($imgData) > 24)) { - $dim = unpack('N2dim', substr($imgData, 16, 8)); - $width = $dim['dim1']; - $height = $dim['dim2']; - $type = 3; - } elseif ((substr($imgData, 0, 3) == GETID3_JPG_SIG) && (strlen($imgData) > 4)) { - ///////////////// JPG CHUNK SCAN //////////////////// - $imgPos = 2; - $type = 2; - $buffer = strlen($imgData) - 2; - while ($imgPos < strlen($imgData)) { - // synchronize to the marker 0xFF - $imgPos = strpos($imgData, 0xFF, $imgPos) + 1; - $marker = $imgData[$imgPos]; - do { - $marker = ord($imgData[$imgPos++]); - } while ($marker == 255); - // find dimensions of block - switch (chr($marker)) { - // Grab width/height from SOF segment (these are acceptable chunk types) - case GETID3_JPG_SOF0: - case GETID3_JPG_SOF1: - case GETID3_JPG_SOF2: - case GETID3_JPG_SOF3: - case GETID3_JPG_SOF5: - case GETID3_JPG_SOF6: - case GETID3_JPG_SOF7: - case GETID3_JPG_SOF9: - case GETID3_JPG_SOF10: - case GETID3_JPG_SOF11: - case GETID3_JPG_SOF13: - case GETID3_JPG_SOF14: - case GETID3_JPG_SOF15: - $dim = unpack('n2dim', substr($imgData, $imgPos + 3, 4)); - $height = $dim['dim1']; - $width = $dim['dim2']; - break 2; // found it so exit - case GETID3_JPG_EOI: - case GETID3_JPG_SOS: - return false; // End loop in case we find one of these markers - default: // We're not interested in other markers - $skiplen = (ord($imgData[$imgPos++]) << 8) + ord($imgData[$imgPos++]) - 2; - // if the skip is more than what we've read in, read more - $buffer -= $skiplen; - if ($buffer < 512) { // if the buffer of data is too low, read more file. - // $imgData .= fread($fd, $skiplen + 1024); - // $buffer += $skiplen + 1024; - return false; // End loop in case we find run out of data - } - $imgPos += $skiplen; - break; - } // endswitch check marker type - } // endif loop through JPG chunks - } // endif chk for valid file types - - return array($width, $height, $type); - } // end function - - function ImageTypesLookup($imagetypeid) { static $ImageTypesLookup = array(); if (empty($ImageTypesLookup)) { diff --git a/modules/id3/getid3/module.audio-video.asf.php b/modules/id3/getid3/module.audio-video.asf.php index c7e5aa1b..34203fce 100644 --- a/modules/id3/getid3/module.audio-video.asf.php +++ b/modules/id3/getid3/module.audio-video.asf.php @@ -146,7 +146,8 @@ class getid3_asf $offset += 4; $thisfile_asf_filepropertiesobject['max_bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); $offset += 4; - $ThisFileInfo['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate']; + //$ThisFileInfo['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate']; + $ThisFileInfo['bitrate'] = ($thisfile_asf_filepropertiesobject['filesize'] * 8) / $ThisFileInfo['playtime_seconds']; break; case GETID3_ASF_Stream_Properties_Object: @@ -331,45 +332,56 @@ class getid3_asf if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) { $thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000); } - if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) { - $thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate']; + //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) { + if (!@$thisfile_video['bitrate'] && @$thisfile_audio['bitrate'] && @$ThisFileInfo['bitrate']) { + //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate']; + $thisfile_video['bitrate'] = $ThisFileInfo['bitrate'] - $thisfile_audio['bitrate']; } $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency)); switch ($AudioCodecFrequency) { case 8: + case 8000: $thisfile_audio['sample_rate'] = 8000; break; case 11: + case 11025: $thisfile_audio['sample_rate'] = 11025; break; case 12: + case 12000: $thisfile_audio['sample_rate'] = 12000; break; case 16: + case 16000: $thisfile_audio['sample_rate'] = 16000; break; case 22: + case 22050: $thisfile_audio['sample_rate'] = 22050; break; case 24: + case 24000: $thisfile_audio['sample_rate'] = 24000; break; case 32: + case 32000: $thisfile_audio['sample_rate'] = 32000; break; case 44: + case 441000: $thisfile_audio['sample_rate'] = 44100; break; case 48: + case 48000: $thisfile_audio['sample_rate'] = 48000; break; @@ -858,16 +870,16 @@ class getid3_asf $thisfile_asf['stream_bitrate_properties_object'] = array(); $thisfile_asf_streambitratepropertiesobject = &$thisfile_asf['stream_bitrate_properties_object']; - $thisfile_asf_streambitrateproperties['objectid'] = $NextObjectGUID; - $thisfile_asf_streambitrateproperties['objectid_guid'] = $NextObjectGUIDtext; - $thisfile_asf_streambitrateproperties['objectsize'] = $NextObjectSize; - $thisfile_asf_streambitrateproperties['bitrate_records_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $thisfile_asf_streambitratepropertiesobject['objectid'] = $NextObjectGUID; + $thisfile_asf_streambitratepropertiesobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_streambitratepropertiesobject['objectsize'] = $NextObjectSize; + $thisfile_asf_streambitratepropertiesobject['bitrate_records_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); $offset += 2; - for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitrateproperties['bitrate_records_count']; $BitrateRecordsCounter++) { - $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) { + $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); $offset += 2; - $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x007F; - $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x007F; + $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); $offset += 4; } break; @@ -928,14 +940,17 @@ class getid3_asf } } if ($ASFbitrateAudio > 0) { - $thisfile_audio['bitrate'] = $ASFbitrateAudio; + $thisfile_audio['bitrate'] = $ASFbitrateAudio; } if ($ASFbitrateVideo > 0) { - $thisfile_video['bitrate'] = $ASFbitrateVideo; + $thisfile_video['bitrate'] = $ASFbitrateVideo; } } if (isset($thisfile_asf['stream_properties_object']) && is_array($thisfile_asf['stream_properties_object'])) { + $thisfile_audio['bitrate'] = 0; + $thisfile_video['bitrate'] = 0; + foreach ($thisfile_asf['stream_properties_object'] as $streamnumber => $streamdata) { switch ($streamdata['stream_type']) { @@ -967,8 +982,20 @@ class getid3_asf break; } - if (!isset($thisfile_audio['bitrate'])) { - $thisfile_audio['bitrate'] = $thisfile_asf_audiomedia_currentstream['bytes_sec'] * 8; + if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { + foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { + if (@$dataarray['flags']['stream_number'] == $streamnumber) { + $thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate']; + $thisfile_audio['bitrate'] += $dataarray['bitrate']; + break; + } + } + } else { + if (@$thisfile_asf_audiomedia_currentstream['bytes_sec']) { + $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bytes_sec'] * 8; + } elseif (@$thisfile_asf_audiomedia_currentstream['bitrate']) { + $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bitrate']; + } } $thisfile_audio['streams'][$streamnumber] = $thisfile_asf_audiomedia_currentstream; $thisfile_audio['streams'][$streamnumber]['wformattag'] = $thisfile_asf_audiomedia_currentstream['raw']['wFormatTag']; @@ -1040,14 +1067,24 @@ class getid3_asf $videomediaoffset += 4; $thisfile_asf_videomedia_currentstream['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset); + if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { + foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { + if (@$dataarray['flags']['stream_number'] == $streamnumber) { + $thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate']; + $thisfile_video['bitrate'] += $dataarray['bitrate']; + break; + } + } + } $thisfile_asf_videomedia_currentstream['format_data']['codec'] = getid3_riff::RIFFfourccLookup($thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']); - $thisfile_video['fourcc'] = $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']; - $thisfile_video['codec'] = $thisfile_asf_videomedia_currentstream['format_data']['codec']; - $thisfile_video['resolution_x'] = $thisfile_asf_videomedia_currentstream['image_width']; - $thisfile_video['resolution_y'] = $thisfile_asf_videomedia_currentstream['image_height']; - $thisfile_video['bits_per_sample'] = $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel']; + $thisfile_video['streams'][$streamnumber]['fourcc'] = $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']; + $thisfile_video['streams'][$streamnumber]['codec'] = $thisfile_asf_videomedia_currentstream['format_data']['codec']; + $thisfile_video['streams'][$streamnumber]['resolution_x'] = $thisfile_asf_videomedia_currentstream['image_width']; + $thisfile_video['streams'][$streamnumber]['resolution_y'] = $thisfile_asf_videomedia_currentstream['image_height']; + $thisfile_video['streams'][$streamnumber]['bits_per_sample'] = $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel']; + $thisfile_video['streams'][$streamnumber]['bitrate'] = $thisfile_asf_videomedia_currentstream['bitrate']; break; default: @@ -1283,7 +1320,7 @@ class getid3_asf } } - switch ($thisfile_audio['codec']) { + switch (@$thisfile_audio['codec']) { case 'MPEG Layer-3': $thisfile_audio['dataformat'] = 'mp3'; break; @@ -1326,7 +1363,7 @@ class getid3_asf $thisfile_video['pixel_aspect_ratio'] = (isset($thisfile_audio['pixel_aspect_ratio']) ? $thisfile_audio['pixel_aspect_ratio'] : (float) 1); $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf'); } - + $ThisFileInfo['bitrate'] = @$thisfile_audio['bitrate'] + @$thisfile_video['bitrate']; return true; } diff --git a/modules/id3/getid3/module.audio-video.flv.php b/modules/id3/getid3/module.audio-video.flv.php index 54666bd2..98661d6c 100644 --- a/modules/id3/getid3/module.audio-video.flv.php +++ b/modules/id3/getid3/module.audio-video.flv.php @@ -5,9 +5,16 @@ // or http://www.getid3.org // // // // FLV module by Seth Kaufman <seth@whirl-i-gig.com> // +// // // * version 0.1 (26 June 2005) // +// // // minor modifications by James Heinrich <info@getid3.org> // // * version 0.1.1 (15 July 2005) // +// // +// Support for On2 VP6 codec and meta information by // +// Steve Webster <steve.webster@featurecreep.com> // +// * version 0.2 (22 February 2006) // +// // ///////////////////////////////////////////////////////////////// // // // module.audio-video.flv.php // @@ -16,6 +23,13 @@ // /// ///////////////////////////////////////////////////////////////// +define('GETID3_FLV_TAG_AUDIO', 8); +define('GETID3_FLV_TAG_VIDEO', 9); +define('GETID3_FLV_TAG_META', 18); + +define('GETID3_FLV_VIDEO_H263', 2); +define('GETID3_FLV_VIDEO_SCREEN', 3); +define('GETID3_FLV_VIDEO_VP6', 4); class getid3_flv { @@ -60,7 +74,7 @@ class getid3_flv $Timestamp = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 4, 3)); switch ($TagType) { - case 8: + case GETID3_FLV_TAG_AUDIO: if (is_null($SoundFormat)) { $SoundInfo = ord(substr($FLVfileData, $CurrentOffset + 11, 1)); $SoundFormat = $SoundInfo & 0x07; @@ -71,69 +85,87 @@ class getid3_flv } break; - case 9: + case GETID3_FLV_TAG_VIDEO: if (is_null($VideoFormat)) { $VideoInfo = ord(substr($FLVfileData, $CurrentOffset + 11, 1)); $VideoFormat = $VideoInfo & 0x07; $ThisFileInfo['flv']['video']['videoCodec'] = $VideoFormat; - $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 15, 2))) >> 7; - $PictureSizeType = $PictureSizeType & 0x0007; - $ThisFileInfo['flv']['header']['videoSizeType'] = $PictureSizeType; - switch ($PictureSizeType) { - case 0: - $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 16, 2)); - $PictureSizeEnc <<= 1; - $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8; - $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 17, 2)); - $PictureSizeEnc <<= 1; - $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8; - break; - - case 1: - $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 16, 4)); - $PictureSizeEnc <<= 1; - $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFFFF0000) >> 16; - - $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 18, 4)); - $PictureSizeEnc <<= 1; - $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFFFF0000) >> 16; - break; - - case 2: - $ThisFileInfo['video']['resolution_x'] = 352; - $ThisFileInfo['video']['resolution_y'] = 288; - break; - - case 3: - $ThisFileInfo['video']['resolution_x'] = 176; - $ThisFileInfo['video']['resolution_y'] = 144; - break; - - case 4: - $ThisFileInfo['video']['resolution_x'] = 128; - $ThisFileInfo['video']['resolution_y'] = 96; - break; - - case 5: - $ThisFileInfo['video']['resolution_x'] = 320; - $ThisFileInfo['video']['resolution_y'] = 240; - break; - - case 6: - $ThisFileInfo['video']['resolution_x'] = 160; - $ThisFileInfo['video']['resolution_y'] = 120; - break; - - default: - $ThisFileInfo['video']['resolution_x'] = 0; - $ThisFileInfo['video']['resolution_y'] = 0; - break; - + if ($VideoFormat != GETID3_FLV_VIDEO_VP6) { + + $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 15, 2))) >> 7; + $PictureSizeType = $PictureSizeType & 0x0007; + $ThisFileInfo['flv']['header']['videoSizeType'] = $PictureSizeType; + switch ($PictureSizeType) { + case 0: + $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 16, 2)); + $PictureSizeEnc <<= 1; + $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8; + $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 17, 2)); + $PictureSizeEnc <<= 1; + $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8; + break; + + case 1: + $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 16, 4)); + $PictureSizeEnc <<= 1; + $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFFFF0000) >> 16; + + $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 18, 4)); + $PictureSizeEnc <<= 1; + $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFFFF0000) >> 16; + break; + + case 2: + $ThisFileInfo['video']['resolution_x'] = 352; + $ThisFileInfo['video']['resolution_y'] = 288; + break; + + case 3: + $ThisFileInfo['video']['resolution_x'] = 176; + $ThisFileInfo['video']['resolution_y'] = 144; + break; + + case 4: + $ThisFileInfo['video']['resolution_x'] = 128; + $ThisFileInfo['video']['resolution_y'] = 96; + break; + + case 5: + $ThisFileInfo['video']['resolution_x'] = 320; + $ThisFileInfo['video']['resolution_y'] = 240; + break; + + case 6: + $ThisFileInfo['video']['resolution_x'] = 160; + $ThisFileInfo['video']['resolution_y'] = 120; + break; + + default: + $ThisFileInfo['video']['resolution_x'] = 0; + $ThisFileInfo['video']['resolution_y'] = 0; + break; + + } } } break; + // Meta tag + case GETID3_FLV_TAG_META: + + $reader = new AMFReader(new AMFStream(substr($FLVfileData, $CurrentOffset + 11, $DataLength))); + $eventName = $reader->readData(); + $ThisFileInfo['meta'][$eventName] = $reader->readData(); + + unset($reader); + + $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['meta']['onMetaData']['framerate']; + $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['meta']['onMetaData']['width']; + $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['meta']['onMetaData']['height']; + + break; + default: // noop break; @@ -181,7 +213,7 @@ class getid3_flv function FLVaudioRate($id) { $FLVaudioRate = array( - 0 => 5500, + 0 => 5500, 1 => 11025, 2 => 22050, 3 => 44100, @@ -191,20 +223,269 @@ class getid3_flv function FLVaudioBitDepth($id) { $FLVaudioBitDepth = array( - 0 => 8, + 0 => 8, 1 => 16, ); return (@$FLVaudioBitDepth[$id] ? @$FLVaudioBitDepth[$id] : false); } function FLVvideoCodec($id) { - $FLVaudioBitDepth = array( - 2 => 'Sorenson H.263', - 3 => 'Screen video', + $FLVvideoCodec = array( + GETID3_FLV_VIDEO_H263 => 'Sorenson H.263', + GETID3_FLV_VIDEO_SCREEN => 'Screen video', + GETID3_FLV_VIDEO_VP6 => 'On2 VP6', ); - return (@$FLVaudioBitDepth[$id] ? @$FLVaudioBitDepth[$id] : false); + return (@$FLVvideoCodec[$id] ? @$FLVvideoCodec[$id] : false); + } +} + +class AMFStream { + var $bytes; + var $pos; + + function AMFStream(&$bytes) { + $this->bytes =& $bytes; + $this->pos = 0; } + function readByte() { + return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1)); + } + + function readInt() { + return ($this->readByte() << 8) + $this->readByte(); + } + + function readLong() { + return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte(); + } + + function readDouble() { + return getid3_lib::BigEndian2Float($this->read(8)); + } + + function readUTF() { + $length = $this->readInt(); + return $this->read($length); + } + + function readLongUTF() { + $length = $this->readLong(); + return $this->read($length); + } + + function read($length) { + $val = substr($this->bytes, $this->pos, $length); + $this->pos += $length; + return $val; + } + + function peekByte() { + $pos = $this->pos; + $val = $this->readByte(); + $this->pos = $pos; + return $val; + } + + function peekInt() { + $pos = $this->pos; + $val = $this->readInt(); + $this->pos = $pos; + return $val; + } + + function peekLong() { + $pos = $this->pos; + $val = $this->readLong(); + $this->pos = $pos; + return $val; + } + + function peekDouble() { + $pos = $this->pos; + $val = $this->readDouble(); + $this->pos = $pos; + return $val; + } + + function peekUTF() { + $pos = $this->pos; + $val = $this->readUTF(); + $this->pos = $pos; + return $val; + } + + function peekLongUTF() { + $pos = $this->pos; + $val = $this->readLongUTF(); + $this->pos = $pos; + return $val; + } +} + +class AMFReader { + var $stream; + + function AMFReader(&$stream) { + $this->stream =& $stream; + } + + function readData() { + $value = null; + + $type = $this->stream->readByte(); + + switch($type) { + // Double + case 0: + $value = $this->readDouble(); + break; + + // Boolean + case 1: + $value = $this->readBoolean(); + break; + + // String + case 2: + $value = $this->readString(); + break; + + // Object + case 3: + $value = $this->readObject(); + break; + + // null + case 6: + return null; + break; + + // Mixed array + case 8: + $value = $this->readMixedArray(); + break; + + // Array + case 10: + $value = $this->readArray(); + break; + + // Date + case 11: + $value = $this->readDate(); + break; + + // Long string + case 13: + $value = $this->readLongString(); + break; + + // XML (handled as string) + case 15: + $value = $this->readXML(); + break; + + // Typed object (handled as object) + case 16: + $value = $this->readTypedObject(); + break; + + // Long string + default: + $value = '(unknown or unsupported data type)'; + break; + } + + return $value; + } + + function readDouble() { + return $this->stream->readDouble(); + } + + function readBoolean() { + return $this->stream->readByte() == 1; + } + + function readString() { + return $this->stream->readUTF(); + } + + function readObject() { + // Get highest numerical index - ignored + $highestIndex = $this->stream->readLong(); + + $data = array(); + + while ($key = $this->stream->readUTF()) { + // Mixed array record ends with empty string (0x00 0x00) and 0x09 + if (($key == '') && ($this->stream->peekByte() == 0x09)) { + // Consume byte + $this->stream->readByte(); + break; + } + + $data[$key] = $this->readData(); + } + + return $data; + } + + function readMixedArray() { + // Get highest numerical index - ignored + $highestIndex = $this->stream->readLong(); + + $data = array(); + + while ($key = $this->stream->readUTF()) { + // Mixed array record ends with empty string (0x00 0x00) and 0x09 + if (($key == '') && ($this->stream->peekByte() == 0x09)) { + // Consume byte + $this->stream->readByte(); + break; + } + + if (is_numeric($key)) { + $key = (float) $key; + } + + $data[$key] = $this->readData(); + } + + return $data; + } + + function readArray() { + $length = $this->stream->readLong(); + + $data = array(); + + for ($i = 0; $i < count($length); $i++) { + $data[] = $this->readData(); + } + + return $data; + } + + function readDate() { + $timestamp = $this->stream->readDouble(); + $timezone = $this->stream->readInt(); + return $timestamp; + } + + function readLongString() { + return $this->stream->readLongUTF(); + } + + function readXML() { + return $this->stream->readLongUTF(); + } + + function readTypedObject() { + $className = $this->stream->readUTF(); + return $this->readObject(); + } } ?>
\ No newline at end of file diff --git a/modules/id3/getid3/module.audio-video.quicktime.php b/modules/id3/getid3/module.audio-video.quicktime.php index 9be09011..c5d6e8d9 100644 --- a/modules/id3/getid3/module.audio-video.quicktime.php +++ b/modules/id3/getid3/module.audio-video.quicktime.php @@ -853,8 +853,10 @@ class getid3_quicktime $ThisFileInfo['video']['resolution_x'] = $atomstructure['width']; $ThisFileInfo['video']['resolution_y'] = $atomstructure['height']; } - $ThisFileInfo['video']['resolution_x'] = max($ThisFileInfo['video']['resolution_x'], $atomstructure['width']); - $ThisFileInfo['video']['resolution_y'] = max($ThisFileInfo['video']['resolution_y'], $atomstructure['height']); + if ($atomstructure['flags']['enabled'] == 1) { + $ThisFileInfo['video']['resolution_x'] = max($ThisFileInfo['video']['resolution_x'], $atomstructure['width']); + $ThisFileInfo['video']['resolution_y'] = max($ThisFileInfo['video']['resolution_y'], $atomstructure['height']); + } if (!empty($ThisFileInfo['video']['resolution_x']) && !empty($ThisFileInfo['video']['resolution_y'])) { $ThisFileInfo['quicktime']['video']['resolution_x'] = $ThisFileInfo['video']['resolution_x']; $ThisFileInfo['quicktime']['video']['resolution_y'] = $ThisFileInfo['video']['resolution_y']; diff --git a/modules/id3/getid3/module.graphic.svg.php b/modules/id3/getid3/module.graphic.svg.php new file mode 100644 index 00000000..e4471456 --- /dev/null +++ b/modules/id3/getid3/module.graphic.svg.php @@ -0,0 +1,52 @@ +<?php +///////////////////////////////////////////////////////////////// +/// getID3() by James Heinrich <info@getid3.org> // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.graphic.svg.php // +// module for analyzing SVG Image files // +// dependencies: NONE // +// author: Bryce Harrington <bryceØbryceharrington*org> // +// /// +///////////////////////////////////////////////////////////////// + + +class getid3_svg +{ + + + function getid3_svg(&$fd, &$ThisFileInfo) { + fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET); + + // I'm making this up, please modify as appropriate + $SVGheader = fread($fd, 32); + $ThisFileInfo['svg']['magic'] = substr($SVGheader, 0, 4); + if ($ThisFileInfo['svg']['magic'] == 'aBcD') { + + $ThisFileInfo['fileformat'] = 'svg'; + $ThisFileInfo['video']['dataformat'] = 'svg'; + $ThisFileInfo['video']['lossless'] = true; + $ThisFileInfo['video']['bits_per_sample'] = 24; + $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1; + + $ThisFileInfo['svg']['width'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4)); + $ThisFileInfo['svg']['height'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 4)); + + $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['svg']['width']; + $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['svg']['height']; + + return true; + } + $ThisFileInfo['error'][] = 'Did not find SVG magic bytes "aBcD" at '.$ThisFileInfo['avdataoffset']; + unset($ThisFileInfo['fileformat']); + return false; + } + +} + + +?>
\ No newline at end of file diff --git a/modules/id3/getid3/write.apetag.php b/modules/id3/getid3/write.apetag.php index 5fdf91ea..189160af 100644 --- a/modules/id3/getid3/write.apetag.php +++ b/modules/id3/getid3/write.apetag.php @@ -122,8 +122,9 @@ class getid3_write_apetag return true; } + return false; } - return false; + return true; } diff --git a/modules/id3/getid3/write.id3v2.php b/modules/id3/getid3/write.id3v2.php index 9d47e708..52398fbd 100644 --- a/modules/id3/getid3/write.id3v2.php +++ b/modules/id3/getid3/write.id3v2.php @@ -342,7 +342,9 @@ class getid3_write_id3v2 if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'], $this->majorversion)) { $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion; } elseif (!isset($source_data_array['data']) || !$this->IsValidURL($source_data_array['data'], false, false)) { - $this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + //$this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + // probably should be an error, need to rewrite IsValidURL() to handle other encodings + $this->warnings[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; } else { $framedata .= chr($source_data_array['encodingid']); $framedata .= $source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']); @@ -754,7 +756,9 @@ class getid3_write_id3v2 } elseif (($this->majorversion >= 3) && (!$this->ID3v2IsValidAPICimageformat($source_data_array['mime']))) { $this->errors[] = 'Invalid MIME Type in '.$frame_name.' ('.$source_data_array['mime'].') for ID3v2.'.$this->majorversion; } elseif (($source_data_array['mime'] == '-->') && (!$this->IsValidURL($source_data_array['data'], false, false))) { - $this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + //$this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + // probably should be an error, need to rewrite IsValidURL() to handle other encodings + $this->warnings[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; } else { $framedata .= chr($source_data_array['encodingid']); $framedata .= str_replace("\x00", '', $source_data_array['mime'])."\x00"; @@ -857,7 +861,9 @@ class getid3_write_id3v2 if (!getid3_id3v2::IsValidID3v2FrameName($source_data_array['frameid'], $this->majorversion)) { $this->errors[] = 'Invalid Frame Identifier in '.$frame_name.' ('.$source_data_array['frameid'].')'; } elseif (!$this->IsValidURL($source_data_array['data'], true, false)) { - $this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + //$this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + // probably should be an error, need to rewrite IsValidURL() to handle other encodings + $this->warnings[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; } elseif ((($source_data_array['frameid'] == 'AENC') || ($source_data_array['frameid'] == 'APIC') || ($source_data_array['frameid'] == 'GEOB') || ($source_data_array['frameid'] == 'TXXX')) && ($source_data_array['additionaldata'] == '')) { $this->errors[] = 'Content Descriptor must be specified as additional data for Frame Identifier of '.$source_data_array['frameid'].' in '.$frame_name; } elseif (($source_data_array['frameid'] == 'USER') && (getid3_id3v2::LanguageLookup($source_data_array['additionaldata'], true) == '')) { @@ -1141,7 +1147,9 @@ class getid3_write_id3v2 // 4.3. W??? URL link frames // URL <text string> if (!$this->IsValidURL($source_data_array['data'], false, false)) { - $this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + //$this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; + // probably should be an error, need to rewrite IsValidURL() to handle other encodings + $this->warnings[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')'; } else { $framedata .= $source_data_array['data']; } diff --git a/modules/id3/getid3/write.php b/modules/id3/getid3/write.php index db09decd..e9dbf160 100644 --- a/modules/id3/getid3/write.php +++ b/modules/id3/getid3/write.php @@ -83,6 +83,7 @@ class getid3_writetags return false; } + $TagFormatsToRemove = array(); if (filesize($this->filename) == 0) { // empty file special case - allow any tag format, don't check existing format @@ -150,7 +151,6 @@ class getid3_writetags } // List of other tag formats, removed if requested - $TagFormatsToRemove = array(); if ($this->remove_other_tags) { foreach ($AllowedTagFormats as $AllowedTagFormat) { switch ($AllowedTagFormat) { diff --git a/modules/id3/vainfo.class.php b/modules/id3/vainfo.class.php index f564b5e9..629c9af5 100755 --- a/modules/id3/vainfo.class.php +++ b/modules/id3/vainfo.class.php @@ -19,7 +19,9 @@ class vainfo { /* Loaded Variables */ var $filename = ''; var $_getID3 = ''; - + var $type = ''; + var $tags = array(); + var $info = array(); /* Returned Variables */ var $_info = array(); @@ -53,9 +55,12 @@ class vainfo { */ function get_info() { - $raw_array = $this->_getID3->analyze($this->filename); + /* Get the Raw file information */ + $raw_array = $this->_getID3->analyze($this->filename); + + /* Figure out what type of file we are dealing with */ + - print_r($raw_array); } // get_info |