MediaMetadataRetriever:
Dim metaRetriver As JavaObject
metaRetriver.InitializeNewInstance("android.media.MediaMetadataRetriever", Null)
metaRetriver.RunMethod("setDataSource", Array($"${File.Dir}/name.mp4"$))
Log("height :"&metaRetriver.RunMethod("extractMetadata", Array(metaRetriver.GetField("METADATA_KEY_VIDEO_HEIGHT"))))
Log("width :"&metaRetriver.RunMethod("extractMetadata", Array(metaRetriver.GetField("METADATA_KEY_VIDEO_WIDTH"))))
To detect the orientation of the video we need this field.
B4X:
Log("ROTATION: "&metaRetriver.RunMethod("extractMetadata", Array(metaRetriver.GetField("METADATA_KEY_VIDEO_ROTATION"))))
For whose are more interested let's look at this forum:
Rotation Metadata in Video Files Created by Mobile Devices
Videos recorded using mobile devices contain a lot of metadata. One piece of such data is the rotation metadata. This data is used by browsers such as Chrome and Safari and by video players like VLC and QuickTime to display the video the way it was shot: portrait or landscape.
blog.addpipe.com
Last edited: