You've single handedly managed to work out those errors. I'll believe you.
So, you're new code looks like this:
<?php
function fact($n) {
if ($n == 1 || $n == 0) {
return 1;
} else {
return ($n * factorial($n-1));
}
}
?>
Admittedly, this is error-free, but what does it do? It's functional?
Now try putting "echo fact(5);" below that code. Ups. You're not using that function, that's why no errors show up. You've been warned. Remember: this is not me being ****y and infatuated, this is you not knowing basic php.
I'll look into it and try to help you.
Later Edit
OK. Here's what to do:
Make a folder. Its name doesn't matter, but we'll name it "tinood" for guidance 😃
Copy those 3 downloaded files into "tinood" folder (pthreadGC2.dll and ffmpeg.exe are necessary)
Find a .mpg file and copy it to "tinood" (I've searched for a mpg in my comp and stumbled upon a 3 mb one: "demo.mpg". I used this in my example code. Change it to your own!)
Make a php file in "tinood" and populate it with the code below:
<?php
$ffmpeg = 'ffmpeg.exe';
// change "demo.mpg" to your mpg file name!
$video = dirname(__FILE__) . '\demo.mpg';
// change "demo.jpg" to whichever name you like or don't
// for this example, the name of the output jpg file does not matter
$image = dirname(__FILE__) . '\demo.jpg';
$second = 1;
$cmd = "$ffmpeg -i $video 2>&1";
if (preg_match('/Duration: ((\d+):(\d+):(\d+))/s', `$cmd`, $time)) {
$total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
$second = rand(1, ($total - 1));
}
$cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";
$return = `$cmd`;
echo 'done!';
?>
Run the php file server-wise. It should echo "done!"
Now check "tinood" folder. There should be a demo.jpg
Now you can play with that file. Tamper with ffmpeg parameters. It's pretty straightforward.
If you want a small picture (thumbnail, 320x240), try this (I haven't):
//change this:
$cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";
//...to this:
$cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -s 320x240 -vcodec mjpeg -f mjpeg $image 2>&1";
Hope this helps. Am I a bad person, tinood? :rolleyes:
BTW: If you bump into troubles using this code, do be specific about errors. I can't help you if you reply: "Nope. Doesn't work".