Generate Preview Jpeg/gif from Video

I use this Perl-Function to create a Thumbnail Gif and a Preview JPEG for my videos.If you want to switch the image with mouse over in HTML see this script.

I use the standard variable $$  (Prozess-ID)  to create a own folder for each process then convert, optimize and then delete.

sub makegif { 
my $in = shift; 
system("rm -rf ./Folder/gif_$$"); 
system("mkdir ./Folder/gif_$$"); 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 5% -o './Folder/$in.jpg'`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 5% -o  ./Folder/gif_$$/test0.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 10% -o ./Folder/gif_$$/test1.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 20% -o ./Folder/gif_$$/test2.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 30% -o ./Folder/gif_$$/test3.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 40% -o ./Folder/gif_$$/test4.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 50% -o ./Folder/gif_$$/test5.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 60% -o ./Folder/gif_$$/test6.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 70% -o ./Folder/gif_$$/test7.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 80% -o ./Folder/gif_$$/test8.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 90% -o ./Folder/gif_$$/test9.jpg`; 
`ffmpegthumbnailer -i './Folder/$in.mp4' -q 10 -s 512 -t 95% -o ./Folder/gif_$$/test10.jpg`; 
system("convert -layers Optimize -delay 40 -loop 0 './Folder/gif_$$/*.jpg' './Folder/".$in.".gif'"); 
system('mogrify -resize 166x125 "./Folder/'.$in.'.gif"'); 
system('mogrify -resize 166x125 "./Folder/'.$in.'.jpg"'); 

system("rm -rf ./Folder/gif_$$"); 
}

 

3 thoughts on “Generate Preview Jpeg/gif from Video”

  1. My family all the time say that I am killing my
    time here at net, however I know I am getting knowledge everyday
    by reading thes good articles or reviews.

  2. What’s up to all, because I am genuinely eager of reading
    this webpage’s post to be updated regularly.
    It contains nice data.

Leave a Reply

Your email address will not be published.

17 − nine =