PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Create Thumbnails From Videos PHP Code

Go down

Create Thumbnails From Videos PHP Code Empty Create Thumbnails From Videos PHP Code

Post by jamied_uk 20th March 2021, 23:19

Vid coming Soon!


Code:
<?php
// (c)J~Net 2021
// jnet.sytes.net
// https://jnet.forumotion.com/t1726-creat-thumbnails-from-videos-php-code#2674
$pathToDir="/var/www/html/xxx/vids";
$folder="path/1";
$extensions=array('mp4','webm','avi');
$result=array();
$directory=new DirectoryIterator("$folder");
//
foreach ($directory as $fileinfo) {
    // must be a file
    if ($fileinfo->isFile()) {
        // file extension
$extension=strtolower(pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION));
        // check if extension match
        if(in_array($extension, $extensions)) {
            // add to result
            //$result[]=$fileinfo->getFilename();
            $vidfile=$fileinfo->getFilename();;
            // my custom links
            $Full="$pathToDir/$folder/$vidfile";
            $lname=substr($Full, 0, -4);
            echo "<p>$Full</p>";
            if(!file_exists($lname-thumbnail.png)) {
            $command="/usr/local/bin/ffmpeg -i ".$Full." -vf fps=1/60 ".$lname."-thumbnail.png"; // %03d
//   system($command);
            shell_exec($command);
            //echo "<p>Thumbnail Created!<br></p>";
//  $links .= '<a href="play.php?r='.$fileinfo->getFilename().'">'.$lname.'</a> <p>';
            echo "<p>Missing Thumbnail Created!<br></p>";
            }
        }
    }
}
?>

This will generate png for web servers (apache for example)
 using video files in given folder / directory
jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum