fixed duration calculation with a clever regex

git-svn-id: http://yolanda.mister-muffin.de/svn@91 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2007-10-19 08:42:03 +00:00
parent 3258c69eb1
commit 38515f9c63

View file

@ -130,15 +130,14 @@ while(1)
#TODO: maybe delete entry from uploaded table after successful upload? #TODO: maybe delete entry from uploaded table after successful upload?
$filesize = -s "$gnutube_root/tmp/$id"; $filesize = -s "$gnutube_root/tmp/$id";
#convert hh:mm:ss.s duration to full seconds - lazy method by using mysql #convert hh:mm:ss.s duration to full seconds - thanks perl for making this so damn easy!
$sth = $dbh->prepare(qq{select time_to_sec( ? )}); #don't want to know how this would look in python or php... hell I don't even have to create extra variables!
$sth->execute($duration); $duration =~ /^(\d{2}):(\d{2}):(\d{2})\.(\d)$/;
($duration) = $sth->fetchrow_array(); $duration = int($1*3600 + $2*60 + $3 + $4/10 + .5);
$sth->finish();
#create thumbnail #create thumbnail
$thumbnailsec = int($duration/3 + .5); $thumbnailsec = int($duration/3 + .5);
system "ffmpeg -i $gnutube_root/tmp/$id -vcodec png -vframes 1 -an -f rawvideo -ss $thumbnailsec -s 320x240 $gnutube_root/video-stills/$id"; system "ffmpeg -i $gnutube_root/tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s 320x240 $gnutube_root/video-stills/$id";
#check if the upload already is in the right format #check if the upload already is in the right format
if ($container eq 'ogg' and $video eq 'theora' and $audio eq 'vorbis') if ($container eq 'ogg' and $video eq 'theora' and $audio eq 'vorbis')