Transcode Task Handling

This commit is contained in:
Samuel Lorch 2024-06-22 21:12:52 +02:00
parent fea955fb79
commit 13ea1cb755
6 changed files with 164 additions and 20 deletions

View file

@ -7,6 +7,7 @@ import (
"fmt"
"log/slog"
"net/http"
"strconv"
"time"
"git.lastassault.de/speatzle/morffix/constants"
@ -174,7 +175,11 @@ func createTask(ctx context.Context, r *http.Request) error {
}
library := r.FormValue("library")
health := r.FormValue("health")
typ := r.FormValue("type")
typ, err := strconv.Atoi(r.FormValue("type"))
if err != nil {
return fmt.Errorf("Parsing Task Type: %w", err)
}
slog.Info("Got Task Create", "library", library, "health", health, "type", typ)
rows, err := db.Query(r.Context(), "SELECT id, path, size, status, health, md5, updated_at FROM files where library_id = $1 AND status = $2 AND (-1 = $3 OR health = $3)", library, constants.FILE_STATUS_EXISTS, health)
@ -193,7 +198,7 @@ func createTask(ctx context.Context, r *http.Request) error {
defer tx.Rollback(ctx)
var data any
if true { // TODO typ == constants.TASK_TYPE_HEALTHCHECK {
if typ == constants.TASK_TYPE_HEALTHCHECK {
// ffmpeg.exe -stats -v error -i "in.mp4" -f null -max_muxing_queue_size 9999 "out.mp4"
data = types.HealthCheckData{Command: types.FFmpegCommand{
@ -201,6 +206,14 @@ func createTask(ctx context.Context, r *http.Request) error {
InputFiles: []types.File{{Path: "input.mkv"}},
OutputFiles: []types.File{{Path: "output.mkv", Arguments: []types.Arg{{Flag: "-f", Value: "null"}, {Flag: "-max_muxing_queue_size", Value: "9999"}}}},
}}
} else if typ == constants.TASK_TYPE_TRANSCODE {
data = types.TranscodeData{Command: types.FFmpegCommand{
Args: []types.Arg{{Flag: "-stats"}, {Flag: "-v", Value: "error"}, {Flag: "-xerror"}},
InputFiles: []types.File{{Path: "input.mkv"}},
OutputFiles: []types.File{{Path: "output.mkv", Arguments: []types.Arg{{Flag: "-f", Value: "null"}, {Flag: "-max_muxing_queue_size", Value: "9999"}}}},
}}
} else {
return fmt.Errorf("Unkown Task Type: %v", typ)
}
for _, file := range files {