From de45c0be60e453e69263f5b32ab2ce2661dc74ca Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:24:53 +0000 Subject: [feature] more filetype support! (#3107) * add more supported file types to our media processor that ffmpeg supports, update supported mime type lists * add code comments to the supported mime types slice * don't check for zero value string, just parse * remove some unneeded consts which make the code a bit harder to read * fix test expected instance media mime types, use compact ffprobe json, simple media processing by type * final tweaks to media processing code * don't use safe divide where we don't need to --- cmd/process-emoji/main.go | 9 +++++++++ cmd/process-media/main.go | 12 ++++++++++++ 2 files changed, 21 insertions(+) (limited to 'cmd') diff --git a/cmd/process-emoji/main.go b/cmd/process-emoji/main.go index 62253bbdf..b06eb84f8 100644 --- a/cmd/process-emoji/main.go +++ b/cmd/process-emoji/main.go @@ -29,6 +29,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/db/bundb" "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/media" + "github.com/superseriousbusiness/gotosocial/internal/media/ffmpeg" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/storage" "github.com/superseriousbusiness/gotosocial/internal/util" @@ -43,6 +44,14 @@ func main() { log.Panic(ctx, "Usage: go run ./cmd/process-emoji ") } + if err := ffmpeg.InitFfprobe(ctx, 1); err != nil { + log.Panic(ctx, err) + } + + if err := ffmpeg.InitFfmpeg(ctx, 1); err != nil { + log.Panic(ctx, err) + } + var st storage.Driver st.Storage = memory.Open(10, true) diff --git a/cmd/process-media/main.go b/cmd/process-media/main.go index 2f5a43f31..096d718f9 100644 --- a/cmd/process-media/main.go +++ b/cmd/process-media/main.go @@ -29,6 +29,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/db/bundb" "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/media" + "github.com/superseriousbusiness/gotosocial/internal/media/ffmpeg" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/storage" ) @@ -42,6 +43,14 @@ func main() { log.Panic(ctx, "Usage: go run ./cmd/process-media ") } + if err := ffmpeg.InitFfprobe(ctx, 1); err != nil { + log.Panic(ctx, err) + } + + if err := ffmpeg.InitFfmpeg(ctx, 1); err != nil { + log.Panic(ctx, err) + } + var st storage.Driver st.Storage = memory.Open(10, true) @@ -105,6 +114,9 @@ func main() { func copyFile(ctx context.Context, st *storage.Driver, key string, path string) { rc, err := st.GetStream(ctx, key) if err != nil { + if storage.IsNotFound(err) { + return + } log.Panic(ctx, err) } defer rc.Close() -- cgit v1.2.3