Skip to content

Instantly share code, notes, and snippets.

@jamesu
Created November 14, 2009 22:13
Show Gist options
  • Save jamesu/234809 to your computer and use it in GitHub Desktop.
Save jamesu/234809 to your computer and use it in GitHub Desktop.
#
# (C) 2009 Stuart J Urquhart.
# Licensed under the MIT License.
#
# The following script generates the .pvranim files used in vidsplit.
require 'rubygems'
require 'fileutils'
puzzle_video = ARGV[0]
video_base = ARGV[1]
VIDEO_QUALITY=4
VIDEO_FPS=15
CROP_SIZE=[0,0]
#CROP_SIZE=[0,96]
puts "Generating #{puzzle_video} -> #{video_base}..."
# Make PNG images...
system "/Applications/ffmpegX.app/Contents/Resources/ffmpeg -i \"#{puzzle_video}\" -croptop #{CROP_SIZE[0]} -cropbottom #{CROP_SIZE[1]} -vcodec png -r #{VIDEO_FPS} -s 256x256 ~/tmp/#{video_base}%03d.png"
# Generate PVR...
Dir["/Users/jamesu/tmp/#{video_base}*.png"].each do |filename|
system "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-#{VIDEO_QUALITY} -o #{filename}.pvr #{filename}"
end
# Now compose into a pvranim
system "cat ~/tmp/#{video_base}*.pvr > #{video_base}.pvranim"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment