Skip to content

Instantly share code, notes, and snippets.

@saptarshiguha
Created February 24, 2016 07:17
Show Gist options
  • Select an option

  • Save saptarshiguha/ffbec1934fb73c65abf4 to your computer and use it in GitHub Desktop.

Select an option

Save saptarshiguha/ffbec1934fb73c65abf4 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/Rscript
library(infuser)
a <- commandArgs(trailing=TRUE)
fgif <- normalizePath(path.expand(a[1]))
outf <- gsub("(gif)$","mp4", fgif)
if(length(a)>1){
n <- a[2]
} else {
n <- 10
}
y <- rep("file /tmp/inter.mp4",n)
writeLines(y, "/tmp/list.txt")
x1 <- infuse("ffmpeg -f gif -i {{fgif}} /tmp/inter.mp4 -c:v lib264 -pix_fmt yuv420p", fgif=fgif)
x2 <- "ffmpeg -f concat -i /tmp/list.txt -c copy /tmp/out.mp4"
x3 <- infuse('ffmpeg -y -i /tmp/out.mp4 -crf 18 -c:v libx264 -r 25 -pix_fmt yuv420p -vf "scale=1200:-2" {{outf}}',outf=outf)
system(x1)
system(x2)
system(x3)
system("rm /tmp/inter.mp4 /tmp/out.mp4")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment