#- 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
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)
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/
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
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)