fix bug of erasing the temp .avi file created by mencoder because
authorgc <gc>
Sun, 14 Aug 2005 20:29:07 +0000 (20:29 +0000)
committergc <gc>
Sun, 14 Aug 2005 20:29:07 +0000 (20:29 +0000)
two files in two different directories have the same name

lib/booh/booh-lib.rb

index 81fa37c..9e37172 100644 (file)
@@ -178,7 +178,7 @@ module Booh
     #- grab the results of a command but don't sleep forever on a runaway process
     def subproc_runaway_aware(command)
         begin
-            timeout(5) {
+            timeout(10) {
                 return `#{command}`
             }
         rescue Timeout::Error    
@@ -310,7 +310,8 @@ module Booh
                     convert_options += ($config['convert-enhance'] || $convert_enhance) + " "
                 end
             end
-            orig_image = "#{dest_dir}/#{File.basename(orig)}.jpg000000.jpg"
+            orig_base = File.basename(dests[0]['filename']) + File.basename(orig)
+            orig_image = "#{dest_dir}/#{orig_base}.jpg000000.jpg"
             system("rm -f '#{orig_image}'")
             for dest in dests
                 if !File.exists?(orig_image)
@@ -320,7 +321,7 @@ module Booh
                             transcode_options += '-k '
                         end
                     end
-                    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"
+                    cmd = "transcode -a 0 -c #{frame_offset}-#{frame_offset+1} -i '#{orig}' -y jpg -o '#{dest_dir}/#{orig_base}.jpg' #{transcode_options} 2>&1"
                     msg 2, cmd
                     results = subproc_runaway_aware(cmd)
                     if results =~ /skipping frames/ && results =~ /encoded 0 frames/
@@ -329,20 +330,20 @@ module Booh
                         return false
                     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}/#{File.basename(orig)}.avi' -frames #{frame_offset+26} -fps 25 >/dev/null 2>/dev/null"
+                        cmd = "mencoder '#{orig}' -nosound -ovc lavc -lavcopts vcodec=mjpeg -o '#{dest_dir}/#{orig_base}.avi' -frames #{frame_offset+26} -fps 25 >/dev/null 2>/dev/null"
                         msg 2, cmd
                         system cmd
-                        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"
+                        if File.exists?("#{dest_dir}/#{orig_base}.avi")
+                            cmd = "transcode -a 0 -c #{frame_offset}-#{frame_offset+1} -i '#{dest_dir}/#{orig_base}.avi' -y jpg -o '#{dest_dir}/#{orig_base}.jpg' #{transcode_options} 2>&1"
                             msg 2, cmd
                             results = subproc_runaway_aware(cmd)
-                            system("rm -f '#{dest_dir}/#{File.basename(orig)}.avi'")
+                            system("rm -f '#{dest_dir}/#{orig_base}.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?(orig_image)
-                                msg 0, _("could not extract first image of video %s encoded by mencoder") % "#{dest_dir}/#{File.basename(orig)}.avi"
+                                msg 0, _("could not extract first image of video %s encoded by mencoder") % "#{dest_dir}/#{orig_base}.avi"
                                 return false
                             end
                         else
@@ -352,7 +353,7 @@ module Booh
                     end
                     if felem && whitebalance = felem.attributes["#{attributes_prefix}white-balance"]
                         if whitebalance.to_f != 0
-                            neworig = "#{dest_dir}/#{File.basename(orig)}-whitebalance#{whitebalance}.jpg"
+                            neworig = "#{dest_dir}/#{orig_base}-whitebalance#{whitebalance}.jpg"
                             cmd = "booh-fix-whitebalance '#{orig_image}' '#{neworig}' #{whitebalance}"
                             sys(cmd)
                             if File.exists?(neworig)