Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jamiefrancis

Pages: [1]
1
Mods & Plugins (Requests & Discussions) / Re: Video thumbnailer?
« on: October 21, 2007, 06:47:48 PM »
Hi Ice,

I Understand what you say, but it is something quite soughtafter and IMHO quite needed.

I Just need to find out where to place the code

Code: [Select]
ffmpeg -i sourcevideo.mpg -f singlejpeg -t 0.001 outputthumb.jpg
and then 4Images will handle video just as good as Images :-)

If this interests you maybe follow the mod i requested @ http://www.4homepages.de/forum/index.php?topic=12272.0


put it on your image_utils.php

}
function Generate_VideoThumb($src, $dest) {
  global $convert_options;

  $command = "/usr/bin/ffmpeg -i ".$src." -f mjpeg -t 0.02 -s 90x90 ".$dest;
  echo ($command);
  system($command);

  return (file_exists($dest)) ? 1 : 0;
}


2
Hi the problem is that,
videos uploaded before i started using ffmpeg has the standard icon saying no images.
when i use the autothumbnailer its doesnt detect those old video files without thumbnails:(

3
Hi Wez and thurnderstrike,

here is my image_utils.php

Quote
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: image_utils.php                                      *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.4                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/
if (!defined('ROOT_PATH')) {
  die("Security violation");
}

function init_convert_options() {
  global $config, $lang;

  $convert_options = array(
    "convert_error" => 0,
    "convert_tool" => $config['convert_tool'],
    "convert_path" => ereg_replace("\/$", "", $config['convert_tool_path'])
  );
  switch($config['convert_tool']) {
  case "im":
    $exec = check_executable("convert");
    $convert_options['convert_path'] = preg_replace("/\/?(".check_executable("mogrify")."|$exec)+$/i", '', $convert_options['convert_path']);
    $convert_options['convert_path'] = $convert_options['convert_path'] . '/' . $exec;
    if (!@is_executable($convert_options['convert_path'])) {
      $convert_options['convert_error'] = "<b class=\"marktext\">".$lang['im_error']."</b><br />\n".$lang['check_module_settings'];
    }
    break;
  case "gd":
    $convert_options['convert_gd2'] = false;

    if (defined('CONVERT_IS_GD2')) {
      $convert_options['convert_gd2'] = CONVERT_IS_GD2 == 0 ? false : true;
    } elseif (function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled")) {
      $convert_options['convert_gd2'] = true;
    }

    if (!function_exists("imagetypes")) {
      $convert_options['convert_error'] = (defined("IN_CP")) ? "<b class=\"marktext\">".$lang['gd_error']."</b><br />\n".$lang['check_module_settings'] : 1;
    }
    break;
  case "netpbm":
    if (!@is_executable($convert_options['convert_path']."/".check_executable("pnmscale"))) {
      $convert_options['convert_error'] = (defined("IN_CP")) ? "<b class=\"marktext\">".$lang['netpbm_error']."</b><br />\n".$lang['check_module_settings'] : 1;
    }
    break;
  default:
    $convert_options['convert_error'] = (defined("IN_CP")) ? "<b class=\"marktext\">".$lang['no_convert_module']."</b><br />\n".$lang['check_module_settings'] : 1;
  }
  return $convert_options;
}

function resize_image_gd($src, $dest, $quality, $width, $height, $image_info) {
  global $convert_options;

  $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
  if ($convert_options['convert_gd2']) {
    $thumb = imagecreatetruecolor($width, $height);
  }
  else {
    $thumb = imagecreate($width, $height);
  }
  $image_create_handle = "imagecreatefrom".$types[$image_info[2]];
  if ($image = $image_create_handle($src)) {
    if ($convert_options['convert_gd2']) {
      imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
    }
    else {
      imagecopyresized($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
    }

    if ($image_info[2] == 3) {
      $quality = 9;
    }

    $image_handle = "image".$types[$image_info[2]];
    $image_handle($thumb, $dest, $quality);
    imagedestroy($image);
    imagedestroy($thumb);
  }
  return (file_exists($dest)) ? 1 : 0;
}

function resize_image_im($src, $dest, $quality, $width, $height, $image_info) {
  global $convert_options;

  $command = $convert_options['convert_path']." -quality ".$quality." -antialias -sample $width"."x"."$height \"$src\" \"$dest\"";
  system($command);
  return (file_exists($dest)) ? 1 : 0;
}

function resize_image_netpbm($src, $dest, $quality, $width, $height, $image_info) {
  global $convert_options;

  $convert_path = $convert_options['convert_path'];
  $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
  $target = ($width > $height) ? $width : $height;
  $command = $convert_path."/".check_executable($types[$image_info[2]]."topnm")." ".$src." | ".$convert_path."/".check_executable("pnmscale")." --quiet -xysize ".$target." ".$target." | ";
  if ($image_info[2] == 1) {
    $command .= $convert_path."/".check_executable("ppmquant")." 256 | " . $convert_path."/".check_executable("ppmtogif")." > ".$dest;
  }
  elseif ($image_info[2] == 3) {
    $command .= $convert_path."/".check_executable("pnmtopng")." > ".$dest;
  }
  else {
    $jpeg_exec = (file_exists($convert_path."/".check_executable("pnmtojpeg"))) ? check_executable("pnmtojpeg") : check_executable("ppmtojpeg");
    $command .= $convert_path."/".$jpeg_exec." --quality=".$quality." > ".$dest;
  }
  system($command);
  return (file_exists($dest)) ? 1 : 0;
}

function get_width_height($dimension, $width, $height, $resize_type = 1) {
  if ($resize_type == 2) {
    $new_width = $dimension;
    $new_height = floor(($dimension/$width) * $height);
  }
  elseif ($resize_type == 3) {
    $new_width = floor(($dimension/$height) * $width);
    $new_height = $dimension;
  }
  else {
    $ratio = $width / $height;
    if ($ratio > 1) {
      $new_width = $dimension;
      $new_height = floor(($dimension/$width) * $height);
    }
    else {
      $new_width = floor(($dimension/$height) * $width);
      $new_height = $dimension;
    }
  }
  return array("width" => $new_width, "height" => $new_height);
}

function create_thumbnail($src, $dest, $quality, $dimension, $resize_type) {
  global $convert_options;

  if (file_exists($dest)) {
    @unlink($dest);
  }
  $image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (!$image_info) {
    if (Generate_VideoThumb($src, $dest)) {
   echo $src.$dest;
   return true;
   }
   else {
   echo $src.$dest;
    return false;
    }
  }
  echo $src.$dest;
  $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
  $resize_handle = "resize_image_".$convert_options['convert_tool'];
  if ($resize_handle($src, $dest, $quality, $width_height['width'], $width_height['height'], $image_info)) {
    @chmod($dest, CHMOD_FILES);
    return true;
  }
  else {
    return false;
  }
}
function Generate_VideoThumb($src, $dest) {
  global $convert_options;

  $command = "/usr/local/bin/ffmpeg -i ".$src." -f mjpeg -t 0.02 -s 90x90 ".$dest;
  echo ($command);
  system($command);

  return (file_exists($dest)) ? 1 : 0;
}


function resize_image($file, $quality, $dimension, $resize_type = 1) {
  global $convert_options;
  $image_info = (defined("IN_CP")) ? getimagesize($file) : @getimagesize($file);
  if (!$image_info) {
    return false;
  }
  $file_bak = $file.".bak";
  if (!rename($file, $file_bak)) {
    return false;
  }
  $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
  $resize_handle = "resize_image_".$convert_options['convert_tool'];
  if ($resize_handle($file_bak, $file, $quality, $width_height['width'], $width_height['height'], $image_info)) {
    @chmod($file, CHMOD_FILES);
    @unlink($file_bak);
    return true;
  }
  else {
    rename($file_bak, $file);
    return false;
  }
}
?>

4
Mods & Plugins (Releases & Support) / Re: [MOD] Auto-Thumbnailer v2.2.1
« on: August 21, 2007, 12:22:36 AM »
Hi everyone!
How do I make the thumbnailer.php (version 2.2.1) in CP see that the thumbs are missing?
This function does not see that mov,wmv,avi,mpg  files have no thumbs in Database....  I am using this code

http://www.4homepages.de/forum/index.php?topic=12272.15

Please help. I have a ton of videos with no preview that I want to add thumbs to but the thumbnailer does not check mov,wmv,avi,mpg files
Thanks,
Aleksey

Hi guys,

i have the same problem, can somebody help me please thanks:)

5
Hi WeZ,

After i installed the ffmpeg to generate the video thumbnails everything works well,
my problem is that all the previous videos i had before i installed the script is using the standard icon ex: 3gp, wmv, avi
when i i use the autothumbnailer MOD 2.2.1 it doesnt detect the video files without a thumbnail.

i thought you were able to remedy this problem:)
thanks

6
Hi son_gokou & alekseyn1,

Anyway, alekseyn1... i think i might be able to help you considering i also have that plug-in installed.

Thanks Wez! It helps a lot! At least this code now hels the thumbnailer.php to see that the thumb is missing... I will have to dig more in my code... mplayer.exe is not working properly for me...

Thanks anyways!

Hi Wez and Alekseyn1,
How did you fix the thumbnailer.php to see thumb missing?
thanks

7
this works well on my site running 1.7.4, Fedora 4, lighttpd
ffmpeg with 3gp support:)

Pages: [1]