summaryrefslogtreecommitdiff
path: root/internal/media
AgeCommit message (Collapse)AuthorFiles
2025-02-06temporary fix for tetratelabs/wazero#2365 armv8 compiler support bug (#3741)Libravatar kim1
2025-02-03adds support for build specifically without wasm ffmpeg (#3732)Libravatar kim6
2025-01-08[feature] Fetch + create domain permissions from subscriptions nightly (#3635)Libravatar tobi1
* peepeepoopoo * test domain perm subs * swagger * envparsing * dries your wets * start on docs * finish up docs * copy paste errors * rename actions package * rename force -> skipCache * move obfuscate parse nearer to where err is checked * make higherPrios a simple slice * don't use receiver for permsFrom funcs * add more context to error logs * defer finished log * use switch for permType instead of if/else * thanks linter, love you <3 * validate csv headers before full read * use bufio scanner
2024-12-28[bugfix] Advertise audio/mpeg as supported (#3632)Libravatar Daenney2
This will be either an mp1, mp2 or mp3 file. In practice it'll probably be mp3, but this handles mp1 too for good measure. We don't advertise audio/mp1 as a supported media type since best I can tell that was never a MIME type that's been used. This also changes the returned MIME-type for mp2 and mp3 to audio/mpeg, to match what's expected and supported by most things nowadays. Fixes: #3531
2024-12-05[feature] add support for receiving federated status edits (#3597)Libravatar kim3
* add support for extracting Updated field from Statusable implementers * add support for status edits in the database, and update status dereferencer to handle them * remove unused AdditionalInfo{}.CreatedAt * remove unused AdditionalEmojiInfo{}.CreatedAt * update new mention creation to use status.UpdatedAt * remove mention.UpdatedAt, fixes related to NewULIDFromTime() change * add migration to remove Mention{}.UpdatedAt field * add migration to add the StatusEdit{} table * start adding tests, add delete function for status edits * add more of status edit migrations, fill in more of the necessary edit delete functionality * remove unused function * allow generating gotosocial compatible ulid via CLI with `go run ./cmd/gen-ulid` * add StatusEdit{} test models * fix new statusedits sql * use model instead of table name * actually remove the Mention.UpdatedAt field... * fix tests now new models are added, add more status edit DB tests * fix panic wording * add test for deleting status edits * don't automatically set `updated_at` field on updated statuses * flesh out more of the dereferencer status edit tests, ensure updated at field set on outgoing AS statuses * remove media_attachments.updated_at column * fix up more tests, further complete the dereferencer status edit tests * update more status serialization tests not expecting 'updated' AS property * gah!! json serialization tests!! * undo some gtscontext wrapping changes * more serialization test fixing :smiling_face_with_tear: * more test fixing, ensure the edit.status_id field is actually set :facepalm: * fix status edit test * grrr linter * add edited_at field to apimodel status * remove the choice of paging on the timeline public filtered test (otherwise it needs updating every time you add statuses ...) * ensure that status.updated_at always fits chronologically * fix more serialization tests ... * add more code comments * fix envparsing * update swagger file * properly handle media description changes during status edits * slight formatting tweak * code comment
2024-11-06[chore] update go ffmpreg to v0.6.0 (#3515)Libravatar kim4
* pull in go-ffmpreg v0.6.0 * add code comment * grrr linter * set empty module name when calling ffmpeg / ffprobe
2024-11-05previously we were using the ffmpeg runner for ffprobe :facepalm: (#3512)Libravatar kim1
2024-11-04[bugfix] determine mime-type to use during ffprobe evaluation stage, don't ↵Libravatar kim7
bother checking against file extension (#3506) * determine mime-type to use during ffprobe evaluation stage, don't bother rechecking by file extension * set mjpeg content-type * fix up tests expecting differing default values
2024-10-28[bugfix] support classifying correct video codec without audio as webm (#3494)Libravatar kim3
* for webm support video:[vp8,vp9,av1] and audio:[NONE,vorbis,opus] * improved unsupported data type error output
2024-10-28[chore] pull in go-ffmpreg v0.4.1 (#3485)Libravatar kim1
* pull in go-ffmpreg v0.4.1 * bring back GTS_WAZERO_COMPILATION_CACHE
2024-10-18[chore] Thumbnail only first frame of animated media (#3448)Libravatar tobi8
2024-10-16[chore] Upgrade golangci-lint, ignore existing int overflow warnings (#3420)Libravatar Markus Unterwaditzer4
* [chore] Bump tooling versions, bump go -> v1.23.0 * undo silly change * sign * bump go version in go.mod * allow overflow in imaging * goreleaser deprecation notices * [chore] Upgrade golangci-lint, ignore existing int overflow warnings There is a new lint for unchecked int casts. Integer overflows are bad, but the old code that triggers this lint seems to be perfectly fine. Instead of disabling the lint entirely for new code as well, grandfather in existing code. * fix golangci-lint documentation link * revert unrelated changes * revert another unrelated change * get rid of remaining nolint:gosec * swagger updates * apply review feedback * fix wrong formatting specifier thing * fix the linter for real --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
2024-10-14[feature/OFFICIALLY UNSUPPORTED] add nowasm build tag to disable building ↵Libravatar kim8
with WebAssembly (#3429) * add experimental build-tag 'nowasm' which uses local ffmpeg / ffprobe * updated experimental support message * add comment to build script explaining build tag * add nowasm build tags to moderncsqlite files
2024-10-06update go-ffmpreg to v0.3.1 (pulls in latest wazero too) (#3398)Libravatar kim2
2024-09-27[bugfix] better handle ogg container format (#3365)Libravatar kim1
2024-09-27[bugfix] fix media limit reader check (#3363)Libravatar kim1
* return nicer errors for frontend when media / emoji upload limit reached * fix reader limit check * add code comment
2024-09-26[bugfix] s3 media uploaded without content-type (#3353)Libravatar kim2
* update go-storage dependency, for S3Storage manually call PutObject() so we can set content-type * update calls to PutFile() to include the contentType
2024-09-23[bugfix] add support for media with rotation contained in stream side data ↵Libravatar kim1
(#3335) * add support for media with embedded rotation data in stream side data list * *grumble grumble* linter
2024-08-31[performance] use single-threaded image transforms (#3252)Libravatar kim3
* use single-threaded image resizing in native code so we have more control over goroutines * implement parallel-free versions of image transform functions also * remove debug code
2024-08-30[security] Implement `allowFiles` fs for better isolation of ffmpeg / ↵Libravatar tobi2
ffprobe (#3251) * [chore] Implement readOneFile fs * further isolation * remove fmt call * tweaks
2024-08-29[chore] Only call `imaging.Resize when necessary`, use even tinier ↵Libravatar tobi3
blurhashes (#3247) * [chore] Use `imaging.Fit`, use even tinier blurhashes * avoid calling resize if not necessary * update blurhashes + thumb
2024-08-25[chore] Remove unused "env" module (#3235)Libravatar tobi1
2024-08-23[performance] ffmpeg ffprobe wrapper improvements (#3225)Libravatar kim7
* use a single instance of wazero runtime and compiled modules * remove test output :facepalm: * undo process-{media,emoji} changes * update test runner to include wazero compilation cache * sign drone.yml --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
2024-08-19[performance] use native Go code to probe JPEGs (#3206)Libravatar kim4
* use native Go code to probe JPEGs * add note about copying from github.com/disintegration/imaging * add more code comments
2024-08-16[bugfix] permit unspecified orientation data (#3205)Libravatar kim1
2024-08-08[performance] move thumbnail generation to go code where possible (#3183)Libravatar kim15
* wrap thumbnailing code to handle generation natively where possible * more code comments! * add even more code comments! * add code comments about blurhash generation * maintain image rotation if contained in exif data * move rotation before resizing * ensure pix_fmt actually selected by ffprobe, check for alpha layer with gifs * use linear instead of nearest-neighbour for resizing * work with image "orientation" instead of "rotation". use default 75% quality for both webp and jpeg generation * add header to new file * use thumb extension when getting thumb mime type * update test models and tests with new media processing * add suggested code comments * add note about thumbnail filter count reducing memory usage
2024-08-08[feature] Use gifv type for short soundless mp4 videos (#3182)Libravatar tobi2
2024-08-03[bugfix] fix emoji recaching operations (#3167)Libravatar kim3
* add test for emoji update image * update emoji recache to set the instance account id * don't refresh emoji if only not cached. in that case literally just recache * code comment * rename + move a few things * add some more code comments, and rename some functions to make logic a bit clearer * remove unnecessary nil check (the value can be nil) * comment wording * remove test data output * handle the case of caching an emoji which has been refreshed then uncached * allow overwriting on testrig storage as we do now on regular storage * fix emoji category ID not getting updated --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
2024-08-02[bugfix] close files before error return (#3163)Libravatar kim2
* close files before error return * use defer statements * shuffle around some defers
2024-08-02[chore] add back exif-terminator and use only for jpeg,png,webp (#3161)Libravatar kim6
* add back exif-terminator and use only for jpeg,png,webp * fix arguments passed to terminateExif() * pull in latest exif-terminator * fix test * update processed img --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
2024-07-31[chore] Take account of rotation data when calculating full size image ↵Libravatar tobi3
dimensions (#3159) * [chore] Take account of rotation data when calculating full size image dimensions * boobies
2024-07-30[performance] limit ffprobe read time to at most 1s after start of file (#3155)Libravatar kim1
2024-07-30[chore] add some more slice related utility functions + remove duplicated ↵Libravatar kim1
functions (#3149)
2024-07-28[bugfix] take into account rotation when generating thumbnail (#3147)Libravatar kim4
* take into account rotation when generating thumbnail, simplify ffprobe output to show only fields we need * only show rotation side data * remove unnecessary comment * fix code comments * remove debug logging
2024-07-28[bugfix] moves file rename to earlier in media pipeline so ffmpeg calls ↵Libravatar kim3
ALWAYS have extension (#3146)
2024-07-26ensure ffmpeg muxer gets set correctly by setting input file extension ↵Libravatar kim1
before clean (#3142)
2024-07-22[bugfix] media.Processor{}.GetFile() returning 404s on first call, correctly ↵Libravatar kim2
loading on 2nd (#3129) * refactor file handling a tiny bit * whoops * make processing media / emoji defers a bit clear to see that it's the "on finished processing" path * some wording * add some debug logging * add mutex locks for processing remote media * try removing freshness check * fix derefMedia not being allocated * fix log format string * handle case of empty file paths (i.e. not stored) * remove media / emoji once finished processing from dereferencer maps * whoops, fix the cached / force checks * move url parsing outside of 'process___Safely()' funcs to prevalidate url * use emoji.ShortcodeDomain() * update RefreshEmoji() to also match RefreshMedia() changes --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
2024-07-21[feature] add flac support (#3121)Libravatar kim2
* add flac support to the ffprobe format/stream -> filetype parser * also add audio/flac for flac (not just x-flac) * update tests --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
2024-07-20update go-ffmpreg to v0.2.3 (#3120)Libravatar kim2
2024-07-19[feature] use webp for thumbnails (#3116)Libravatar kim19
* update to use webp for thumbnails * bump webp quality up to 40% from 12% (it's a bit different to jpeg quality setting) * update to use yuva colorspace, and use thumbnail=n=10 to select frame * fix missing comma in ffmpeg args * add links to appropriate ffmpeg docs * update tests * add file size tests for thumbnails --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
2024-07-17[chore] media pipeline improvements (#3110)Libravatar kim5
* don't set emoji / media image paths on failed download, migrate FileType from string to integer * fix incorrect uses of util.PtrOr, fix returned frontend media * fix migration not setting arguments correctly in where clause * fix not providing default with not null column * whoops * ensure a default gets set for media attachment file type * remove the exclusive flag from writing files in disk storage * rename PtrOr -> PtrOrZero, and rename PtrValueOr -> PtrOrValue to match * slight wording changes * use singular / plural word forms (no parentheses), is better for screen readers * update testmodels with unknown media type to have unset file details, update attachment focus handling converting to frontend, update tests * store first instance in ffmpeg wasm pool, fill remaining with closed instances
2024-07-16give read-only access to /dev for ffmpeg to access /dev/urandom (#3109)Libravatar kim1
2024-07-15[feature] more filetype support! (#3107)Libravatar kim6
* 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
2024-07-15[feature/frontend] Add player for audio files; use thumbnail for `poster` ↵Libravatar tobi2
(#3099) * [feature/frontend] Audio player for audio media types * use video preview images for previews instead of video itself * don't preload * update tests for new zork status * collapse media gallery into single row when small
2024-07-12[feature] support processing of (many) more media types (#3090)Libravatar kim30
* initial work replacing our media decoding / encoding pipeline with ffprobe + ffmpeg * specify the video codec to use when generating static image from emoji * update go-storage library (fixes incompatibility after updating go-iotools) * maintain image aspect ratio when generating a thumbnail for it * update readme to show go-ffmpreg * fix a bunch of media tests, move filesize checking to callers of media manager for more flexibility * remove extra debug from error message * fix up incorrect function signatures * update PutFile to just use regular file copy, as changes are file is on separate partition * fix remaining tests, remove some unneeded tests now we're working with ffmpeg/ffprobe * update more tests, add more code comments * add utilities to generate processed emoji / media outputs * fix remaining tests * add test for opus media file, add license header to utility cmds * limit the number of concurrently available ffmpeg / ffprobe instances * reduce number of instances * further reduce number of instances * fix envparsing test with configuration variables * update docs and configuration with new media-{local,remote}-max-size variables
2024-07-03[chore] Allow gtsmodel to depend on util (#3068)Libravatar Vyr Cossont2
Convert one free function into a gtsmodel.Emoji method so that util does not depend on gtsmodel and can be used from it in the future
2024-06-26[chore] media and emoji refactoring (#3000)Libravatar kim8
* start updating media manager interface ready for storing attachments / emoji right away * store emoji and media as uncached immediately, then (re-)cache on Processing{}.Load() * remove now unused media workers * fix tests and issues * fix another test! * fix emoji activitypub uri setting behaviour, fix remainder of test compilation issues * fix more tests * fix (most of) remaining tests, add debouncing to repeatedly failing media / emojis * whoops, rebase issue * remove kim's whacky experiments * do some reshuffling, ensure emoji uri gets set * ensure marked as not cached on cleanup * tweaks to media / emoji processing to handle context canceled better * ensure newly fetched emojis actually get set in returned slice * use different varnames to be a bit more obvious * move emoji refresh rate limiting to dereferencer * add exported dereferencer functions for remote media, use these for recaching in processor * add check for nil attachment in updateAttachment() * remove unused emoji and media fields + columns * see previous commit * fix old migrations expecting image_updated_at to exists (from copies of old models) * remove freshness checking code (seems to be broken...) * fix error arg causing nil ptr exception * finish documentating functions with comments, slight tweaks to media / emoji deref error logic * remove some extra unneeded boolean checking * finish writing documentation (code comments) for exported media manager methods * undo changes to migration snapshot gtsmodels, updated failing migration to have its own snapshot * move doesColumnExist() to util.go in migrations package
2024-05-22[performance] update storage backend and make use of seek syscall when ↵Libravatar kim4
available (#2924) * update to use go-storage/ instead of go-store/v2/storage/ * pull in latest version from codeberg * remove test output :innocent: * add code comments * set the exclusive bit when creating new files in disk config * bump to actual release version * bump to v0.1.1 (tis a simple no-logic change) * update readme * only use a temporary read seeker when decoding video if required (should only be S3 now) * use fastcopy library to use memory pooled buffers when calling TempFileSeeker() * update to use seek call in serveFileRange()
2024-04-26[performance] update remaining worker pools to use queues (#2865)Libravatar kim3
* start replacing client + federator + media workers with new worker + queue types * refactor federatingDB.Delete(), drop queued messages when deleting account / status * move all queue purging to the processor workers * undo toolchain updates * code comments, ensure dereferencer worker pool gets started * update gruf libraries in readme * start the job scheduler separately to the worker pools * reshuffle ordering or server.go + remove duplicate worker start / stop * update go-list version * fix vendoring * move queue invalidation to before wipeing / deletion, to ensure queued work not dropped * add logging to worker processing functions in testrig, don't start workers in unexpected places * update go-structr to add (+then rely on) QueueCtx{} type * ensure more worker pools get started properly in tests * fix remaining broken tests relying on worker queue logic * fix account test suite queue popping logic, ensure noop workers do not pull from queue * move back accidentally shuffled account deletion order * ensure error (non nil!!) gets passed in refactored federatingDB{}.Delete() * silently drop deletes from accounts not permitted to * don't warn log on forwarded deletes * make if else clauses easier to parse * use getFederatorMsg() * improved code comment * improved code comment re: requesting account delete checks * remove boolean result from worker start / stop since false = already running or already stopped * remove optional passed-in http.client * remove worker starting from the admin CLI commands (we don't need to handle side-effects) * update prune cli to start scheduler but not all of the workers * fix rebase issues * remove redundant return statements * i'm sorry sir linter
2024-04-11[performance] massively improved ActivityPub delivery worker efficiency (#2812)Libravatar kim1
* add delivery worker type that pulls from queue to httpclient package * finish up some code commenting, bodge a vendored activity library change, integrate the deliverypool changes into transportcontroller * hook up queue deletion logic * support deleting queued http requests by target ID * don't index APRequest by hostname in the queue * use gorun * use the original context's values when wrapping msg type as delivery{} * actually log in the AP delivery worker ... * add uncommitted changes * use errors.AsV2() * use errorsv2.AsV2() * finish adding some code comments, add bad host handling to delivery workers * slightly tweak deliveryworkerpool API, use advanced sender multiplier * remove PopCtx() method, let others instead rely on Wait() * shuffle things around to move delivery stuff into transport/ subpkg * remove dead code * formatting * validate request before queueing for delivery * finish adding code comments, fix up backoff code * finish adding more code comments * clamp minimum no. senders to 1 * add start/stop logging to delivery worker, some slight changes * remove double logging * use worker ptrs * expose the embedded log fields in httpclient.Request{} * ensure request context values are preserved when updating ctx * add delivery worker tests * fix linter issues * ensure delivery worker gets inited in testrig * fix tests to delivering messages to check worker delivery queue * update error type to use ptr instead of value receiver * fix test calling Workers{}.Start() instead of testrig.StartWorkers() * update docs for advanced-sender-multiplier * update to the latest activity library version * add comment about not using httptest.Server{}