Skip to content

Instantly share code, notes, and snippets.

@tuler
Created June 5, 2013 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuler/5713178 to your computer and use it in GitHub Desktop.
Save tuler/5713178 to your computer and use it in GitHub Desktop.
groovy script to generate a film strip
@Grab( 'commons-io:commons-io:2.1' )
import org.apache.commons.io.FilenameUtils
// filename of video
def filename = this.args[0]
// base of filename
def basename = FilenameUtils.getBaseName(filename)
// width of final strip
def width = this.args.length > 1 ? this.args[1] : 640
// number of desired frames
def count = 8
// calculate the height assuming 16x9 video
def w = width / count
def h = Math.round(w * 9 / 16)
(1..count).each { c ->
"ffmpegthumbnailer -i ${filename} -o ${basename}_${c}.jpg -s ${w} -t ${((c-1) / count) * 100}%".execute().waitFor()
}
"convert +append ${basename}_*.jpg ${basename}.jpg".execute().waitFor()
"rm -f ${basename}_*".execute().waitFor()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment