rondog Posted March 14, 2008 Share Posted March 14, 2008 I finally got ffmpeg/ffmpeg-php installed and now I am just testing some scripts. I am able to getDuration getFilename etc. I want to try and get a thumbnail from the FLV now. I think I may be doing it wrong. <?php $extension = "ffmpeg"; $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX; $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname; // load extension if(!extension_loaded($extension)) { dl($extension_soname) or die("Can't load extension $extension_fullname\n"); } $mov = new ffmpeg_movie("golfers.flv",false); $image = $mov->getFrame(50); $frame = new ffmpeg_frame($image); $img = $frame->toGDImage(); echo $img; ?> its coming up blank..any ideas? Quote Link to comment Share on other sites More sharing options...
rondog Posted March 14, 2008 Author Share Posted March 14, 2008 ok i figured it out and it was outputting all kinds of weird characters �����JFIF���������;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 40 ���C� 2!=,.$2I@LKG@FEPZsbPUmVEFd�emw{���N`���}�s~�|���C;!!;|SFS||||||||||||||||||||||||||||||||||||||||||||||||||����V��"�������������� �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFG etc..... so I did header("Content-type: image/jpeg"); and that fixed it.. now I put it into my actual page that im working on which is in a while loop: while($row = mysql_fetch_array($sql)) { //$desc = substr($row[description], 0, 200); $mov = new ffmpeg_movie("videos/$row[filename]",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(); $displayMe = imagejpeg($newImg, $mkThumbFile,40); imagedestroy($newImg); $count += 1; if($count == $columnLimit) { echo "<td><div id=\"$row[id]-$row[name]\">$displayme</div></td>\n"; echo "</tr>\n<tr>\n"; $count = 0; } else { echo "<td><div id=\"$row[id]-$row[name]\">$displayme</div></td>\n"; } } its outputting all those weird characters again..has to be the header issue, but how do i apply headers to the image in that while loop? Quote Link to comment Share on other sites More sharing options...
devreflex2004 Posted March 22, 2008 Share Posted March 22, 2008 Hi Ron, This code is usefull for me, so thanks for pasting the solution here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.