Jump to content

Need help with ffmpeg-php


rondog

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/96195-need-help-with-ffmpeg-php/
Share on other sites

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.