Trying to implement Auto Thumb Creation with VirusScan before per my other site Trying to implement Auto Thumb Creation with VirusScan before per my other site
 

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

Main Menu

Trying to implement Auto Thumb Creation with VirusScan before per my other site

Started by cadude7, December 15, 2020, 04:40:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cadude7

Why can't coppermine create thumbnails for my videos?

All this custom thumbnail business might appear very complicated to newbies, and in fact you're right: this is a complicated process. Therefore, many users ask why this has to be so complicated. Coppermine can create thumbnails for images, so why can't it create thumbnails for videos? The reason is pretty simple: because the image libraries that Coppermine is relying on (GD or ImageMagick, see "Minimum requirements") to create thumbnails from images don't support videos. It's not that the Coppermine developers have been reluctant to come up with code that auto-creates thumbnails for videos - it's just that they can't because the technology that is available on your webserver can't.


I understand the above statement from the help files however, i know HOW script wise to do this.  The technology IS there you just need to unleash it.  FFMPEG is usually available now on MOST servers.  And it doesn't take any resources to do this either as its executed OUTSIDE the application. Your already making Exec calls in your code so you can make these calls also. I just need someone to point me in the appropriate area whether its in a theme or if there is a way to add an include with my code to cause after a video has been uploaded to scan it and make a video thumbnail.  In my previous site, I had modified its FTP to HTML5 forms so I didn't have to share/create ftp accounts.  I had then coded AUTO clamAV scan and then to use FFMPEG to make me a thumbfile.  Scanning of viruses went through a very rouge file checker sniffing for scripts, executable s in the file even before it went through the scanner.  Worked nicely to catch anything.

The old album needed to make a file with .videoExt.png to display videos properly and didnt exist.  Like  yours, just seems to require thumbs_ and jpg which could be done.  Below is the code sequence from my old system which was called at the end of the upload sequence using the forms $_File value.  Before any of this, AntivirusScan() had to return true.  This code is not posted in its entirety as its still used by some family members on the old site as i get this one up and running.

My old upload sequence which i'm trying to identify to manipulate in your code:

if ($uploadOk == 0 || $sniffOK== 0) {
  echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
  if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
    //  Create a thum for this file so the program sees it if not a virus.
    
    $probe=AntivirusScan();
     if ($probe=='File: OK'){
       MakeThumb($target_file);
       echo "<br/>The file ".$target_name. " has been uploaded to the selected folder.<br/>";} else {echo "<br/> Your file ".$target_name." has been quarantined and has been deleted by ClamAV from our server!!";}

My Antivirus Function, Returns true if all good.

function AntivirusScan() {
   //Final checks - Antivirus Scan trigger.  Purge bad downloads
   Global $target_file;
   $virusscaner='"C:\Program Files\ClamAV\clamdscan.exe"';
   if(strlen($target_file)< 13) {Exit("ClamAV:Scanner Failure. invalid Filename.");}
   $scan_file=realpath($_SERVER["DOCUMENT_ROOT"]."/Elter/PhotoAlbum/".$target_file);
   if (substr_count ($scan_file,".")>2){exit ("EasyCheck Error: Corrupt Target File Definition. Escape!");}
   $scan_file=' "'.$scan_file.'"';
   //print $virusscaner.$scan_file;
   
   exec($virusscaner.$scan_file,$scanerint,$scannervar);
   $fileOK=$scanerint[0]; // this int changes with versions...whatch it!
   echo "<br/>Requesting Virus Scan.  Please Wait";
   echo "<br/>Antivirus: ClamAV 0.102.3/26008<br/><br/>";
   //flush();
   //ob_flush();
   
   //print $scanerint; seems to change ???
   // 0=Status Messages
   // 1=File OK FAIL with fullpath
   // 2=empty
   // 3-11 are summary

   //Remove top 2
   array_shift($scanerint);
   array_shift($scanerint);

   $abc=implode("<br/>",$scanerint);
   print($abc);
   if (strpos($fileOK,"OK")){$ScanSuccess="File: OK";} else {
      $ScanSuccess="Virus Found!";
      CleanTMP();
      }
   echo '<br/>----------- SCAN COMPLETE -----------<br/>';
   Return $ScanSuccess;

The function that makes a thumbfile:

function MakeThumb($file){

// Thumb file at 5 sec mark
$video = '"'.$file.'"';
$thumbnail = '"'.$file.'.png'.'"';
$ffmpeg='ffmpeg.exe';
$command=' -i '.$video.' -deinterlace -an -ss 5 -t 00:00:05 -r 1 -y -vcodec mjpeg -f mjpeg '.$thumbnail.' 2>&1';
//print $ffmpeg.$command;

$abc=exec($ffmpeg.$command,$output);
print '<br/>';
echo '<br/>------ Thumb Creation for Video ------<br/>';
print '<br/>'.$abc.'<br/>';
}

I realize i prob wont be able to output anything which is fine, i would just need to know how to also interrupt the process if my scanner call sees something nasty. 


cadude7

Edit:  Sorry the Scanner doesn't return a bol but could.  It returns text for output reasons in the old site.

ron4mac

I think thumbnails for videos are better when you can choose a specific frame in the video.
Take a look at this method.

cadude7

Quote from: ron4mac on December 15, 2020, 07:30:22 PM
I think thumbnails for videos are better when you can choose a specific frame in the video.
Take a look at this method.

You need a like button for replies.  Ill check this out.  Sweet!  Some reason didn't see it when i was searching.  Thanks ron4mac