rondog Posted March 14, 2008 Share Posted March 14, 2008 I am using ffmpeg-php to create thumbnails from flv files. The issue I am having is a header problem. The code to make the jpeg is in a while loop that is drawing from a database. The problem is, their is no header attached to this jpeg so the output is a bunch 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:CDEFGHIJSTUVWXYZcdefghijstuvwxyz����������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br etc etc... How do I apply headers to this code block so it doesn't do that?? <?php 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 = header("Content-type: image/jpeg"); $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"; } } ?> you can see I am trying to do the headers with these two lines but its not working: $displayMe = header("Content-type: image/jpeg"); $displayMe .= imagejpeg($newImg, $mkThumbFile,40); any ideas? Quote Link to comment Share on other sites More sharing options...
craygo Posted March 14, 2008 Share Posted March 14, 2008 Your header shouldn't be in any kind of a html tag it is strickly php. To be honest I think you should have the script that creates the thumbnails in it's own page, Then call the script in the loop. echo "<td><div id=\"$row[id]-$row[name]\"><img src=createthumb.php></div></td>\n"; GD is not going to work creating multiple images on the same page, by putting the script on another page it creates the image and it's done, then gets called on again. You can always put the link to the movie in the src echo "<td><div id=\"$row[id]-$row[name]\"><img src=createthumb.php?source=videos/".$row['filename']."></div></td>\n"; Then in your script you can grab the variable $moviefile = $_GET['source']; $mov = new ffmpeg_movie("$moviefile",false); What I am saying is don't create the image in your loop, call for the image from another page in the loop. Ray Quote Link to comment Share on other sites More sharing options...
rondog Posted March 14, 2008 Author Share Posted March 14, 2008 ah you're a genius my friend..that worked like a charm! 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.