Page 1 of 3
Question Video to image
Posted: 2010-01-26T12:07:35-07:00
by winracer
I am working on a script that lets you upload all kinds of video and images. I am wornding if ImageMagick can be used to take a snapshoot of the video and then display it as a image. showing the image on main page.
the script I am using is wrote in php. also my hosting company has imagemagick installed.
thanks for any information . if a script has been written you someone tell me where to get it and if not any information link would be great!
Re: Question Video to image
Posted: 2010-01-27T12:51:55-07:00
by blatant
ffmpeg does the job
especially if you have multiple video formats i would doubt magicks ability to extract (key) frames
ffmpeg has lots of filters for almost every possible codec
Re: Question Video to image
Posted: 2010-01-27T14:53:31-07:00
by Bonzo
I think it can and would search the user section as this would have come up before.
Re: Question Video to image
Posted: 2010-01-28T07:01:15-07:00
by winracer
blatant wrote:ffmpeg does the job
especially if you have multiple video formats i would doubt magicks ability to extract (key) frames
ffmpeg has lots of filters for almost every possible codec
thanks my hosting company does not support ffmpeg that is why I am looking to program something different
Re: Question Video to image
Posted: 2010-01-28T07:15:39-07:00
by winracer
Bonzo wrote:I think it can and would search the user section as this would have come up before.
I searched and did not see a answer. I guess I could have mist it. thanks
Re: Question Video to image
Posted: 2010-01-28T10:49:17-07:00
by fmw42
I believe that IM uses ffmpeg to do its work on video. That delegate library is needed with IM.
Re: Question Video to image
Posted: 2010-01-28T10:58:57-07:00
by winracer
I found this
http://www.imagemagick.org/Usage/video/
and using below code and it will not create a .gif file any thoughts?
<?php
$name = 'cat.avi';
$new_name = 'cat.gif';
$max_width = "90";
$max_height = "90";
exec("convert -quiet -delay 1 $name $max_widthx$max_height $new_name");
print("<b>New image size:</b>".$new_name.$name."<br>");
echo "<img src=\"".$name."\">";
echo "<img src=\"".$new_name."\">";
?>
Re: Question Video to image
Posted: 2010-01-28T11:14:52-07:00
by fmw42
you probably need the full path to convert, usually at /usr/local/bin or /usr/bin
try this
<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>
or
in command line try
find /usr | grep "convert"
or
sudo find / | grep "convert"
Re: Question Video to image
Posted: 2010-01-28T11:38:06-07:00
by winracer
fmw42 wrote:you probably need the full path to convert, usually at /usr/local/bin or /usr/bin
try this
<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>
or
in command line try
find /usr | grep "convert"
or
sudo find / | grep "convert"
my paths are
ImageMagick /usr/bin/
ImageMagick (C) /usr/local/bin/convert
I tried this and still will not work
<?php
$name = 'cat.avi';
$new_name = 'cat.gif';
$max_width = "90";
$max_height = "90";
exec(" /usr/local/bin/convert -quiet -delay 1 $name $max_widthx$max_height $new_name");
print("<b>Names:</b>".$new_name.$name."<br>");
echo "<img src=\"".$name."\">";
echo "<img src=\"".$new_name."\">";
?>
Re: Question Video to image
Posted: 2010-01-28T18:52:07-07:00
by fmw42
see if it runs from the command line or what errors it tells you and report back.
On the surface this makes no sense for correct syntax:
convert -quiet -delay 1 $name $max_widthx$max_height $new_name
to what does the WidthxHeight refer?
Is that a subsection of the image or a crop or a resize? If the latter two, then you need some operator such as -crop or -resize, if the former, then the size must be specified as image.png[WidthxHeight+xoffset+yoffset] the brackets are important as are the offsets
Re: Question Video to image
Posted: 2010-01-29T06:10:35-07:00
by winracer
fmw42 wrote:see if it runs from the command line or what errors it tells you and report back.
On the surface this makes no sense for correct syntax:
convert -quiet -delay 1 $name $max_widthx$max_height $new_name
to what does the WidthxHeight refer?
Is that a subsection of the image or a crop or a resize? If the latter two, then you need some operator such as -crop or -resize, if the former, then the size must be specified as image.png[WidthxHeight+xoffset+yoffset] the brackets are important as are the offsets
thanks
I changed to
http://www.imagemagick.org/Usage/video/
<?php
$name = 'cat.avi';
$new_name = 'cat.gif';
exec(" /usr/local/bin/convert -quiet -delay 1 $name $new_name");
print("<b>Names:</b>".$new_name.$name."<br>");
echo "<img src=\"".$name."\">";
echo "<img src=\"".$new_name."\">";
?>
but still do not get a cat.gif I can not run from command line. is there away to output error message to screen?
Re: Question Video to image
Posted: 2010-01-29T10:39:58-07:00
by fmw42
try adding the returnval and print_r as in
<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>
Re: Question Video to image
Posted: 2010-01-29T11:24:07-07:00
by winracer
fmw42 wrote:try adding the returnval and print_r as in
<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>
when I add
<?php
exec("convert -version",$out,$returnval);
print_r($out[0]);
?>[/quote]
I get
Version: ImageMagick 6.3.9 12/10/08 Q16
http://www.imagemagick.org
Re: Question Video to image
Posted: 2010-01-29T13:37:57-07:00
by Bonzo
Try:
Code: Select all
<?php
$name = 'cat.avi';
$new_name = 'cat.gif';
$array=array();
echo "<pre>";
exec(" /usr/local/bin/convert $name -quiet -delay 1 $new_name 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
print("<b>Names:</b>".$new_name.$name."<br>");
echo "<img src=\"".$name."\">";
echo "<img src=\"".$new_name."\">";
?>
When I run this I get:
Array
(
[0] => convert: no tag found `avi:decode' @ delegate.c/InvokeDelegate/863.
[1] => convert: missing an image filename `cat.gif' @ convert.c/ConvertImageCommand/2822.
)
1
Re: Question Video to image
Posted: 2010-01-29T13:47:43-07:00
by winracer
[quote="Bonzo"]Try:
Code: Select all
<?php
$name = 'cat.avi';
$new_name = 'cat.gif';
$array=array();
echo "<pre>";
exec(" /usr/local/bin/convert $name -quiet -delay 1 $new_name 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
print("<b>Names:</b>".$new_name.$name."<br>");
echo "<img src=\"".$name."\">";
echo "<img src=\"".$new_name."\">";
?>
When I run this I get:
thanks I get this error any thoughts?
Array
(
[0] => convert: Not enough pixel data `cat.avi'.
[1] => convert: missing an image filename `cat.gif'.
)
1