Update of /cvsroot/freevo/freevo/src/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28553
Modified Files:
videothumb.py
Log Message:
create small image using mevas in the child itself, do not save as .raw
Index: videothumb.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/util/videothumb.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** videothumb.py 20 Dec 2004 14:31:44 -0000 1.24
--- videothumb.py 1 Jan 2005 18:36:12 -0000 1.25
***************
*** 41,47 ****
import mmpython
import glob
- import shutil
- import Image
import popen2
from stat import *
--- 41,46 ----
import mmpython
import glob
import popen2
+ import mevas
from stat import *
***************
*** 67,76 ****
def stdout_cb(self, line):
! if line[:-1]:
! print '>>', line[:-1]
def stderr_cb(self, line):
! if line[:-1]:
! print '>>', line[:-1]
def finished(self):
--- 66,77 ----
def stdout_cb(self, line):
! line.strip(' \t\n')
! if line:
! log.info('>>' % line)
def stderr_cb(self, line):
! line.strip(' \t\n')
! if line:
! log.info('>>' % line)
def finished(self):
***************
*** 78,120 ****
_runqueue = _runqueue[1:]
! if vfs.isfile(self.imagefile):
! imagefile = self.imagefile
! try:
! image = Image.open(imagefile)
! if image.size[0] > 255 or image.size[1] > 255:
! image.thumbnail((255,255), Image.ANTIALIAS)
!
! if image.mode == 'P':
! image = image.convert('RGB')
!
! if image.size[0] * 3 > image.size[1] * 4:
! # fix image with blank bars to be 4:3
! ni = Image.new('RGB', (image.size[0],
! (image.size[0]*3)/4))
! ni.paste(image, (0,(((image.size[0]*3)/4)-\
! image.size[1])/2))
! image = ni
! elif image.size[0] * 3 < image.size[1] * 4:
! # strange aspect, let's guess it's 4:3
! new_size = (image.size[0], (image.size[0]*3)/4)
! image = Image.open(imagefile).resize(new_size,
! Image.ANTIALIAS)
!
! # crob some pixels, looks better that way
! image = image.crop((4, 3, image.size[0]-8,
! image.size[1]-6))
! if imagefile.endswith('.raw.tmp'):
! f = vfs.open(imagefile[:-4], 'w')
! f.write('FRI%s%s%5s' % (chr(image.size[0]),
! chr(image.size[1]),
! image.mode))
! f.write(image.tostring())
! f.close()
! os.unlink(imagefile)
! else:
! image.save(imagefile)
! except (OSError, IOError), e:
! log.exception('saving image')
! else:
log.warning('no imagefile found')
if _runqueue:
--- 79,83 ----
_runqueue = _runqueue[1:]
! if not vfs.isfile(self.imagefile):
log.warning('no imagefile found')
if _runqueue:
***************
*** 130,134 ****
global _runqueue
if not imagefile:
! imagefile = vfs.getoverlay(videofile + '.raw')
if not update and os.path.isfile(imagefile) and \
--- 93,97 ----
global _runqueue
if not imagefile:
! imagefile = os.path.splitext(videofile)[0] + '.jpg'
if not update and os.path.isfile(imagefile) and \
***************
*** 143,147 ****
return
! print 'generate', imagefile
args = [ config.MPLAYER_CMD, videofile, imagefile ]
--- 106,110 ----
return
! log.info('generate %s' % imagefile)
args = [ config.MPLAYER_CMD, videofile, imagefile ]
***************
*** 149,157 ****
args.append(str(pos))
! _runqueue.append((([os.environ['FREEVO_SCRIPT'], 'execute',
! os.path.abspath(__file__) ] + args), imagefile))
if len(_runqueue) == 1:
MplayerThumbnail(*_runqueue[0])
!
--- 112,121 ----
args.append(str(pos))
! job = (([os.environ['FREEVO_SCRIPT'], 'execute',
! os.path.abspath(__file__) ] + args), imagefile)
! _runqueue.append(job)
if len(_runqueue) == 1:
MplayerThumbnail(*_runqueue[0])
!
***************
*** 199,208 ****
child.childerr.close()
child.tochild.close()
# store the correct thumbnail
captures = glob.glob('000000??.png')
! if captures:
! capture = captures[-1]
try:
! shutil.copy(capture, imagefile)
except:
try:
--- 163,191 ----
child.childerr.close()
child.tochild.close()
+
# store the correct thumbnail
captures = glob.glob('000000??.png')
! if not captures:
! print "error creating capture for %s" % filename
! sys.exit(1)
!
! capture = captures[-1]
!
! try:
! image = mevas.imagelib.open(capture)
! if image.width > 255 or image.height > 255:
! image.scale_preserve_aspect((255,255))
! if image.width * 3 > image.height * 4:
! # fix image with blank bars to be 4:3
! nh = (image.width*3)/4
! ni = mevas.imagelib.new((image.width, nh))
! ni.blend(image, (0,(nh- image.height) / 2))
! image = ni
! elif image.width * 3 < image.height * 4:
! # strange aspect, let's guess it's 4:3
! new_size = (image.width, (image.width*3)/4)
! image.scale((new_size))
try:
! image.save(imagefile)
except:
try:
***************
*** 211,219 ****
if not os.path.isdir(os.path.dirname(imagefile)):
os.makedirs(os.path.dirname(imagefile))
! shutil.copy(capture, imagefile)
except Exception, e:
! print 'unable to write file %s: %s' %
(vfs.getoverlay(imagefile), e)
! else:
! print "error creating capture for %s" % filename
for capture in captures:
--- 194,203 ----
if not os.path.isdir(os.path.dirname(imagefile)):
os.makedirs(os.path.dirname(imagefile))
! image.save(imagefile)
except Exception, e:
! print 'unable to write file %s: %s' % \
! (vfs.getoverlay(imagefile), e)
! except (OSError, IOError), e:
! print 'saving image', e
for capture in captures:
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog