[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins-dist / medias / metadata / video.php
1 <?php
2 /**
3 * GetID3
4 * Gestion des métadonnées de fichiers sonores et vidéos directement dans SPIP
5 *
6 * Auteurs :
7 * kent1 (http://www.kent1.info - kent1@arscenic.info), BoOz
8 * 2008-2016 - Distribué sous licence GNU/GPL
9 *
10 * @package SPIP\GetID3\Metadatas
11 */
12
13 if (!defined('_ECRIRE_INC_VERSION')) {
14 return;
15 }
16
17 /**
18 * Fonction de récupération des métadonnées sur les fichiers vidéo
19 * appelée à l'insertion en base dans le plugin medias (inc/renseigner_document)
20 *
21 * @param string $file
22 * Le chemin du fichier à analyser
23 * @return array $metas
24 * Le tableau comprenant les différentes metas à mettre en base
25 */
26 function metadata_video($file) {
27 $meta = array();
28
29 include_spip('lib/getid3/getid3');
30 $getID3 = new getID3;
31 $getID3->setOption(array('tempdir' => _DIR_TMP));
32
33 // Scan file - should parse correctly if file is not corrupted
34 $file_info = $getID3->analyze($file);
35
36 /**
37 * Les pistes vidéos
38 */
39 if (isset($file_info['video'])) {
40 $id3['hasvideo'] = 'oui';
41 if (isset($file_info['video']['resolution_x'])) {
42 $meta['largeur'] = $file_info['video']['resolution_x'];
43 }
44 if (isset($file_info['video']['resolution_y'])) {
45 $meta['hauteur'] = $file_info['video']['resolution_y'];
46 }
47 if (isset($file_info['video']['frame_rate'])) {
48 $meta['framerate'] = $file_info['video']['frame_rate'];
49 }
50 }
51 if (isset($file_info['playtime_seconds'])) {
52 $meta['duree'] = round($file_info['playtime_seconds'], 0);
53 }
54
55 return $meta;
56 }