[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / plugins-dist / medias / metadata / flv.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 function metadata_flv_dist($file, $bigindian = true){
16 $meta = array();
17
18 if ($fd = fopen($file, 'r')
19 AND $raw = fread($fd, 512)){
20
21 $keys = array('largeur'=>'width', 'hauteur'=>'height','duree'=>'duration','framerate'=>'framerate');
22 foreach ($keys as $m=>$k) {
23 if (($i = strpos($raw, $k))>-1){
24 $bytes = substr($raw, $i+strlen($k)+1, 8);
25 if ($bigindian)
26 $bytes = strrev($bytes);
27 $zz = unpack("dflt", $bytes); // unpack the bytes
28 $meta[$m] = $zz['flt']; // return the number from the associative array
29 }
30 }
31 }
32
33 return $meta;
34 }
35
36 ?>