make gen_thumbnails reentrant, the GUI can call it from different threads
authorgc <gc>
Sun, 3 Jul 2005 20:13:56 +0000 (20:13 +0000)
committergc <gc>
Sun, 3 Jul 2005 20:13:56 +0000 (20:13 +0000)
bin/booh
bin/booh-backend
lib/booh/booh-lib.rb

index bbad2b6f168df18e0305c479f35c590dffc192ef..d4b8770fbd5b09f1f853e55f85463cdf39de1b97 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -496,10 +496,6 @@ def recalc_whitebalance(level, orig, thumbnail_img, img, xmlelem, attributes_pre
         system("rm -f '#{destfile}'")
         xmlelem.add_attribute("#{attributes_prefix}white-balance", save_whitebalance)
         $modified_pixbufs[thumbnail_img][:angle_to_orig] = 0
-        if entry2type(orig) == 'video'
-            #- cleanup temp for videos
-            system("rm -f #{current_dest_dir}/screenshot.jpg000000.jpg")
-        end
     end
 
     $modified_pixbufs[thumbnail_img] ||= {}
@@ -575,10 +571,6 @@ def gen_real_thumbnail(type, origfile, destfile, xmldir, size, img, infotype)
         gen_real_thumbnail_core(type, origfile, destfile, xmldir, size, infotype)
         gtk_thread_protect { img.set(destfile) }
         $modified_pixbufs[destfile] = { :orig => img.pixbuf, :pixbuf => img.pixbuf, :angle_to_orig => 0 }
-        if entry2type(origfile) == 'video'
-            #- cleanup temp for videos
-            system("rm -f #{current_dest_dir}/screenshot.jpg000000.jpg")
-        end
         pop_mousecursor
     }
 end
index 0cd2f97ee25043330d84d46ff696e49d0baf07f2..0cf165a5a7c7432d64ad2bbd1c522b1726fabca6 100755 (executable)
@@ -661,8 +661,6 @@ def walk_source_dir
             if !File.exists?(destvideo)
                 psys("cp '#{dir}/#{video}' '#{destvideo}'")
             end
-            #- cleanup temp
-            system("rm -f #{dest_dir}/screenshot.jpg000000.jpg")
         }
 
         if !$forgui
@@ -880,8 +878,6 @@ def walk_source_dir
                 html_index.gsub!(/~~image_iteration~~/, "<a href='thumbnails.html'>" + img_element(thumbnail) + '</a>')
                 html_index.gsub!(/~~caption_iteration~~/, xmldir.attributes['thumbnails-caption'])
             end
-            #- cleanup temp for videos
-            system("rm -f #{dest_dir}/screenshot.jpg000000.jpg")
 
             #- deal with sub-albums (direct to subdirs/index.html pages)
             xmldir.elements.each('dir') { |child|
@@ -896,8 +892,6 @@ def walk_source_dir
                                       [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ], find_subalbum_info_type(child))
                 html_index.gsub!(/~~caption_iteration~~/, caption)
                 html_index.gsub!(/~~image_iteration~~/, "<a href='#{make_dest_filename(subdir)}/index.html'>" + img_element(thumbnail) + '</a>')
-                #- cleanup temp for videos
-                system("rm -f #{dest_dir}/screenshot.jpg000000.jpg")
             }
 
             html_index += close_iterations(iterations)
index 1b37e2e7ea023fb78259fa29ba09e3cf94f06167..0cd1fe029c6083883ed9a781cf8c0a7476ccae1b 100644 (file)
@@ -295,7 +295,7 @@ module Booh
                     convert_options += ($config['convert-enhance'] || $convert_enhance) + " "
                 end
             end
-            orig_image = "#{dest_dir}/screenshot.jpg000000.jpg"
+            orig_image = "#{dest_dir}/#{File.basename(orig)}.jpg000000.jpg"
             for dest in dests
                 if !File.exists?(orig_image)
                     transcode_options = ''
@@ -304,29 +304,29 @@ module Booh
                             transcode_options += '-k '
                         end
                     end
-                    cmd = "transcode -a 0 -c #{frame_offset}-#{frame_offset+1} -i '#{orig}' -y jpg -o '#{dest_dir}/screenshot.jpg' #{transcode_options} 2>&1"
+                    cmd = "transcode -a 0 -c #{frame_offset}-#{frame_offset+1} -i '#{orig}' -y jpg -o '#{dest_dir}/#{File.basename(orig)}.jpg' #{transcode_options} 2>&1"
                     msg 2, cmd
                     results = subproc_runaway_aware(cmd)
                     if results =~ /skipping frames/ && results =~ /encoded 0 frames/
                         msg 0, _("specified frame-offset too large? max frame was: %s. that may also be another problem. try another value.") %
                                results.scan(/skipping frames \[000000-(\d+)\]/)[-1]
                         return false
-                    elsif results =~ /V: import format.*unknown/ || !File.exists?("#{dest_dir}/screenshot.jpg000000.jpg")
+                    elsif results =~ /V: import format.*unknown/ || !File.exists?(orig_image)
                         msg 2, _("* could not extract first image of video %s with transcode, will try first converting with mencoder") % orig
-                        cmd = "mencoder '#{orig}' -nosound -ovc lavc -lavcopts vcodec=mjpeg -o '#{dest_dir}/foo.avi' -frames #{frame_offset+1} -fps 25 >/dev/null 2>/dev/null"
+                        cmd = "mencoder '#{orig}' -nosound -ovc lavc -lavcopts vcodec=mjpeg -o '#{dest_dir}/#{File.basename(orig)}.avi' -frames #{frame_offset+1} -fps 25 >/dev/null 2>/dev/null"
                         msg 2, cmd
                         system cmd
-                        if File.exists?("#{dest_dir}/foo.avi")
-                            cmd = "transcode -a 0 -c #{frame_offset}-#{frame_offset+1} -i '#{dest_dir}/foo.avi' -y jpg -o '#{dest_dir}/screenshot.jpg' #{transcode_options} 2>&1"
+                        if File.exists?("#{dest_dir}/#{File.basename(orig)}.avi")
+                            cmd = "transcode -a 0 -c #{frame_offset}-#{frame_offset+1} -i '#{dest_dir}/#{File.basename(orig)}.avi' -y jpg -o '#{dest_dir}/#{File.basename(orig)}.jpg' #{transcode_options} 2>&1"
                             msg 2, cmd
                             results = subproc_runaway_aware(cmd)
-                            system("rm -f '#{dest_dir}/foo.avi'")
+                            system("rm -f '#{dest_dir}/#{File.basename(orig)}.avi'")
                             if results =~ /skipping frames/ && results =~ /encoded 0 frames/
                                 msg 0, _("specified frame-offset too large? max frame was: %s. that may also be another probleme. try another value.") %
                                        results.scan(/skipping frames \[000000-(\d+)\]/)[-1]
                                 return false
-                            elsif results =~ /V: import format.*unknown/ || !File.exists?("#{dest_dir}/screenshot.jpg000000.jpg")
-                                msg 0, _("could not extract first image of video %s encoded by mencoder") % "#{dest_dir}/foo.avi"
+                            elsif results =~ /V: import format.*unknown/ || !File.exists?(orig_image)
+                                msg 0, _("could not extract first image of video %s encoded by mencoder") % "#{dest_dir}/#{File.basename(orig)}.avi"
                                 return false
                             end
                         else