Skip to content

Commit

Permalink
added ruby script to convert videos to sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Praderio committed Nov 3, 2015
1 parent 16d51dc commit e3b94e0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
24 changes: 24 additions & 0 deletions get_frames_video.rb
@@ -0,0 +1,24 @@
require 'shellwords'

#path = '~/Videos/castelloscopi_baixa_resolució/POM_de_DALT/baixa_resolució'
#path = '~/Videos/castelloscopi_baixa_resolució/TRONC'
#path = '~/Videos/castelloscopi_baixa_resolució/PINYA'
path = '~/Videos/castelloscopi_baixa_resolució/MÚSICS'

videos = Dir.entries("#{path}/.").select { |f| File.file?("#{path}/#{f}") }

videos.each{
|video|
puts video
video_file = "#{path}/#{video}"
video_escaped = "#{File.dirname video_file}/#{File.basename video_file}".shellescape

frames = "#{File.basename video_file, '.mov'}".gsub(' ','_').shellescape
frames_folder = "#{File.dirname video_file}/#{frames}"

system "mkdir #{frames_folder}"
system "ffmpeg -i #{video_escaped} -r 1 -vframes 64 -ss 00:00:40 -s vga #{frames_folder}/image-%d.jpeg"
system "convert #{frames_folder}/* +append #{frames_folder}/#{frames}.png"
system "rm #{frames_folder}/image*"

}
15 changes: 9 additions & 6 deletions video_to_texture.txt
@@ -1,11 +1,14 @@

- Per passar els videos a imatges
http://linuxers.org/tutorial/how-extract-images-video-using-ffmpeg
ffmpeg -i 12--Cstllscp\ Fsc\ segon\ Cucu.mov -r 1 -vframes 100 -ss 00:00:40 -s vga image-%d.jpeg
#Per passar els videos a imatges
#http://linuxers.org/tutorial/how-extract-images-video-using-ffmpeg
ffmpeg -i 12--Cstllscp\ Fsc\ segon\ Cucu.mov -r 1 -vframes 64 -ss 00:00:40 -s vga image-%d.jpeg

les sprites com a màxim de 8064px (64 imatges)
#les sprites com a màxim de 8064px (64 imatges) 8192x96

- Per unir les imatges (CSS spritting)

http://www.phpied.com/command-line-css-spriting/
#Per unir les imatges (CSS spritting)
#http://www.phpied.com/command-line-css-spriting/
convert * +append casteller.png

#per cambiar les dimensions de les imatges
mogrify -resize 8192x96 *.png

0 comments on commit e3b94e0

Please sign in to comment.