php - Imagemagick create thumbs -
i have tube site , im using function generate thumbs video file
$thumbwidth = 240; //thumb width $thumbheight = 180; //thumb height $imagick_command = "-modulate 110,102,100 -sharpen 1x1 -enhance"; shell_exec("$ffmpeg_path -ss $first -i \"".$row[file]."\" -vcodec mjpeg -vframes 1 -an -f rawvideo -s ".$thumbwidth."x".$thumbheight." \"$image\""); shell_exec("/usr/local/bin/mogrify $imagick_command $image");
here thumbs result, image need, no border , etc..
but depending on video have thumbs this
whats best way remove black space thumbs, need keep thumb size 240x180
you need to:
resize image ffmpeg keeping aspect ratio, doesn't add borders.
-vf scale=".$thumbwidth.":trunc(ow/a/2)*2
below.resize image exact size want.
-resize ".$thumbwidth."x".$thumbheight."\!
below.
so new set of commands should like:
$thumbwidth = 240; //thumb width $thumbheight = 180; //thumb height $imagick_command = "-modulate 110,102,100 -sharpen 1x1 -enhance -resize ".$thumbwidth."x".$thumbheight."\!"; shell_exec("$ffmpeg_path -ss $first -i \"".$row[file]."\" -vcodec mjpeg -vframes 1 -an -f rawvideo -vf scale=".$thumbwidth.":trunc(ow/a/2)*2 \"$image\""); shell_exec("/usr/local/bin/mogrify $imagick_command $image");
tested on ffmpeg build last sept parameters set actual values make easier read:
ffmpeg -ss 1 -i gopr9876.mp4 -vcodec mjpeg -vframes 1 -an -f rawvideo -vf scale=240:trunc\(ow/a/2\)*2 "foo.jpg"
Comments
Post a Comment