Report abuse


			
# Author:: Greg Retkowski 
# I wrote this to transfer pictures off my 
# Panasonic SDR-SW20 Video camera and
# encode it in a format usable by Windows Movie Maker
#
# This software is Public Domain
t = Time.now
# Set the output dir.
dest_dir = "C:/Users/Greg/Videos"
tstamp = t.strftime("%y%m%d%H")
# Where your ffmpeg lives.
ffmpeg_bin="c:/ffmpeg.exe"
# Change start dir to where your camera lands.
start_dir = "H:/SD_VIDEO"
dest_dir = "#{dest_dir}/#{tstamp}"
bitrate = (3000 * 1024).to_s
ffmpeg_args="-vcodec mpeg1video -acodec mp2 -vb #{bitrate} -s 720x480 -aspect 4:3"
o_ext = ".MPG"
counter = 0
Dir.mkdir(dest_dir) if ! File.exists?(dest_dir)
Dir.entries(start_dir).each do |dir|
  Dir.entries(start_dir+"/"+dir).each do |file|
    if /\.MOD/.match(file)
      counter += 1
      fn = "#{start_dir}/#{dir}/#{file}"
      fts = File.new(fn) #.mtime #.strftime("%y%m%d%H%M%S")
      zfn = ("%d" % counter).rjust(8,"0") + o_ext
       ofn = "#{dest_dir}/#{zfn}"
      puts "#{fn} to #{ofn}"
      system("#{ffmpeg_bin} -i #{fn} #{ffmpeg_args} #{ofn}")
    end
  end
end