package transcoder import ( "fmt" "log" "os" "os/exec" "path/filepath" "github.com/spf13/viper" ) func Transcode(inFile string) { // create ingest and archive paths ingestPath := filepath.Join(viper.GetString("transcoder.repository"), "ingest", inFile) outputPath := filepath.Join(viper.GetString("transcoder.repository"), "output", inFile) log.Printf("Transcoding video file %s.", ingestPath) cmd := exec.Command("/usr/bin/ffmpeg", "-i", ingestPath, "-y", "-f", viper.GetString("transcoder.video_format"), "-c:v", viper.GetString("transcoder.video_codec"), "-s", viper.GetString("transcoder.video_resolution"), "-r", viper.GetString("transcoder.video_framerate"), "-vf", fmt.Sprintf("format=%s", viper.GetString("transcoder.video_color")), "-profile:v", viper.GetString("transcoder.video_profile"), "-c:a", viper.GetString("transcoder.audio_codec"), outputPath) if err := cmd.Run(); err != nil { log.Fatalf("Error while transcoding: %s.", err) os.Exit(1) } }