Created
June 5, 2013 11:15
-
-
Save tuler/5713178 to your computer and use it in GitHub Desktop.
groovy script to generate a film strip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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