Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: 1 2 [3]   Go Down

Author Topic: Automatic video thumbnail creation (Requires ffmpeg)  (Read 146985 times)

0 Members and 1 Guest are viewing this topic.

worenklein

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #40 on: May 20, 2008, 06:33:52 am »

I think I got it!

Code: [Select]
Index: util.php
===================================================================
--- util.php    (revision 4455)
+++ util.php    (working copy)
@@ -246,6 +246,22 @@
                 $thumb = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['thumb_pfx'] . $row['filename'];

                 if ($updatetype == 0 || $updatetype == 2){
+      if (is_movie($image)) {
+       preg_match("/(.+)\.(.*?)\Z/", $row['filename'], $matches);
+       $thumb = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['thumb_pfx'] . $matches[1].".jpg";
+       $videoThumb = create_movie_thumb($image);
+       if ($videoThumb) {
+         if (resize_image($videoThumb, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])) {
+           echo "$thumb {$lang_util_php['updated_succesfully']} !<br />";
+           my_flush();
+         } else {
+           echo "{$lang_util_php['error_create']} : $thumb<br />";
+           my_flush();
+         }
+       }
+       @unlink($videoThumb);
+       $imagesize = getimagesize($thumb);
+      } else {
                         if (resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])){
                                 echo "$thumb {$lang_util_php['updated_succesfully']} !<br />";
                                 my_flush();
@@ -254,6 +270,7 @@
                                 my_flush();
                         }
                 }
+    }

                 if ($updatetype == 1 || $updatetype == 2){
Logged
David C Worenklein

SolidSnake2003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 82
  • Solid Snake/Joshua Harris Fan
    • Legacy Designs
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #41 on: June 05, 2008, 02:09:21 am »

I tried this out, but when I tried to add videos using the batch add, it wouldnt add the videos, and gave me an error of not being able to load ffmpeg (125)
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #42 on: June 05, 2008, 06:41:32 am »

That means either ffmpeg is not properly installed or you gave the incorrect path to its executable.
Logged
Chief Geek at Ranium Systems

dildo

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #43 on: April 29, 2009, 09:02:19 pm »

When I try to implement this mod, video uploads seize to work.

When I upload the file it says:

Successful Uploads
1 uploads were successful.

Please click 'Continue' to add the files to albums.

But after continuing and selecting an album and pressing continue again it says

"The previous file could not be placed.

You have successfully placed all the files."

Quote
@lifter : PM me the admin un/pass, url of your gallery along with a link to this topic. If that doesn't help then i might ask for ftp access too (if you are happy to provide that).

hi,

How did you solve his problem ?  I got the same...
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #44 on: April 30, 2009, 04:41:41 am »

@dildo: Can't remember. I don't even remember if he ever sent me the login info :)
Logged
Chief Geek at Ranium Systems

dildo

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #45 on: April 30, 2009, 10:46:44 pm »

ok it's all right I am going to manage in another way thank you sir
Logged

Ghost rider

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #46 on: August 27, 2009, 03:47:23 pm »

Hi Ali,
I'm writting you, if you can help  me to solve the trouble about how to create automatic video thumbnail. I tried to intregated the script that you posted in past about this matter is no working. I did managed to install ffmpeg. The script below is uploading the video files in directory but it's no creating thumbnail in directory folder(thumb).Thank in advance

Code: [Select]
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="500000" /> 
          <table width="400" cellpadding="3" >
            <tr>
              <td colspan="3"> </td>
            </tr>
            <tr>
              <td width="10" rowspan="2"> </td>
              <td width="120"><strong>Choose a file to upload:</strong></td>
              <td width="242"><input type="file" name="uploaded_file" /></td>
            </tr>
            <tr>
              <td> </td>
              <td> </td>
            </tr>
            <tr>
              <td> </td>
              <td> </td>
              <td><input type="submit" name="sendForm" value="Upload File" />
                <br /></td>
            </tr>
            <tr>
              <td colspan="3"> </td>
            </tr>
          </table>
</form>
<?php 
  
  
// C:\wamp\www\scriptDir\uploads\ ;
 
  
$idir "C:/wamp/www/Testvideo/videos/";   // Path To Images Directory 
  
$tdir "C:/wamp/www/Testvideo/ThumbVideos/";   // Path To Thumbnails Directory 
  
$twidth "200";   // Maximum Width For Thumbnail Images 
  
$theight "150";   // Maximum Height For Thumbnail Images 

  
error_reporting(E_ALL E_NOTICE); // Show all major errors. 

  // Check to see if the button has been pressed 
  
if (!empty($_REQUEST['sendForm'])) 
  { 
    
// Assign the name to a variable 
    
$name $_FILES['uploaded_file']['name']; 
    
// Assign the tmp_name to a variable 
    
$tmp_name $_FILES['uploaded_file']['tmp_name']; 
    
// Assign the error to a variable 
    
$error $_FILES['uploaded_file']['error']; 
    
// Assign the size to a variable 
    
$size $_FILES['uploaded_file']['size'];
    
// No trailing slash 
    
$uploadFilesTo 'videos'
    
// Create safe filename 
    
$name ereg_replace('[^A-Za-z0-9.]''-'$name); 
    
// Disallowed file extensions 
    //what files you don't want upoad... leave this alone and you should be fine but you could add more 
    
$naughtyFileExtension = array("php""php3""asp""inc""txt""wma","js""exe""jsp""map""obj"" """"html""mp3""mpu""wav""cur""ani");    // Returns an array that includes the extension 
   
    //Allowable file Mime Types. Add more mime types if you want 
    
$FILE_MIMES = array('video/mpg','video/avi','video/mpeg','video/wmv'); 
    
//Allowable file ext. names. you may add more extension names. 
    
$FILE_EXTS = array('.avi','.mpg','.mpeg','.asf','.wmv','.3gpp');
    
$file_ext strtolower(substr($name,strrpos($name,".")));  
    
// to check the extensio
    
if (!in_array($file_type$FILE_MIMES) && !in_array($file_ext,$FILE_EXTS) ) 
    
$message "Sorry, $file_name($file_type) is not allowed to be uploaded.";  
 
    
$fileInfo pathinfo($name); 
    
// Check extension 
    
if (!in_array($fileInfo['extension'], $naughtyFileExtension)) 
    { 
      
// Get filename 
      
$name getNonExistingFilename($uploadFilesTo$name); 
      
// Upload the file 
      
if (move_uploaded_file($tmp_name$uploadFilesTo.'/'.$name))  
      { 
          
// Show success message 
          
echo '<center><p>Your Video File has uploaded successfully<br />'.$uploadFilesTo.'/'.$name.'</p></center>'
      } 
      else 
      { 
          
// Show failure message 
          
echo '<center><p>File failed to upload to /'.$name.'</p></center>'
      } 
    } 
    else 
    { 
        
// Bad File type 
        
echo '<center><p>The file uses an extension we don\'t allow.</p></center>'
    } 
  } 
  
  
// Functions do not need to be inline with the rest of the code 
  
function getNonExistingFilename($uploadFilesTo$name
  { 
      if (!
file_exists($uploadFilesTo '/' $name)) 
          return 
$name
      
      return 
getNonExistingFilename($uploadFilesTorand(100200) . '_' $name); 
  } 
  
  
  
/**
 * Function to create video thumbnail using ffmpeg
   http://forum.coppermine-gallery.net/index.php?topic=38774.0
 */
function create_movie_thumb($src_file)
{
    global 
$CONFIG$ERROR;

    
$CONFIG['ffmpeg_path'] = 'C:/wamp/bin/'// Change the path according to your server.

    
$src_file $src_file;
    
$dest_file $CONFIG['fullpath']."edit/".md5(uniqid(time()))."%d.jpg";

    if (
preg_match("#[A-Z]:|\\\\#Ai"__FILE__)) {
        
// get the basedir, remove '/include'
        
$cur_dir substr(dirname(__FILE__), 0, -8);
        
$src_file '"' $cur_dir '\\' strtr($src_file'/''\\') . '"';
        
$ff_dest_file '"' $cur_dir '\\' strtr($dest_file'/''\\') . '"';
    } else {
        
$src_file escapeshellarg($src_file);
        
$ff_dest_file escapeshellarg($dest_file);
    }

    
$output = array();

    if (
eregi("win",$_ENV['OS'])) {
        
// Command to create video thumb
        
$cmd "\"".str_replace("\\","/"$CONFIG['ffmpeg_path'])."ffmpeg\" -i ".str_replace("\\","/" ,$src_file )." -an -ss 00:00:05 -r 1 -vframes 1 -y ".str_replace("\\","/" ,$ff_dest_file);
        
exec ("\"$cmd\""$output$retval);
    } else {
        
// Command to create video thumb
        
$cmd "{$CONFIG['ffmpeg_path']}ffmpeg -i $src_file -an -ss 00:00:05 -r 1 -vframes 1 -y $ff_dest_file";
        
exec ($cmd$output$retval);
    }


    if (
$retval) {
        
$ERROR "Error executing FFmpeg - Return value: $retval";
        if (
$CONFIG['debug_mode']) {
            
// Re-execute the command with the backtick operator in order to get all outputs
            // will not work if safe mode is enabled
            
$output = `$cmd 2>&1`;
            
$ERROR .= "<br /><br /><div align=\"left\">Cmd line : <br /><span style=\"font-size:120%\">" nl2br(htmlspecialchars($cmd)) . "</span></div>";
            
$ERROR .= "<br /><br /><div align=\"left\">The ffmpeg program said:<br /><span style=\"font-size:120%\">";
            
$ERROR .= nl2br(htmlspecialchars($output));
            
$ERROR .= "</span></div>";
        }
        @
unlink($dest_file);
        return 
false;
    }

    
$return str_replace("%d""1"$dest_file);
    @
chmod($returnoctdec($CONFIG['default_file_mode'])); //silence the output in case chmod is disabled
    
return $return;
}


?>
 
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #47 on: August 28, 2009, 07:02:31 am »

Are you using the thumbnail creation functions outsite of coppermine?
Logged
Chief Geek at Ranium Systems

Ghost rider

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #48 on: August 28, 2009, 12:14:26 pm »

hi Ali,
thank for your reply. No I'm not using a function outside the coppermine and may be I didn't use all the functions illustrating in coppermine site. Please if you can check my script and give some direction. Thanks for your time.
Logged

Ghost rider

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #49 on: August 28, 2009, 01:43:50 pm »

Abba Ali,
Ignorant my last message. I think I get confusion using your  function because I tried to mix up with some of my script. I want to get this right.OK

1-I don't think I got complete the script or function.
2-I tried to run the function below.

Code: [Select]
<?php
/**
 * Function to create video thumbnail using ffmpeg
  from http://forum.coppermine-gallery.net/index.php?topic=38774.0
 */
function create_movie_thumb($src_file)
{
    global 
$CONFIG$ERROR;

    
$CONFIG['ffmpeg_path'] = '/usr/local/bin/'// Change the path according to your server.

    
$src_file $src_file;
    
$dest_file $CONFIG['fullpath']."edit/".md5(uniqid(time()))."%d.jpg";

    if (
preg_match("#[A-Z]:|\\\\#Ai"__FILE__)) {
        
// get the basedir, remove '/include'
        
$cur_dir substr(dirname(__FILE__), 0, -8);
        
$src_file '"' $cur_dir '\\' strtr($src_file'/''\\') . '"';
        
$ff_dest_file '"' $cur_dir '\\' strtr($dest_file'/''\\') . '"';
    } else {
        
$src_file escapeshellarg($src_file);
        
$ff_dest_file escapeshellarg($dest_file);
    }

    
$output = array();

    if (
eregi("win",$_ENV['OS'])) {
        
// Command to create video thumb
        
$cmd "\"".str_replace("\\","/"$CONFIG['ffmpeg_path'])."ffmpeg\" -i ".str_replace("\\","/" ,$src_file )." -an -ss 00:00:05 -r 1 -vframes 1 -y ".str_replace("\\","/" ,$ff_dest_file);
        
exec ("\"$cmd\""$output$retval);
    } else {
        
// Command to create video thumb
        
$cmd "{$CONFIG['ffmpeg_path']}ffmpeg -i $src_file -an -ss 00:00:05 -r 1 -vframes 1 -y $ff_dest_file";
        
exec ($cmd$output$retval);
    }


    if (
$retval) {
        
$ERROR "Error executing FFmpeg - Return value: $retval";
        if (
$CONFIG['debug_mode']) {
            
// Re-execute the command with the backtick operator in order to get all outputs
            // will not work if safe mode is enabled
            
$output = `$cmd 2>&1`;
            
$ERROR .= "<br /><br /><div align=\"left\">Cmd line : <br /><span style=\"font-size:120%\">" nl2br(htmlspecialchars($cmd)) . "</span></div>";
            
$ERROR .= "<br /><br /><div align=\"left\">The ffmpeg program said:<br /><span style=\"font-size:120%\">";
            
$ERROR .= nl2br(htmlspecialchars($output));
            
$ERROR .= "</span></div>";
        }
        @
unlink($dest_file);
        return 
false;
    }

    
$return str_replace("%d""1"$dest_file);
    @
chmod($returnoctdec($CONFIG['default_file_mode'])); //silence the output in case chmod is disabled
    
return $return;
}

// Add a picture to an album
function add_picture($aid$filepath$filename$position 0$title ''$caption ''$keywords ''$user1 ''$user2 ''$user3 ''$user4 ''$category 0$raw_ip ''$hdr_ip ''$iwidth 0$iheight 0)

 } elseif (
is_movie($image)) {
      
preg_match("/(.+)\.(.*?)\Z/"$filename$matches);
      
$thumb $CONFIG['fullpath'] . $filepath $CONFIG['thumb_pfx'] . $matches[1].".jpg";
      
$videoThumb create_movie_thumb($image);
      if (
$videoThumb) {
        if (!
resize_image($videoThumb$thumb$CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])) {
          return 
false;
        }
        @
unlink($videoThumb);
        
$imagesize getimagesize($thumb);
      } else {
        return 
false;
      }

 } else {
        
$imagesize[0] = $iwidth;
        
$imagesize[1] = $iheight;
    }
?>
 


I'm getting this error:
Code: [Select]
Parse error: syntax error, unexpected '}', expecting '{' in C:\wamp\www\Testvideo\videoFunction.php on line 61
4-Please if you can you send me complete script and function or illustrate how can I create video thumbnail! I'm using WAMP server. Thank you so much.
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #50 on: August 28, 2009, 02:29:44 pm »

The code you posted above is not correct and few lines (from original code) are missing from it and hence it is giving parse error. I am sorry but providing support for creating a custom script, not belonging to coppermine, is out of the scope of this board.
Logged
Chief Geek at Ranium Systems

Ghost rider

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #51 on: August 28, 2009, 05:44:15 pm »

Thank for your reply. If you could at least give some directions to help me solve the problem. Thank in advance
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #52 on: August 30, 2009, 01:34:17 pm »

We can not do that, it's beyond the scope of support on this forum. Please do not clutter announcement threads with your individual issues.
Logged

Ghost rider

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #53 on: September 02, 2009, 04:58:58 pm »

Ok thanks. I'm a new user in forum. Could you please help me to find where the tab to process new topics on this forum? I can't find it! Thanks in advance
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Automatic video thumbnail creation (Requires ffmpeg)
« Reply #54 on: September 14, 2009, 02:37:16 pm »

I told you to stop cluttering this announcement thread, yet you still clutter it! You're now banned from posting for three days because you haven't dpone as suggested and because you're lazy. You can of course not start a new thread here on this very sub-board, as this sub-board contains actual mod announcements and not support requests. You'd have to go to a sub-board where you actually can start new threads related to support: visit the corresponding sub-board of the support branch. You can only do so after your three day ban has expired.
Logged
Pages: 1 2 [3]   Go Up
 

Page created in 0.025 seconds with 20 queries.