I’m new to working with videos in android development and I’m trying to extract a bitmap and information from a video online. I’ve tried using ffmpeg, but seems like I’m required to download the video before it can extract the data. I would think taking that approach could burn through a users data.
This is the error I get when I attempt to capture the metadata, but when using a tool like exif I’m able to see attached metadata.
LaunchedEffect(uri) {
try {
val player = ExoPlayer.Builder(context).build().apply {
setMediaItem(androidx.media3.common.MediaItem.fromUri(uri))
prepare()
}
// Retrieve video duration
videoLength = player.duration.coerceAtLeast(0L)
// Retrieve the first frame as a bitmap (ExoPlayer doesn't directly support frame extraction)
bitmap = getFrameFromVideo(context, uri)
player.release()
} catch (e: Exception) {
Log.e("VideoPlayerView", "Error retrieving video metadata", e)
}
}
Any pointers on how I can approach this? My end goal is a bitmap image from a frame and some metadata info.