mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 01:33:15 -06:00
[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
This commit is contained in:
parent
9efb11d848
commit
de45c0be60
12 changed files with 495 additions and 351 deletions
|
|
@ -34,17 +34,46 @@ import (
|
|||
)
|
||||
|
||||
var SupportedMIMETypes = []string{
|
||||
mimeImageJpeg,
|
||||
mimeImageGif,
|
||||
mimeImagePng,
|
||||
mimeImageWebp,
|
||||
mimeVideoMp4,
|
||||
"image/jpeg", // .jpeg
|
||||
"image/gif", // .gif
|
||||
"image/webp", // .webp
|
||||
|
||||
"audio/mp2", // .mp2
|
||||
"audio/mp3", // .mp3
|
||||
|
||||
"video/x-msvideo", // .avi
|
||||
|
||||
// png types
|
||||
"image/png", // .png
|
||||
"image/apng", // .apng
|
||||
|
||||
// ogg types
|
||||
"audio/ogg", // .ogg
|
||||
"video/ogg", // .ogv
|
||||
|
||||
// mpeg4 types
|
||||
"audio/x-m4a", // .m4a
|
||||
"video/mp4", // .mp4
|
||||
"video/quicktime", // .mov
|
||||
|
||||
// asf types
|
||||
"audio/x-ms-wma", // .wma
|
||||
"video/x-ms-wmv", // .wmv
|
||||
|
||||
// matroska types
|
||||
"video/webm", // .webm
|
||||
"audio/x-matroska", // .mka
|
||||
"video/x-matroska", // .mkv
|
||||
}
|
||||
|
||||
var SupportedEmojiMIMETypes = []string{
|
||||
mimeImageGif,
|
||||
mimeImagePng,
|
||||
mimeImageWebp,
|
||||
"image/jpeg", // .jpeg
|
||||
"image/gif", // .gif
|
||||
"image/webp", // .webp
|
||||
|
||||
// png types
|
||||
"image/png", // .png
|
||||
"image/apng", // .apng
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
|
|
@ -102,8 +131,8 @@ func (m *Manager) CreateMedia(
|
|||
id,
|
||||
|
||||
// Always encode attachment
|
||||
// thumbnails as jpg.
|
||||
"jpg",
|
||||
// thumbnails as jpeg.
|
||||
"jpeg",
|
||||
)
|
||||
|
||||
// Calculate attachment thumbnail URL.
|
||||
|
|
@ -114,8 +143,8 @@ func (m *Manager) CreateMedia(
|
|||
id,
|
||||
|
||||
// Always encode attachment
|
||||
// thumbnails as jpg.
|
||||
"jpg",
|
||||
// thumbnails as jpeg.
|
||||
"jpeg",
|
||||
)
|
||||
|
||||
// Populate initial fields on the new media,
|
||||
|
|
@ -134,7 +163,7 @@ func (m *Manager) CreateMedia(
|
|||
Path: path,
|
||||
},
|
||||
Thumbnail: gtsmodel.Thumbnail{
|
||||
ContentType: mimeImageJpeg, // thumbs always jpg.
|
||||
ContentType: "image/jpeg",
|
||||
Path: thumbPath,
|
||||
URL: thumbURL,
|
||||
},
|
||||
|
|
@ -244,7 +273,7 @@ func (m *Manager) CreateEmoji(
|
|||
|
||||
// All static emojis
|
||||
// are encoded as png.
|
||||
mimePng,
|
||||
"png",
|
||||
)
|
||||
|
||||
// Generate static image path for attachment.
|
||||
|
|
@ -256,7 +285,7 @@ func (m *Manager) CreateEmoji(
|
|||
|
||||
// All static emojis
|
||||
// are encoded as png.
|
||||
mimePng,
|
||||
"png",
|
||||
)
|
||||
|
||||
// Populate initial fields on the new emoji,
|
||||
|
|
@ -268,7 +297,7 @@ func (m *Manager) CreateEmoji(
|
|||
Domain: domain,
|
||||
ImageStaticURL: staticURL,
|
||||
ImageStaticPath: staticPath,
|
||||
ImageStaticContentType: mimeImagePng,
|
||||
ImageStaticContentType: "image/png",
|
||||
Disabled: util.Ptr(false),
|
||||
VisibleInPicker: util.Ptr(true),
|
||||
CreatedAt: now,
|
||||
|
|
@ -368,7 +397,7 @@ func (m *Manager) RefreshEmoji(
|
|||
|
||||
// All static emojis
|
||||
// are encoded as png.
|
||||
mimePng,
|
||||
"png",
|
||||
)
|
||||
|
||||
// Generate new static image storage path for emoji.
|
||||
|
|
@ -380,7 +409,7 @@ func (m *Manager) RefreshEmoji(
|
|||
|
||||
// All static emojis
|
||||
// are encoded as png.
|
||||
mimePng,
|
||||
"png",
|
||||
)
|
||||
|
||||
// Finally, create new emoji in database.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue