path = "." videos = Dir["#{path}/*.flv"] videos.each do |f| puts "converting #{f}" newFile = f.gsub(".flv", ".jpg") system("ffmpeg -itsoffset -4 -i #{f} -vframes 1 -an -f mjpeg -s 320x240 #{newFile}") end