rondog Posted April 15, 2008 Share Posted April 15, 2008 Hi, I am creating JPEG thumbnails of FLVs using ffmpeg. The thing is, it runs ffmpeg every time you hit the page to generate them. I dont know what kind of overhead that makes, but I know it would be less intensive on the server if I saved the generated thumbnail the first time and then just checked if file_exists. Here is my createthumb.php file: <?php header("Content-type: image/jpeg"); $moviefile = $_GET['source']; $mov = new ffmpeg_movie($moviefile,false); $img = $mov->getFrame(50); $showImg = $img->toGDImage(); $mkNewImg = new ffmpeg_frame($showImg); $maxWid = 150; $oldWid = $mkNewImg->getWidth(); $oldHgt = $mkNewImg->getHeight(); $movRatio = $oldWid/$oldHgt; if($oldWid > $maxWid) { $newWid = $maxWid; } $newHgt = $newWid / $movRatio; $mkNewImg->resize($newWid,$newHgt); $newImg = $mkNewImg->toGDImage(); imagejpeg($newImg, $mkThumbFile,40); imagedestroy($newImg); ?> How could I modify this to save the thumbnail it makes in a directory. I think I can figure out the checking if it already exists. Just need help saving it. Thank you. Link to comment https://forums.phpfreaks.com/topic/101289-saving-generated-thumbnails/ Share on other sites More sharing options...
rondog Posted April 15, 2008 Author Share Posted April 15, 2008 I've been doing some more research and apparently, imagejpeg($newImg,$mkThumbFile,40); the second param is the directory where you save the image. Well, the image isnt getting saved anywhere. I have a folder in my root called videos/thumbnails and I want the thumbnails to go in there. I tried: imagejpeg($newImg,'videos/thumbnails/$mkThumbFile',40); and it made a file called $mkThumbFile When I right click and save the image I get hte file name: createthumb.php.jpg is that really the name its making? I need to know how to save the jpeg to a directory the same name as $moviefile = $_GET['source']; but ill just strip the FLV extension and put JPG..please anyone?? Link to comment https://forums.phpfreaks.com/topic/101289-saving-generated-thumbnails/#findComment-518086 Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 anyone have an idea how to save the jpg ?? Link to comment https://forums.phpfreaks.com/topic/101289-saving-generated-thumbnails/#findComment-518593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.