@@ -124,9 +124,8 @@ def format_time(secs):
124124 route = os .path .join (prefix , extract_name (self .filepath ) + ".png" )
125125 route = pathlib .Path (route ).as_posix ()
126126
127- with Progress ("Saving thumbnail metadata at '%s'" % self .metadata_path ) as progress :
127+ with Progress ("Saving thumbnail metadata at '%s'" % self .metadata_path ):
128128 for _ , start , end , x , y in self .thumbnails ():
129- progress .update ("Generating metadata for '%s'" % route )
130129 thumbnail_data = "%s --> %s\n %s#xywh=%d,%d,%d,%d\n \n " % (
131130 format_time (start ), format_time (end ),
132131 route , x , y , self .width , self .height ,
@@ -148,26 +147,28 @@ def calc_thumbnail_dir(self):
148147 return ensure_tree (os .path .join (basedir , extract_name (self .filepath )), True )
149148
150149 def prepare_frames (self ):
151- if os .path .exists (self .thumbnail_dir ):
152- remove_tree (self .thumbnail_dir )
153- copy_tree (self .tempdir .name , self .thumbnail_dir )
150+ with Progress ("Copying the frames to the output directory" ):
151+ if os .path .exists (self .thumbnail_dir ):
152+ remove_tree (self .thumbnail_dir )
153+ copy_tree (self .tempdir .name , self .thumbnail_dir )
154154
155155 def generate (self ):
156156 metadata = {}
157157
158- for frame , start , * _ in self .thumbnails ():
159- frame = os .path .join (self .thumbnail_dir , os .path .basename (frame ))
160- with Image .open (frame ) as image :
161- image .resize ((self .width , self .height ), Image .ANTIALIAS ).save (frame )
162- base = os .path .join (self .base , os .path .basename (self .thumbnail_dir ))
163- prefix = base if self .base else os .path .relpath (self .thumbnail_dir )
164- route = os .path .join (prefix , os .path .basename (frame ))
165- route = pathlib .Path (route ).as_posix ()
166- thumbnail_data = {
167- "src" : route ,
168- "width" : "%spx" % self .width ,
169- }
170- metadata [int (start )] = thumbnail_data
158+ with Progress ("Saving thumbnail metadata at '%s'" % self .metadata_path ):
159+ for frame , start , * _ in self .thumbnails ():
160+ frame = os .path .join (self .thumbnail_dir , os .path .basename (frame ))
161+ with Image .open (frame ) as image :
162+ image .resize ((self .width , self .height ), Image .ANTIALIAS ).save (frame )
163+ base = os .path .join (self .base , os .path .basename (self .thumbnail_dir ))
164+ prefix = base if self .base else os .path .relpath (self .thumbnail_dir )
165+ route = os .path .join (prefix , os .path .basename (frame ))
166+ route = pathlib .Path (route ).as_posix ()
167+ thumbnail_data = {
168+ "src" : route ,
169+ "width" : "%spx" % self .width ,
170+ }
171+ metadata [int (start )] = thumbnail_data
171172
172173 with open (self .metadata_path , "w" ) as fp :
173174 json .dump (metadata , fp , indent = 2 )
0 commit comments