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:
parent
3258c69eb1
commit
38515f9c63
1 changed files with 5 additions and 6 deletions
|
@ -130,15 +130,14 @@ while(1)
|
|||
#TODO: maybe delete entry from uploaded table after successful upload?
|
||||
$filesize = -s "$gnutube_root/tmp/$id";
|
||||
|
||||
#convert hh:mm:ss.s duration to full seconds - lazy method by using mysql
|
||||
$sth = $dbh->prepare(qq{select time_to_sec( ? )});
|
||||
$sth->execute($duration);
|
||||
($duration) = $sth->fetchrow_array();
|
||||
$sth->finish();
|
||||
#convert hh:mm:ss.s duration to full seconds - thanks perl for making this so damn easy!
|
||||
#don't want to know how this would look in python or php... hell I don't even have to create extra variables!
|
||||
$duration =~ /^(\d{2}):(\d{2}):(\d{2})\.(\d)$/;
|
||||
$duration = int($1*3600 + $2*60 + $3 + $4/10 + .5);
|
||||
|
||||
#create thumbnail
|
||||
$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
|
||||
if ($container eq 'ogg' and $video eq 'theora' and $audio eq 'vorbis')
|
||||
|
|
Loading…
Reference in a new issue