implemented core ffmpeg functions

[TODO] update README.md and clean code
pull/2/head
Schmenn 2021-01-13 15:25:45 +01:00
parent 24b1b9a48a
commit 2a9103af59
4 changed files with 119 additions and 4 deletions

4
.gitignore vendored
View File

@ -26,3 +26,7 @@ discord-exploits
discord-exploits-linux-32bit
discord-exploits-linux-64bit
*.mp4
*.jpeg

View File

@ -2,10 +2,10 @@ package main
import (
"fmt"
"github.com/Schmenn/discord-exploits/exploits"
"github.com/Schmenn/discord-exploits/modules"
"os"
"strings"
"github.com/Schmenn/discord-exploits/exploits"
"github.com/Schmenn/discord-exploits/modules"
)
var (
@ -27,6 +27,7 @@ func main() {
fmt.Println("mode: " + mode)
initCommand(inputFile, mode)
}
func handleArgs(args []string, quiet *bool) {
@ -64,7 +65,7 @@ func handleArgs(args []string, quiet *bool) {
}
func initCommand(inputFile string, mode string) {
/*func initCommand(inputFile string, mode string) {
inputFile = strings.ToLower(inputFile)
switch strings.ToLower(mode) {
case "e":
@ -73,7 +74,7 @@ func initCommand(inputFile string, mode string) {
exploits.RunExpandingVideoTask(inputFile)
fmt.Println("completed task.")
} else {
fmt.Println("File is not a webm, check -h")
fmt.Println("File is not a webm or mp4, check -h")
}
case "n":
if strings.HasSuffix(inputFile, ".webm") {
@ -101,3 +102,81 @@ func initCommand(inputFile string, mode string) {
}
}
}
*/
func initCommand(inputFile string, mode string) {
inputFile = strings.ToLower(inputFile)
if strings.HasSuffix(inputFile, ".webm") {
switch mode {
case "e":
fmt.Println("editing video.")
exploits.RunExpandingVideoTask(inputFile)
fmt.Println("completed task.")
case "n":
fmt.Println("editing video.")
exploits.RunNegativeVideoTask(inputFile)
fmt.Println("completed task.")
case "0", "v":
fmt.Println("editing video.")
exploits.RunZeroVideoTask(inputFile)
fmt.Println("completed task.")
default:
fmt.Println("the mode doesn't match the file")
}
} else if strings.HasSuffix(inputFile, ".mp4") {
switch mode {
case "e":
fmt.Println("transcoding video from mp4 to webm")
out := modules.Transcode(inputFile, "webm")
fmt.Println("finished transcoding video from mp4 to webm")
fmt.Println("editing video.")
exploits.RunExpandingVideoTask(out)
fmt.Println("completed task.")
os.Remove(out)
case "n":
fmt.Println("transcoding video from mp4 to webm")
out := modules.Transcode(inputFile, "webm")
fmt.Println("finished transcoding video from mp4 to webm")
fmt.Println("editing video.")
exploits.RunNegativeVideoTask(out)
fmt.Println("completed task.")
os.Remove(out)
case "0", "v":
fmt.Println("transcoding video from mp4 to webm")
out := modules.Transcode(inputFile, "webm")
fmt.Println("finished transcoding video from mp4 to webm")
fmt.Println("editing video.")
exploits.RunZeroVideoTask(out)
fmt.Println("completed task.")
os.Remove(out)
default:
fmt.Println("the mode doesn't match the file")
}
} else if strings.HasSuffix(inputFile, "png") {
fmt.Println("editing photo.")
exploits.RunVirusImageTask(inputFile)
fmt.Println("completed task.")
} else if strings.HasSuffix(inputFile, "jpg") {
fmt.Println("transcoding image from jpg to png")
out := modules.Transcode(inputFile, "png")
fmt.Println("finished transcoding image from jpg to png")
fmt.Println("editing photo.")
exploits.RunVirusImageTask(out)
fmt.Println("completed task.")
} else if strings.HasSuffix(inputFile, "jpeg") {
fmt.Println("transcoding image from jpeg to png")
out := modules.Transcode(inputFile, "png")
fmt.Println("finished transcoding image from jpeg to png")
fmt.Println("editing photo.")
exploits.RunVirusImageTask(out)
fmt.Println("completed task.")
}
}

16
modules/ffmpeg-check.go Normal file
View File

@ -0,0 +1,16 @@
package modules
import (
"os/exec"
)
// CheckForFFmpeg looks for ffmpeg in the path
func CheckForFFmpeg() string {
path, err := exec.LookPath("ffmpeg")
if err != nil {
panic(err)
}
return path
}

View File

@ -0,0 +1,16 @@
package modules
import(
"os/exec"
)
//Transcode transcodes video to webm
func Transcode (input string, to string) string {
path := CheckForFFmpeg()
output := CreateName(to)
cmd := exec.Command(path, "-i", input, output)
err := cmd.Run()
Check(err)
return output
}