From 3bc4efe2749490ae603210fac0a58aa3741c85fb Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 7 Apr 2008 14:19:06 +0000 Subject: [PATCH] added random thumbnail and preview generation git-svn-id: http://yolanda.mister-muffin.de/svn@276 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/functions.pl | 3 ++- trunk/tools/daemon.pl | 6 ++++-- trunk/upload.pl | 2 +- trunk/video.pl | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/trunk/functions.pl b/trunk/functions.pl index 29c99bb..eaaae72 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -93,7 +93,8 @@ sub fill_results #before code cleanup, this was a really obfuscated array/hash creation push @{ $page->{'results'}->{'result'} }, { - 'thumbnail' => $duration == 0 ? "/images/tango/video-x-generic.png" : "/video-stills/$id", + 'thumbnail' => "$domain/video-stills/thumbnails/$id", + 'preview' => "$domain/video-stills/previews/$id", 'duration' => $duration, 'viewcount' => $viewcount, 'rdf:RDF' => diff --git a/trunk/tools/daemon.pl b/trunk/tools/daemon.pl index 406402b..1e32453 100755 --- a/trunk/tools/daemon.pl +++ b/trunk/tools/daemon.pl @@ -143,7 +143,8 @@ while(1) $duration = int($1*3600 + $2*60 + $3 + $4/10 + .5); #create thumbnail - $thumbnailsec = int($duration/3 + .5); + $thumbnailsec = int(rand($duration)); + $previewsec = $thumbnailsec; #the width/height calculation could of course be much shorter but less readable then #all thumbs have equal height @@ -151,7 +152,8 @@ while(1) $tnheight = $tnmaxheight; $tnwidth = int($tnheight*($width/$height)/2 + .5)*2; - system "ffmpeg -i /tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s ".$tnwidth."x$tnheight $root/video-stills/$id"; + system "ffmpeg -i /tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s ".$tnwidth."x$tnheight $root/video-stills/thumbnails/$id"; + system "ffmpeg -i /tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $previewsec $root/video-stills/previews/$id"; $vmaxheight = 640; diff --git a/trunk/upload.pl b/trunk/upload.pl index 85cf0be..cd7e813 100644 --- a/trunk/upload.pl +++ b/trunk/upload.pl @@ -32,7 +32,7 @@ if($userinfo->{'username'}) { $subject.=$tag." "; } - $page->{'uploadform'}->{'DC.Subject'} = $ubject; + $page->{'uploadform'}->{'DC.Subject'} = $subject; $page->{'innerresults'} = ['']; diff --git a/trunk/video.pl b/trunk/video.pl index 3d91db7..aa5ee8e 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -128,7 +128,8 @@ if($query->url_param('title') or $query->url_param('id')) #before code cleanup, this was a really obfuscated array/hash creation push @{ $page->{'video'} }, { - 'thumbnail' => "$domain/video-stills/$id", + 'thumbnail' => "$domain/video-stills/thumbnails/$id", + 'preview' => "$domain/video-stills/previews/$id", 'filesize' => $filesize, 'duration' => $duration, 'width' => $width,