Update of /cvsroot/freevo/freevo/src/helpers
In directory sc8-pr-cvs1:/tmp/cvs-serv8080

Modified Files:
        cache.py 
Log Message:
support for generating video thumbnails

Index: cache.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/helpers/cache.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** cache.py    3 Jan 2004 17:42:03 -0000       1.12
--- cache.py    4 Jan 2004 17:20:44 -0000       1.13
***************
*** 12,15 ****
--- 12,18 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.13  2004/01/04 17:20:44  dischi
+ # support for generating video thumbnails
+ #
  # Revision 1.12  2004/01/03 17:42:03  dischi
  # o OVERLAY_DIR is now used everytime
***************
*** 96,99 ****
--- 99,108 ----
      print 'deleting old cachefiles...'
      num = 0
+     for file in util.match_files_recursively(config.OVERLAY_DIR, ['png']):
+         if file.endswith('.fvt.png'):
+             if not os.path.isfile(file[len(config.OVERLAY_DIR):-8]):
+                 os.unlink(file)
+                 num += 1
+ 
      for file in util.match_files_recursively(config.OVERLAY_DIR, ['raw']):
          if not vfs.isfile(file[len(config.OVERLAY_DIR):-4]):
***************
*** 186,191 ****
          if not os.path.isdir(d):
              continue
!         files += util.match_files_recursively(d, config.IMAGE_SUFFIX)
  
      for filename in copy.copy(files):
          sinfo = os.stat(filename)
--- 195,202 ----
          if not os.path.isdir(d):
              continue
!         files += util.match_files_recursively(d, config.IMAGE_SUFFIX) + \
!                  util.match_files_recursively(vfs.getoverlay(d), config.IMAGE_SUFFIX)
  
+     files = util.misc.unique(files)
      for filename in copy.copy(files):
          sinfo = os.stat(filename)
***************
*** 218,232 ****
          if not image:
              continue
-         
-         if image.size[0] > 300 and image.size[1] > 300:
-             image.thumbnail((300,300), Image.ANTIALIAS)
  
!         if image.mode == 'P':
!             image = image.convert('RGB')
  
!         # save for future use
!         data = (image.tostring(), image.size, image.mode)
!         util.save_pickle(data, thumb)
  
  
  
--- 229,245 ----
          if not image:
              continue
  
!         try:
!             if image.size[0] > 300 and image.size[1] > 300:
!                 image.thumbnail((300,300), Image.ANTIALIAS)
  
!             if image.mode == 'P':
!                 image = image.convert('RGB')
  
+             # save for future use
+             data = (image.tostring(), image.size, image.mode)
+             util.save_pickle(data, thumb)
+         except:
+             print 'error caching image %s' % filename
  
  
***************
*** 237,246 ****
          print 'cache all files in your data directories.'
          print
!         print 'usage freevo cache [--rebuild]'
          print 'If the --rebuild option is given, Freevo will delete the cache first'
          print 'to rebuild the cache from start. Caches from discs won\'t be affected'
          print
          sys.exit(0)
  
      delete_old_files()
  
--- 250,288 ----
          print 'cache all files in your data directories.'
          print
!         print 'usage "freevo cache [--rebuild]"'
          print 'If the --rebuild option is given, Freevo will delete the cache first'
          print 'to rebuild the cache from start. Caches from discs won\'t be affected'
          print
+         print 'or "freevo cache --thumbnail [ --recursive ] dir"'
+         print 'This will create thumbnails of your _video_ files'
+         print
+         print 'WARNING:'
+         print 'Caching needs a lot free space in OVERLAY_DIR. The space is also'
+         print 'needed when Freevo generates the files during runtime. Image'
+         print 'caching is the worst. So make sure you have several hundred MB'
+         print 'free! OVERLAY_DIR is set to %s' % config.OVERLAY_DIR
+         print
+         print 'It may be possible to turn off image caching in future versions'
+         print 'of Freevo (but this will slow things down).'
+         print
          sys.exit(0)
  
+     if len(sys.argv)>1 and sys.argv[1] == '--thumbnail':
+         import util.videothumb
+         if sys.argv[2] == '--recursive':
+             dirname = os.path.abspath(sys.argv[3])
+             files = util.match_files_recursively(dirname, config.VIDEO_SUFFIX)
+         else:
+             dirname = os.path.abspath(sys.argv[2])
+             files = util.match_files(dirname, config.VIDEO_SUFFIX)
+             
+         print 'creating video thumbnails....'
+         for filename in files:
+             print '  %4d/%-4d %s' % (files.index(filename)+1, len(files),
+                                      os.path.basename(filename))
+             util.videothumb.snapshot(filename, update=False)
+         print
+         sys.exit(0)
+         
      delete_old_files()
  




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to