diff options
author | 2024-10-28 13:09:21 +0000 | |
---|---|---|
committer | 2024-10-28 14:09:21 +0100 | |
commit | 7ec6509e11cc2d07b5b0f3ccdbb1d42026314578 (patch) | |
tree | 254b573f8e719f8d0ce2c7466e84a69e10a4ef29 /internal/media/ffmpeg.go | |
parent | [chore] pull in go-ffmpreg v0.4.1 (#3485) (diff) | |
download | gotosocial-7ec6509e11cc2d07b5b0f3ccdbb1d42026314578.tar.xz |
[bugfix] support classifying correct video codec without audio as webm (#3494)
* for webm support video:[vp8,vp9,av1] and audio:[NONE,vorbis,opus]
* improved unsupported data type error output
Diffstat (limited to 'internal/media/ffmpeg.go')
-rw-r--r-- | internal/media/ffmpeg.go | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/internal/media/ffmpeg.go b/internal/media/ffmpeg.go index ba251bd26..976662e60 100644 --- a/internal/media/ffmpeg.go +++ b/internal/media/ffmpeg.go @@ -392,18 +392,31 @@ func (res *result) GetFileType() (gtsmodel.FileType, string) { case "matroska,webm": switch { case len(res.video) > 0: + var isWebm bool + switch res.video[0].codec { case "vp8", "vp9", "av1": - default: - return gtsmodel.FileTypeVideo, "mkv" - } - if len(res.audio) > 0 { - switch res.audio[0].codec { - case "vorbis", "opus", "libopus": - // webm only supports [VP8/VP9/AV1]+[vorbis/opus] - return gtsmodel.FileTypeVideo, "webm" + if len(res.audio) > 0 { + switch res.audio[0].codec { + case "vorbis", "opus", "libopus": + // webm only supports [VP8/VP9/AV1] + + // [vorbis/opus] + isWebm = true + } + } else { + // no audio with correct + // video codec also fine. + isWebm = true } } + + if isWebm { + // Check for valid webm codec config. + return gtsmodel.FileTypeVideo, "webm" + } + + // All else falls under generic mkv. + return gtsmodel.FileTypeVideo, "mkv" case len(res.audio) > 0: return gtsmodel.FileTypeAudio, "mka" } |