From 4d82b80a2e06a9b31f9334d4addd3f8e5cd1e66b Mon Sep 17 00:00:00 2001 From: josch Date: Sat, 20 Oct 2007 10:23:54 +0000 Subject: [PATCH] proper thumbnail scaling git-svn-id: http://yolanda.mister-muffin.de/svn@103 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/gnutube_daemon.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/trunk/gnutube_daemon.pl b/trunk/gnutube_daemon.pl index 5540e72..d26e4fc 100755 --- a/trunk/gnutube_daemon.pl +++ b/trunk/gnutube_daemon.pl @@ -138,7 +138,16 @@ while(1) #create thumbnail $thumbnailsec = int($duration/3 + .5); - system "ffmpeg -i $gnutube_root/tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s 320x240 $gnutube_root/video-stills/$id"; + + #the width/height calculation could of course be much shorter but less readable then + $tnwidth = 160; + $tnheight = int(160*($height/$width) + .5); + if($tnheight > 120) + { + $tnheight = 120; + $tnwidth = int(120*($width/$height) + .5); + } + system "ffmpeg -i $gnutube_root/tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s ".$tnwidth."x$tnheight $gnutube_root/video-stills/$id"; #check if the upload already is in the right format if ($container eq 'ogg' and $video eq 'theora' and $audio eq 'vorbis')