Finished the transcoding job
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-08-31 23:53:51 -04:00
parent 1548701ed3
commit 02dfc7c291
2 changed files with 37 additions and 1 deletions

View File

@ -17,7 +17,7 @@ func main() {
// archive file // archive file
r.ArchiveFile(i.Name()) r.ArchiveFile(i.Name())
// transcode file // transcode file
// TODO - t.Transcode(i.Name()) transcoder.Transcode(i.Name())
// clean up source file // clean up source file
r.CleanupFile(i.Name()) r.CleanupFile(i.Name())
} }

36
transcoder/transcoder.go Normal file
View File

@ -0,0 +1,36 @@
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)
}
}