2021-01-15 10:52:04 +00:00
|
|
|
package modules
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
2021-01-25 09:52:39 +00:00
|
|
|
"strings"
|
2021-01-15 10:52:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
//Transcode transcodes videos and images
|
|
|
|
func Transcode(input string, to string) string {
|
|
|
|
path := CheckForFFmpeg()
|
|
|
|
output := CreateName(to)
|
|
|
|
|
2021-01-25 09:52:39 +00:00
|
|
|
if strings.HasSuffix(input, ".ogg") || strings.HasSuffix(input, ".mp3") || strings.HasSuffix(input, ".m4a") {
|
2021-03-23 11:45:20 +00:00
|
|
|
_, err := exec.Command(path, "-i", input, "-ar", "44100", "-y", "-c:a", "libvorbis", output).CombinedOutput()
|
2021-01-25 09:52:39 +00:00
|
|
|
Check(err)
|
|
|
|
|
|
|
|
fmt.Println("temporarily saving transcoded file to " + output)
|
2021-03-23 11:45:20 +00:00
|
|
|
|
2021-01-25 09:52:39 +00:00
|
|
|
return output
|
|
|
|
}
|
|
|
|
|
2021-03-23 11:45:20 +00:00
|
|
|
_, err := exec.Command(path, "-i", input, output).CombinedOutput()
|
2021-01-15 10:52:04 +00:00
|
|
|
|
|
|
|
Check(err)
|
|
|
|
|
|
|
|
fmt.Println("temporarily saving transcoded file to " + output)
|
|
|
|
|
|
|
|
return output
|
|
|
|
}
|