Re: Decompressing a string with zlib problems

From: Date: Fri, 28 Oct 2005 21:30:19 +0000
Subject: Re: Decompressing a string with zlib problems
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-224795@lists.php.net to get a copy of this message
Well, maybe QT has a very wacked out version of zLib ? This is what I sent to the Quicktime API list: //-------------------------------------------------------------------------------- Ok, here we go :) Isn't looking through reams of hex data a blast ? Kind of like a hot poker in the eye ;) curl -l -i "http://www.siren.cc/siren/reel/Library/php/zlib.php" Here are two versions of the SAME test movie exported from Livestage: One version has compressed movie headers The other version has uncompressed movie headers With zLib, I am using gzcompress at compression level 6, and gzuncompress. All the string data below was converted from hex with the pack() function. The actual php script I wrote for this test is way way below. The upshot: 1)Using zlib to compress and decompress a movie header seems to work fine :) 2)Attempting to 'gzuncompress' a movie header that was compressed in Livestage gives an error. I doubt this is fault of Livestage which I assume is simply calling DataCodecCompress or an equivalent function, no ? 3) The Livestage'd compressed movie header output IS NOT THE SAME as a the zLib'd compressed movie header output Maybe I am not starting at the correct point in the compressed movie header string? hopefully, this is enough to start a dialog. here is the output: //----------------------------------------------------- The uncompressed movie header string is: trak\tkhd??7???7?X??@$edtselstXnmdia mdhd??7???7?XXH?hdlrmhlrsprtappl?Sprite Animation Media Handlerminf gmhdgmin@??????9hdlrdhlralisappl?Apple Alias Data Handler$dinfdref
                                                                                                                                                                           alis?stbl,stsdzlibsttsXstscstszstco&?code?sean       emk
hjkedtligudta
             namedrm]udta#?swrMade with LiveStage Proplugmoviename=drm.mov
                                                                          ctypnone      play
//----------------------------------------------------- Compressed in Livestage: the compressed movie header string is:
?cmvd?x??S?n1?l?P?H     ՂV"G?q@???T?ppbg????l7Q??z?+??Џ???8Nw??}?x?????.@?Z???^w?????|  ?=??9???[?????o??~4???k??e?soo?C7?
??P???7?&Fs???4?ǻ?
                  ?,?u????gU?K?s?ꬲҋld?f^?&;H????J`Z?PK3#?\?A??Mͷa???oe8?0%?<??????*J2?3??!?܊Y?;?D??O??7?;޸??;?Vr??C??m?R?????
ӂ[Cߢ??o???8a\dK??\?3?r??Z?ߋJ??\HA?????ԯ*Sj?A??*0?F?]9                                                                        c?8×?oZ6f p?;-?hM??        fb?A?!?O?9
//----------------------------------------------------- The zlib version of the uncompressed movie header using gzcompress at level 6 is: x??SMN?@~v?ZZ*uQH@??T?U?m?EU??`?HHٰ??!3??̌??I9K?-8E?8??H?s?qb?EG?4o???=??:?:ϧ??4?ß?/????D??k??>.-?o????[6F?̏K?N?Y?յ??Ѝ???P???????撡?h?̻#?g\Y??LYWXϊB?,Qt?~XX?Erd?f^??M???J`Y?BKsA2?.ez):=????Z?p?aJ:?y??y??U?d.??????@?[q?2?-" ??????'?_??7':S?<?{Η3?b????1Z?/?c?p???o????;ʹh??̄????h?>?]?Z??b????Fd??(87ɷ???4?$?ZmP?l?Ri#uѝpO_?kô?V?Я??p?.-t???R?,?)?b?Y*?K??-?$??T ????u??n??UarC??,??t_???? //----------------------------------------------------- the uncompressed zlib movie header string using gzuncompress is: trak\tkhd??7???7?X??@$edtselstXnmdia mdhd??7???7?XXH?hdlrmhlrsprtappl?Sprite Animation Media Handlerminf gmhdgmin@??????9hdlrdhlralisappl?Apple Alias Data Handler$dinfdref
                                                                                                                                                                           alis?stbl,stsdzlibsttsXstscstszstco&?code?sean       emk
hjkedtligudta
             namedrm]udta#?swrMade with LiveStage Proplugmoviename=drm.mov
                                                                          ctypnone      play
//----------------------------------------------------- Here is the attempt to use gzuncompress with the movieheader compressed in Livestage: <br /> <b>Warning</b>: gzuncompress(): data error in <b>/home/www/siren/siren/reel/Library/php/zlib.php</b> on line <b>34</b><br /> Here is the PHP script: <?php $uncompressed_movieheader_hex="000003DE6D6F6F760000006C6D76686400000000BF883792BF883792000002580000025800010000010000000000000000000000000100000000000000000000000000000001000000000000000000000000000040000000000000000000025800000000000000000000000000000000000000020000030D7472616B0000005C746B686400000003BF883792BF8837920000000100000000000002580000000000000000FFFE000000000000000100000000000000000000000000000001000000000000000000000000000040000000000200000002000000000024656474730000001C656C737400000000000000010000025800000000000100000000026E6D646961000000206D64686400000000BF883792BF8837920000025800000258000000480000003F68646C72000000006D686C72737072746170706C00000001000101C11E53707269746520416E696D6174696F6E204D656469612048616E646C6572000002076D696E6600000020676D686400000018676D696E000000000040FFFFFFFFFFFF000000000000003968646C720000000064686C72616C69736170706C10000001000101D2184170706C6520416C69617320446174612048616E646C65720000002464696E660000001C6472656600000000000000010000000C616C697300000001000000907374626C0000002C7374736400000000000000010000001C000000000000000000000001000000007A6C6962000000000000001873747473000000000000000100000001000002580000001C737473630000000000000001000000010000000100000001000000147374737A000000000000021D00000001000000147374636F000000000000000100000426000000F2636F6465000000000000000000000000000000DE7365616E0000000100000009000000000000001A00000065000000010000000000000000000000000000000000160000006D0000000100000000000000000001000000180000006B0000000100000000000000000000000A000000150000006800000001000000000000000001000000150000006A00000001000000000000000000000000156B65647400000001000000000000000000000000160000006C000000010000000000000000000000000015000000690000000100000000000000000100000018000000670000000100000000000000000000000400000017756474610000000B6E616D6564726D000000000000005D7564746100000023A9737772001700004D6164652077697468204C69766553746167652050726F00000019706C75676D6F7669656E616D653D64726D2E6D6F760000000C637479706E6F6E6500000009706C6179000000000000000008"; $compressed_movieheader_hex="000001D0636D7664000003DE789C9553C16E1331109D6C9050A1481C0809D582562247C415714010A9871CA854A9170E70706267D7C4F6AE6C3751F2051CF9037AE52BAAFE021FD08FE003DACE384E77B31107AC7DF278C6F3DEECCC2E40F75A97E50200945E141C77B8FCF1EE8200907C09E8003DF5DA39EC9F3FDD5B94BFB71280EE136FD91CEDAF7E1E34BBA8F76BA3B965AB736F6FFE43378900180AEE1DEEA950CED7199137E4264673C9D0C834FFC7BB038C111F0BAE2CC575A1ACABAC6755A5024BA773F5EAACB2D28B6C64A4665E96263B11489B8D99E14A605AF2504B3323995C0799418E8E4DCDB761C5F2DE6F6538CA30251DC93CDDC8FC198CF0802A4A32971D33DF108021DF08A4DC8A59A33B874412ED9FCE4FA8E637CE3BDEB893B63BBA567212CF03E7430FB7B16DFF52E498EEFAEFF10C63EB38C397B56F5A36662070FF3B2DB9684DF4DA096662CE41F41D2104EC4F1FE0390D642742D600316FDD7F84E8218AA6BF139DDFDBE4BD397E3A6D2789A9BD32285FB649A982BC75F501A27FCE3D7D6D8F0DD3825B1D43DFA2FBF56FB7B4D00738615C644BE98BECB35C8833CF72919D5AEADF8B4A9DE7BA5C4841141F90E3AD0E3FEFE1D4AF2A531A6AD441A5D82A30DF0110468E5D00000039"; $uncompressed_movieheader_string = pack("H*", $uncompressed_movieheader_hex); echo '//-----------------------------------------------------'."\n\r"; echo "The uncompressed movie header string is:". "\r\n"; echo $uncompressed_movieheader_string."\r\n\r\n"; $compressed_hexstring = pack("H*", $compressed_movieheader_hex); echo '//-----------------------------------------------------'."\n\r"; echo "Compressed in Livestage: the compressed movie header string is:"."\r\n"; echo $compressed_hexstring."\r\n\r\n"; $compressed_zlib_movieheader_string = gzcompress($uncompressed_movieheader_string, 6); echo '//-----------------------------------------------------'."\n\r"; echo "The zlib version of the uncompressed movie header using gzcompress at level 6 is: "."\r\n"; echo $compressed_zlib_movieheader_string."\r\n\r\n"; $decompressed_zlib_movieheader_string= gzuncompress($compressed_zlib_movieheader_string); echo '//-----------------------------------------------------'."\n\r"; echo "the uncompressed zlib movie header string using gzuncompress is: "."\r\n"; echo $decompressed_zlib_movieheader_string."\r\n\r\n"; echo '//-----------------------------------------------------'."\n\r"; echo "Here is the attempt to use gzuncompress with the movieheader compressed in Livestage: "."\r\n"; $decompressLSCompressedMovieHeader= gzuncompress($compressed_hexstring); echo $decompressLSCompressedMovieHeader."\r\n\r\n"; ?> On Oct 28, 2005, at 8:15 AM, Robin Vickery wrote:
On 10/28/05, Graham Anderson <grahama@siren.cc> wrote:
I am having problems decompressing a zlib'd string located in a file. In the file headers, the compression says that it is zlib. But, when I 'gzinflate' the string, I get the error: gzinflate(): data error in <b Is the below NOT a zlib or some strange variant ? <?php $hex="C0636D7664000003DE789C95533B4E [...]
Is this thread any help? http://lists.apple.com/archives/QuickTime-java/2003/Sep/msg00038.html Looking at your binary data in a hex editor, you've got what looks like a cmvd header at the start. If the next four bytes are the length of the compressed data, then you've got probably got 990 bytes following that that you should be decompressing. -robin


« previous php.general (#224795) next »