diff options
author | 2022-12-22 11:48:28 +0100 | |
---|---|---|
committer | 2022-12-22 11:48:28 +0100 | |
commit | 1659f75ae6e491355e1d32f0f5e8b956ef70a797 (patch) | |
tree | 0cc7aba9d8c98ee0163488121328e9cd0c6b32c2 /internal/media/processingmedia.go | |
parent | [bugfix] fix media create error not being checked (#1283) (diff) | |
download | gotosocial-1659f75ae6e491355e1d32f0f5e8b956ef70a797.tar.xz |
[feature] For video attachments, store + return fps, bitrate, duration (#1282)
* start messing about with different mp4 metadata extraction
* heyyooo it works
* add test cow
* move useful multierror to gtserror package
* error out if video doesn't seem to be a real mp4
* test parsing mkv in disguise as mp4
* tidy up error handling
* remove extraneous line
* update framerate formatting
* use float32 for aspect
* fixy mctesterson
Diffstat (limited to 'internal/media/processingmedia.go')
-rw-r--r-- | internal/media/processingmedia.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go index a7ea4dbab..f22102d6d 100644 --- a/internal/media/processingmedia.go +++ b/internal/media/processingmedia.go @@ -249,16 +249,32 @@ func (p *ProcessingMedia) loadFullSize(ctx context.Context) error { } // set appropriate fields on the attachment based on the image we derived + + // generic fields + p.attachment.File.UpdatedAt = time.Now() p.attachment.FileMeta.Original = gtsmodel.Original{ Width: decoded.width, Height: decoded.height, Size: decoded.size, Aspect: decoded.aspect, } - p.attachment.File.UpdatedAt = time.Now() - p.attachment.Processing = gtsmodel.ProcessingStatusProcessed + + // nullable fields + if decoded.duration != 0 { + i := decoded.duration + p.attachment.FileMeta.Original.Duration = &i + } + if decoded.framerate != 0 { + i := decoded.framerate + p.attachment.FileMeta.Original.Framerate = &i + } + if decoded.bitrate != 0 { + i := decoded.bitrate + p.attachment.FileMeta.Original.Bitrate = &i + } // we're done processing the full-size image + p.attachment.Processing = gtsmodel.ProcessingStatusProcessed atomic.StoreInt32(&p.fullSizeState, int32(complete)) log.Tracef("finished processing full size image for attachment %s", p.attachment.URL) fallthrough |