|
|
@ -2,16 +2,13 @@ package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"math/rand" |
|
|
|
|
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"os/exec" |
|
|
|
"os/exec" |
|
|
|
|
|
|
|
"path/filepath" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
rand.Seed(time.Now().UnixNano()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(os.Args) < 5 { |
|
|
|
if len(os.Args) < 5 { |
|
|
|
fmt.Println("Usage: go run main.go <source-file> <number-of-copies> <shit-size> <iterations>") |
|
|
|
fmt.Println("Usage: go run main.go <source-file> <number-of-copies> <shit-size> <iterations>") |
|
|
|
return |
|
|
|
return |
|
|
@ -32,7 +29,6 @@ func main() { |
|
|
|
|
|
|
|
|
|
|
|
iterations, err := strconv.ParseInt(os.Args[4], 10, 8) |
|
|
|
iterations, err := strconv.ParseInt(os.Args[4], 10, 8) |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
for i := 1; i <= numCopies; i++ { |
|
|
|
for i := 1; i <= numCopies; i++ { |
|
|
|
outputFile := fmt.Sprintf("%s_glitched_%d%s", |
|
|
|
outputFile := fmt.Sprintf("%s_glitched_%d%s", |
|
|
|
stripExtension(sourceFile), |
|
|
|
stripExtension(sourceFile), |
|
|
@ -45,48 +41,11 @@ func main() { |
|
|
|
fmt.Printf("Error glitching file %d: %v\n", i, err) |
|
|
|
fmt.Printf("Error glitching file %d: %v\n", i, err) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
generateGlitchedSequence(sourceFile, numCopies, shitSize, iterations) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputPattern := "./output/img_glitched_%d.jpeg" |
|
|
|
|
|
|
|
outputVideo := "output.mp4" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd := exec.Command( |
|
|
|
|
|
|
|
"ffmpeg", |
|
|
|
|
|
|
|
"-y", |
|
|
|
|
|
|
|
"-framerate", "30", |
|
|
|
|
|
|
|
"-i", inputPattern, |
|
|
|
|
|
|
|
"-vf", "scale=trunc(iw/2)*2:trunc(ih/2)*2,setpts=PTS*2.0", // Scale and slow down playback
|
|
|
|
|
|
|
|
"-vcodec", "libx264", // Use H.264 codec
|
|
|
|
|
|
|
|
"-pix_fmt", "yuv420p", |
|
|
|
|
|
|
|
"-crf", "23", // Compression level: lower is higher quality (range: 18-28)
|
|
|
|
|
|
|
|
"-preset", "fast", |
|
|
|
|
|
|
|
outputVideo, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
done := make(chan bool) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
go func() { |
|
|
|
fmt.Println("GENREATING GIF YEAHH ") |
|
|
|
err := cmd.Run() |
|
|
|
// now run ffmpeg to make a gif!
|
|
|
|
|
|
|
|
cmd := exec.Command("ffmpeg", "-y", "-framerate 60", "-i", "./output/img_glitched_%d.jpeg output.gif") |
|
|
|
|
|
|
|
err = cmd.Run() |
|
|
|
check(err, "cannot run ffmpeg command!") |
|
|
|
check(err, "cannot run ffmpeg command!") |
|
|
|
done <- true |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
go func() { |
|
|
|
|
|
|
|
msg := "Generating MP4" |
|
|
|
|
|
|
|
c := 0 |
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
select { |
|
|
|
|
|
|
|
case <-done: |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
fmt.Printf("\r%s%s", msg, dots(c)) |
|
|
|
|
|
|
|
c = (c + 1) |
|
|
|
|
|
|
|
time.Sleep(500 * time.Millisecond) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
<-done |
|
|
|
|
|
|
|
fmt.Println("\nGIF successfully created in ./output.mp4!") |
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
} |
|
|
|
} |
|
|
|