source: extensions/PHP_Optimisateur/plugins/charlies_content/main.php

Last change on this file was 12819, checked in by mistic100, 12 years ago

fix detection regex and watermark position

File size: 3.1 KB
Line 
1<?php
2/***************************************\
3|            PHP OPTIMISATEUR           |
4|     Plugin Charlie's Content 1.0      |
5\***************************************/
6
7## Génère des miniatures pour divers types de fichiers
8
9$CC_charlies_exts = array( // all extensions supported by Charlies' Content
10  'flv','swf','pls','m3u','wav','mid','au','aif','mp3','pdf',
11  'asf','wmv','divx','xvid','aiff','aac','bmp','gsm','mov','mpg',
12  'mpeg','mp4','m4a','psd','qt','qtif','qif','qti','snd','tif',
13  'tiff','3g2','3pg','zip','rar','gpx','3gp',
14);
15$CC_video_exts = array( // extensions tested with FFmpeg
16  'wmv','mov','mkv','mp4','mpg','flv','asf','xvid','divx','mpeg',
17  'avi','rm', # <-- additional formats
18);
19$CC_video_time = $CONF['Plugins']['charlies_content']['video_time'];
20
21if (!function_exists('ffmpeg')) {
22function ffmpeg($param, $log=true) {
23  global $LOG;
24
25  exec('include\ffmpeg.exe '. $param .' 2>&1', $out);
26 
27  if ($log) {
28    $LOG[] = 'FFmpeg conversion : ' . $param;
29  } else {
30    return $out;
31  }
32}
33}
34
35if (in_arrayi($file['ext'], $CC_video_exts)) {
36  // copie la video
37  copy_log($FilesSource[$i], $FilesSortie[$i]);
38 
39  // infos sur le fichier
40  $infos = ffmpeg('-i "'. $FilesSource[$i] .'"', false);
41  $infos = implode('|', $infos);
42 
43  // taille de la video
44  if (preg_match('#\, (\d+)x(\d+)#s', $infos, $sizes)) {
45    $FileInfos = array(
46      'Width' => $sizes[1],
47      'Height' => $sizes[2],
48    );
49  }
50
51  // position de la miniature
52  $second = 10;
53  if ($CC_video_time == 'rand') {
54    if (preg_match('#Duration: ((\d+):(\d+):(\d+))#s', $infos, $time)) {
55      $total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
56      $second = rand(1, ($total - 1));
57    }
58  } else if (is_int($CC_video_time)) {
59    $second = $CC_video_time;
60  }
61 
62  // création d'un ficher pleine taille temporaire
63  mkdir('temp', 0777, true);
64  ffmpeg('-i "'. $FilesSource[$i] .'" -an -ss '.$second.' -t 1 -r 1 -y -vcodec mjpeg -f mjpeg "temp/'.$file['name'].'.jpg"'); 
65 
66  // miniature, utilise Create Custom Thumbs si activé
67  if (
68    isset($CONF['Plugins']['create_custom_thumbs']) 
69    AND $CONF['Plugins']['create_custom_thumbs']['active']
70  ) {
71    unset($BlockAll);
72    $CCT_filesource = 'temp/'.$file['name'].'.jpg';
73    include('plugins/create_custom_thumbs/main.php');
74    $BlockAll['main'] = true;
75 
76  } else {
77    nconvert('-q '.$CONF['Qthumbnail'].' -out jpeg -o "'.$file['folder_out'].'thumbnail/'.$CONF['prefixe_mini'].$file['name'].'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$CONF['DIMthumbnail'].' '.$CONF['DIMthumbnail'].' -rmeta -rexifthumb "temp/'.$file['name'].'.jpg"');
78  }
79
80  // suppression des fichiers temporaires
81  @rrmdir('temp');
82 
83  $BlockThumbnail['charlies_content'] = true;
84  $BlockNormal['charlies_content'] = true;
85  $BlockHigh['charlies_content'] = true;
86 
87} else if (in_arrayi($file['ext'], $CC_charlies_exts)) {
88  // copie le fichier
89  copy_log($FilesSource[$i], $FilesSortie[$i]);
90 
91  $BlockThumbnail['charlies_content'] = true;
92  $BlockNormal['charlies_content'] = true;
93  $BlockHigh['charlies_content'] = true;
94}
95
96?>
Note: See TracBrowser for help on using the repository browser.