Skip to content

Instantly share code, notes, and snippets.

@findchris
Created August 11, 2010 03:24
Show Gist options
  • Save findchris/518426 to your computer and use it in GitHub Desktop.
Save findchris/518426 to your computer and use it in GitHub Desktop.
require 'find'
Find.find("/users/cjohnson/vids") do |path|
basename = File.basename(path)
dir = File.dirname(path)
extname = File.extname(path)
next if FileTest.directory?(path)
next if basename[0,2] == "._"
next if basename == ".DS_Store"
next unless extname =~ /(m2ts|mts)/i
basename_no_ext = File.basename(path, extname)
target_path = "#{dir}/#{basename_no_ext}.m4v".gsub(/ /, "\\ ").gsub(/\(/, "\\(").gsub(/\)/, "\\)")
path = path.gsub(/ /, "\\ ").gsub(/\(/, "\\(").gsub(/\)/, "\\)")
%x{/Applications/HandBrakeCLI -i #{path} -o #{target_path} -e x264 -f mp4 -5 -w 1280 -l 720 -q 20 -E ca_aac,ac3 -B 192 -R 48 -x b-adapt=2:rc-lookahead=50:no-fast-pskip=1:no-dct-decimate=1}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment