From 24b11a403364073916d5a348d7169167310cc483 Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Wed, 22 Jan 2025 18:51:01 +0000 Subject: [PATCH] png support --- ffmpeg.go | 4 ++-- glitch.go | 4 ++-- main.go | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ffmpeg.go b/ffmpeg.go index 6da23e3..28fa7e7 100644 --- a/ffmpeg.go +++ b/ffmpeg.go @@ -6,8 +6,8 @@ import ( "time" ) -func ffmpegGenerateMP4() { - inputPattern := "./output/img_glitched_%d.jpeg" +func ffmpegGenerateMP4(fileExt string) { + inputPattern := "./output/img_glitched_%d." + fileExt outputVideo := "output.mp4" cmd := exec.Command( diff --git a/glitch.go b/glitch.go index ccf7a89..81b7f94 100644 --- a/glitch.go +++ b/glitch.go @@ -71,9 +71,9 @@ func copyImage(inputFile string, outputFile string) error { return nil } -func generateGlitchedSequence(inputFile string, totalImages int, shitSize int64, iterations int64, chanceToRandom int32) { +func generateGlitchedSequence(inputFile string, fileExt string, totalImages int, shitSize int64, iterations int64, chanceToRandom int32) { for i := 1; i <= totalImages; i++ { - outputFileName := fmt.Sprintf("img_glitched_%d.jpeg", i) // Generate unique filenames + outputFileName := fmt.Sprintf("img_glitched_%d.%s", i, fileExt) if rand.Int32N(100) < chanceToRandom { // Glitched image diff --git a/main.go b/main.go index af5a187..c58d8ad 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "path/filepath" "strconv" ) @@ -22,6 +23,7 @@ func main() { } sourceFile := os.Args[1] + fileExt := filepath.Ext(sourceFile) numCopies, err := strconv.Atoi(os.Args[2]) if err != nil || numCopies <= 0 { @@ -50,12 +52,12 @@ func main() { return } - fmt.Fprintf(os.Stdout, "Generating:\n %d copies of %s\n %d random bytes of data\n %d interations(s)\n Chance to random %d%%\n\n", - numCopies, sourceFile, shitSize, iterations, chanceToRandom) + fmt.Fprintf(os.Stdout, "Generating:\n %d copies of %s\n %d random bytes of data\n %d interations(s)\n Chance to random %d%%\n File Extention: %s\n\n", + numCopies, sourceFile, shitSize, iterations, chanceToRandom, fileExt) makeOutputDir() defer clearOutputDir() - generateGlitchedSequence(sourceFile, numCopies, shitSize, iterations, int32(chanceToRandom)) - ffmpegGenerateMP4() + generateGlitchedSequence(sourceFile, fileExt, numCopies, shitSize, iterations, int32(chanceToRandom)) + ffmpegGenerateMP4(fileExt) }