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

enter image description here

but depending on video have thumbs this

enter image description here

whats best way remove black space thumbs, need keep thumb size 240x180

you need to:

  1. resize image ffmpeg keeping aspect ratio, doesn't add borders. -vf scale=".$thumbwidth.":trunc(ow/a/2)*2 below.

  2. 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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -