ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Provide an API for metadata & frame extraction without playback

Open mhabzda opened this issue 8 years ago • 13 comments

Issue description

I'm trying to extract track information such as title and an artist from the local mp3 file before playing it.

I managed to get track metadata in 'onTracksChanged' callback, but I need access to it earlier. I have File object and its uri and I tried to use Mp3Extractor directly, which needs DataSource, but I'm not sure how to create it.

Could you provide me with the information if such a thing is possible and how to do it?

Version of ExoPlayer being used

2.5.4

mhabzda avatar Dec 18 '17 11:12 mhabzda

The easiest option may be to create a player which is paused (setPlayWhenReady(false)) so that playback doesn't start automatically, then prepare it with your media source. You should get an onTracksChanged callback with the metadata but audio won't start playing.

andrewlewis avatar Dec 19 '17 11:12 andrewlewis

Thank you for your reply, but I wonder if there is a chance to extract metadata without initializing and preparing player? You wrote about the easiest way, so is there another option? Will it take a lot of effort to implement it without using player?

mhabzda avatar Dec 21 '17 08:12 mhabzda

@andrewlewis - Should we turn this into a general enhancement request for providing metadata APIs (or alternatively, should we file a new one and dupe this one to it)?

ojw28 avatar Dec 22 '17 16:12 ojw28

Marking as an enhancement for now.

andrewlewis avatar Dec 22 '17 16:12 andrewlewis

Can you please also consider adding metadata extraction of video files?

AndroidDeveloperLB avatar Jan 24 '19 06:01 AndroidDeveloperLB

@AndroidDeveloperLB That will be included. There is already pending work in that area and we will notify this thread if we publish something.

tonihei avatar Jan 24 '19 09:01 tonihei

@tonihei That's great news. But I also wonder something: Doesn't the Android framework already offer such things ? Or do you plan on much more than what it offers, and have a consistent result, or something ?

AndroidDeveloperLB avatar Jan 24 '19 09:01 AndroidDeveloperLB

@AndroidDeveloperLB @mhabzda some sample code in my project is available here: https://github.com/ened/flutter_plugin_media_info/blob/master/android/src/main/java/asia/ivity/mediainfo/MediaInfoPlugin.java#L139-L188 . It uses the technique mentioned by @andrewlewis, but comes with the full initialisation of a player instance.

ened avatar Oct 08 '19 16:10 ened

@ened Sadly now that Android Q isn't nice to file path, I think you should provide an alternative, that uses Uri or InputStream. Can you please make a repository that shows only this? Meaning of metadata extraction without playback ?

AndroidDeveloperLB avatar Oct 09 '19 13:10 AndroidDeveloperLB

Just adding a clarification for #7285: this API would also support video thumbnail extraction.

kim-vde avatar Apr 24 '20 13:04 kim-vde

Hello. Do you happen to have any updates regarding the frame extraction API?

ademirqueiroga avatar Jan 26 '23 11:01 ademirqueiroga

We don't have any updates on this yet I'm afraid.

andrewlewis avatar Jan 27 '23 13:01 andrewlewis

Coil has this feature that allows to extract the first frame from video: https://coil-kt.github.io/coil/videos/ Although this thing is pretty slow.

I set a transparent background for the player and placed AsyncImage below that. It does work, but flicks with black.

Not sure how to fix this thing

lectricas avatar Aug 27 '23 12:08 lectricas