Implement our own quicktime parser
This commit is contained in:
12
app/Media/QuickTime/Atoms/moov/meta/free.php
Normal file
12
app/Media/QuickTime/Atoms/moov/meta/free.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Media\QuickTime\Atoms\moov\meta;
|
||||
|
||||
// Unused space available in file.
|
||||
|
||||
use App\Media\QuickTime\Atoms\SubAtom;
|
||||
|
||||
class free extends SubAtom
|
||||
{
|
||||
|
||||
}
|
41
app/Media/QuickTime/Atoms/moov/meta/ilst.php
Normal file
41
app/Media/QuickTime/Atoms/moov/meta/ilst.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Media\QuickTime\Atoms\moov\meta;
|
||||
|
||||
// Item LiST container atom
|
||||
|
||||
use App\Media\QuickTime\Atoms\SubAtom;
|
||||
|
||||
class ilst extends SubAtom
|
||||
{
|
||||
public function __construct(int $offset,int $size,string $filename,?string $data)
|
||||
{
|
||||
parent::__construct($offset,$size,$filename);
|
||||
|
||||
$ptr = 0;
|
||||
while ($ptr < strlen($data)) {
|
||||
$key_size = unpack('Nsize',substr($data,$ptr,4));
|
||||
// Sometimes atoms are terminated with a 0
|
||||
if ($key_size['size'] === 0) {
|
||||
$ptr += 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
$a = unpack(sprintf('a4name/a%ddata',$key_size['size']-8),substr($data,$ptr+4,4+$key_size['size']-8));
|
||||
$ptr += $key_size['size'];
|
||||
|
||||
// If we didnt get the right amount of data, something is wrong.
|
||||
if (strlen($a['data']) < $key_size['size']-8)
|
||||
break;
|
||||
|
||||
$b = unpack(sprintf('Nsize/a4name/a%ddata',strlen($a['data'])-8),$a['data']);
|
||||
|
||||
if ($b['name'] !== 'data')
|
||||
throw new \Exception('Parsing of ILST got data that wasnt expected');
|
||||
$c = unpack(sprintf('a4language/a4unknown/a%ddata',strlen($b['data'])-8),$b['data']);
|
||||
|
||||
// heirachy, name, size, offset
|
||||
$this->cache = $this->cache->push($c['data']);
|
||||
}
|
||||
}
|
||||
}
|
26
app/Media/QuickTime/Atoms/moov/meta/keys.php
Normal file
26
app/Media/QuickTime/Atoms/moov/meta/keys.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Media\QuickTime\Atoms\moov\meta;
|
||||
|
||||
// The metadata item keys atom holds a list of the metadata keys that may be present in the metadata atom.
|
||||
// This list is indexed starting with 1; 0 is a reserved index value. The metadata item keys atom is a full atom with an atom type of "keys".
|
||||
|
||||
use App\Media\QuickTime\Atoms\SubAtom;
|
||||
|
||||
class keys extends SubAtom
|
||||
{
|
||||
public function __construct(int $offset,int $size,string $filename,?string $data)
|
||||
{
|
||||
parent::__construct($offset,$size,$filename);
|
||||
|
||||
$this->keys = collect();
|
||||
$read = unpack($this->unpack(self::atom_record),substr($data,0,$ptr=$this->unpack_size(self::atom_record)));
|
||||
|
||||
for ($i=0; $i<$read['count']; $i++) {
|
||||
$key_size = unpack('Nsize',substr($data,$ptr,4));
|
||||
$keys = unpack(sprintf('a4namespace/a%dname',$key_size['size']-8),substr($data,$ptr+4,4+$key_size['size']-8));
|
||||
$ptr += $key_size['size'];
|
||||
$this->cache = $this->cache->push(sprintf('%s.%s',$keys['namespace'],$keys['name']));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user