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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.