Skip to content

Instantly share code, notes, and snippets.

@qbein
Created November 22, 2011 19:23
Show Gist options
  • Save qbein/1386640 to your computer and use it in GitHub Desktop.
Save qbein/1386640 to your computer and use it in GitHub Desktop.
Convert a video file to format suitable for iPhone, iPad and Apple TV
#!/usr/bin/ruby
FILEPATH = ARGV[0]
OUTPUT_DIR = ARGV[1]
raise "Usage: ipadencode.rb FILEPATH OUTPUT_DIR" if FILEPATH.nil? || OUTPUT_DIR.nil?
raise "First argument must be a video file" unless File.exist?(FILEPATH)
raise "Second argument must be a directory" unless File.directory?(OUTPUT_DIR)
OUTPUT_FILE = File.basename(FILEPATH).gsub(/.[a-z0-9]{3,4}$/i, ".mp4")
Dir.chdir(OUTPUT_DIR) do
system "ffmpeg -i #{FILEPATH} -s 1280x720 -b 384k -vcodec libx264 -r 23.976 -acodec libfaac -ac 2 -ar 44100 -ab 64k -vpre ipod720 -crf 22 -deinterlace #{OUTPUT_FILE}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment