move ffmpeg command to seperate table

This commit is contained in:
Samuel Lorch 2024-06-23 22:47:50 +02:00
parent 72dfd2408f
commit cdeb266e38
20 changed files with 245 additions and 84 deletions

View file

@ -21,20 +21,20 @@ func RunTranscode(conf config.Config, t *types.Task, data types.TranscodeData) {
dst_path := filepath.Join(conf.Worker.TempDir, fmt.Sprintf("dst-%v-%v.mkv", t.ID, t.FileID))
// Set ffmpeg input path
if len(data.Command.InputFiles) == 0 {
l.ErrorContext(ctx, "FFmpeg Command has no input files")
if len(t.FfmpegCommand.InputFiles) == 0 {
l.ErrorContext(ctx, "FFmpeg Command has no input files", "command", t.FfmpegCommand)
return
}
data.Command.InputFiles[0].Path = src_path
t.FfmpegCommand.InputFiles[0].Path = src_path
// Set ffmpeg output path
if len(data.Command.OutputFiles) == 0 {
l.ErrorContext(ctx, "FFmpeg Command has no output files")
if len(t.FfmpegCommand.OutputFiles) == 0 {
l.ErrorContext(ctx, "FFmpeg Command has no output files", "command", t.FfmpegCommand)
return
}
data.Command.OutputFiles[0].Path = dst_path
t.FfmpegCommand.OutputFiles[0].Path = dst_path
// TODO cleanup file when done
defer func() {
@ -62,7 +62,7 @@ func RunTranscode(conf config.Config, t *types.Task, data types.TranscodeData) {
}
}()
err = runFfmpegCommand(ctx, l, conf, data.Command)
err = runFfmpegCommand(ctx, l, conf, t.FfmpegCommand)
if err != nil {
l.ErrorContext(ctx, "FFmpeg Failed", "err", err)
return