[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
This commit is contained in:
tobi 2022-12-22 11:48:28 +01:00 committed by GitHub
commit 1659f75ae6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 433 additions and 108 deletions

View file

@ -48,7 +48,7 @@ func decodeGif(r io.Reader) (*mediaMeta, error) {
width := gif.Config.Width
height := gif.Config.Height
size := width * height
aspect := float64(width) / float64(height)
aspect := float32(width) / float32(height)
return &mediaMeta{
width: width,
@ -85,7 +85,7 @@ func decodeImage(r io.Reader, contentType string) (*mediaMeta, error) {
width := i.Bounds().Size().X
height := i.Bounds().Size().Y
size := width * height
aspect := float64(width) / float64(height)
aspect := float32(width) / float32(height)
return &mediaMeta{
width: width,
@ -167,7 +167,7 @@ func deriveThumbnailFromImage(r io.Reader, contentType string, createBlurhash bo
thumbX := thumb.Bounds().Size().X
thumbY := thumb.Bounds().Size().Y
size := thumbX * thumbY
aspect := float64(thumbX) / float64(thumbY)
aspect := float32(thumbX) / float32(thumbY)
im := &mediaMeta{
width: thumbX,