wiztrust / php-reader

Automatically exported from code.google.com/p/php-reader
0 stars 0 forks source link

Zend_Media_Iso14496 Class 2 GB size limit for m4v / mp4 files #62

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The code listed below should extract the cover of a previously with iTunes 
tagged video (m4v or mp4). This works as long the file is not bigger than 2GB 
(running on Mac with 64bit Mac OS X).

As soon as a file is bigger than 2GB, isset($isom....) returns False.

Any solution to come around this issue?
Thanks, would really appreciate to get this solved!

Code:

<?php
require_once 'Zend/Media/Iso14496.php'; // or using autoload
$file = "file.m4v" ;

$isom = new Zend_Media_Iso14496($file);
if (isset($isom->moov->udta->meta->ilst)) {
$ilst = $isom->moov->udta->meta->ilst;
if (isset($ilst->covr)) {
if ($ilst->covr->data->hasFlag(Zend_Media_Iso14496_Box_Data::JPEG)) $imagetype 
= ".jpg" ;
if ($ilst->covr->data->hasFlag(Zend_Media_Iso14496_Box_Data::PNG)) $imagetype = 
".png"; 
if (($handle = fopen("temp" , "wb")) !== false) {
fwrite($handle,$ilst->covr->data->value);
fclose($handle);

list($width, $height) = getimagesize("temp");
$thumb = imagecreatetruecolor(100, 100);
if ($imagetype == ".png") $source = imagecreatefrompng("temp");
else $source = imagecreatefromjpeg("temp");
imagecopyresized($thumb, $source, 0, 0, 0, 0, 100, 100, $width, $height);
imagejpeg($thumb,substr($file,0,strlen($file)-4) . ".jpg" , 100) ;
imagedestroy($thumb);
}
} 
} 
else {
echo "no tag found<br/>";
}
?>

Original issue reported on code.google.com by Werner.T...@googlemail.com on 17 Sep 2011 at 10:32

GoogleCodeExporter commented 9 years ago
Hmm,  I haven't tried the library with files over 2GB. Could you do me a favor 
and figure out whether the library is reading the metadata information 
correctly (which means the problem is in isset) or not (which means the problem 
is in the library itself).

Execute this piece of code:

$iso = new Zend_Media_Iso14496("file.m4v");
print_r($iso);

Then paste the response here.

Original comment by svollbehr on 14 Oct 2011 at 11:31

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for your PHP tool it is amazing :)

I have a similar issue with various mp4 files over 2 GB (works fine with files 
under 2 GB).

28.mp4 = 3 440 448 599 bytes

require_once '/Zend/Media/Iso14496.php'; // or using autoload
$isom = new Zend_Media_Iso14496("28.mp4");
print_r($isom);

output of the above code:

Zend_Media_Iso14496 Object ( [_filename:Zend_Media_Iso14496:private] => 28.mp4 
[_reader:protected] => Zend_Io_FileReader Object ( [_fd:protected] => Resource 
id #7 [_size:protected] => -854518697 ) 
[_options:Zend_Media_Iso14496_Box:private] => Array ( ) 
[_offset:Zend_Media_Iso14496_Box:private] => 0 
[_size:Zend_Media_Iso14496_Box:private] => -854518697 
[_type:Zend_Media_Iso14496_Box:private] => file 
[_parent:Zend_Media_Iso14496_Box:private] => 
[_container:Zend_Media_Iso14496_Box:private] => 1 
[_boxes:Zend_Media_Iso14496_Box:private] => Array ( ) ) 

Is it possible to override this 2GB limit and if yes how? 

thanks
Arnaud

Original comment by arnaud.l...@gmail.com on 30 Jan 2013 at 11:44

GoogleCodeExporter commented 9 years ago
I actually managed to pin down the issue (well mine at least). I was using a 32 
bits version of PHP on a WAMP server, having test the script on PHP 64 bits 
LAMP and the script works fine.

Hope it helps.
Thanks
Arnaud

Original comment by arnaud.l...@gmail.com on 4 Feb 2013 at 11:50

GoogleCodeExporter commented 9 years ago
Apparently it is related to the maximum size for an int in PHP:
32-bit builds of PHP:
Integers can be from -2147483648 to 2147483647
64-bit builds of PHP:
Integers can be from -9223372036854775808 to 9223372036854775807

Thanks
Arnaud

Original comment by arnaud.l...@gmail.com on 4 Feb 2013 at 11:52