I am using the AndroidX Media3 Transformer to trim a video file, but I can't figure out how to get the duration of the video (without spinning up a player). An earlier answer suggested using MediaMetadataRetriever
, but this is part of the old Media API; I feel like there must be an equivalent in the new API. (It is, after all, something that the player will need access to.)
I see that several of the format decoder classes implement a method getDurationUs()
, which is defined in the SeekMap
interface, which looked promising, but I can't see how to get to that from a MediaItem
.