Ignore:
Timestamp:
Jan 1, 2012, 10:09:17 PM (12 years ago)
Author:
mistic100
Message:

fix detection regex and watermark position

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PHP_Optimisateur/plugins/charlies_content/main.php

    r10338 r12819  
    11<?php
    22/***************************************\
    3 |                       PHP OPTIMISATEUR                        |
    4 |         Plugin Charlie's Content 1.0          |
     3|            PHP OPTIMISATEUR           |
     4|     Plugin Charlie's Content 1.0      |
    55\***************************************/
    66
     
    88
    99$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',
     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',
    1414);
    1515$CC_video_exts = array( // extensions tested with FFmpeg
    16         'wmv','mov','mkv','mp4','mpg','flv','asf','xvid','divx','mpeg',
    17         'avi','rm', # <-- additional formats
     16  'wmv','mov','mkv','mp4','mpg','flv','asf','xvid','divx','mpeg',
     17  'avi','rm', # <-- additional formats
    1818);
    1919$CC_video_time = $CONF['Plugins']['charlies_content']['video_time'];
     
    2121if (!function_exists('ffmpeg')) {
    2222function ffmpeg($param, $log=true) {
    23         global $LOG;
     23  global $LOG;
    2424
    25         exec('include\ffmpeg.exe '. $param .' 2>&1', $out);
    26        
    27         if ($log) {
    28                 $LOG[] = 'FFmpeg conversion : ' . $param;
    29         } else {
    30                 return $out;
    31         }
     25  exec('include\ffmpeg.exe '. $param .' 2>&1', $out);
     26 
     27  if ($log) {
     28    $LOG[] = 'FFmpeg conversion : ' . $param;
     29  } else {
     30    return $out;
     31  }
    3232}
    3333}
    3434
    3535if (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         }
     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  }
    5050
    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         }
     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  }
    7979
    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        
     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 
    8787} 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;
     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;
    9494}
    9595
Note: See TracChangeset for help on using the changeset viewer.